SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 68 forks source link

Add Last Known Network to Get-GSChromeOSDevice #376

Open schmittg25 opened 1 year ago

schmittg25 commented 1 year ago

Is it possible to add the lastKnownNetwork info from https://developers.google.com/admin-sdk/directory/reference/rest/v1/chromeosdevices to the Get-GSChromeOSDevice function?

Foggy2 commented 1 year ago

I just had a quick look at this. All that is required is to update to the latest DLLs for the Directory API.

I have compiled the module myself incorporating some of the other changes that I have made. This version has the updated DLLs and contains the lastKnownNetwork property.

From what I can tell the build process (build.ps1 in the root) automatically downloads the latest versions of the DLLs. So you could try building it yourself. Otherwise, I assume that the DLLs will be updated with the next release.

schmittg25 commented 1 year ago

Do you mind sharing how you got those dlls? I'm pretty desperate and I'll give it a shot myself.

Thanks!

Foggy2 commented 1 year ago

The DLLs can be downloaded via Nuget.

I have found the easiest way is to build the module yourself by downloading the source from the Github repo. Then run the build.ps1 file.

When I built it the first time it prompted to install the required modules for the build process but I still ran into some errors. From memory I needed to install Git and then it worked fine.

From what I understand the build process will download the latest versions of the Google DLLs and the specified versions of the Newtonsoft.json.dll. To get the updated version of that one simply modify the ci/NuGetDependencies.json file and increase the version number from 12.0.1 to 13.0.1. I know that 13.0.1 works as I used it here.

schmittg25 commented 1 year ago

------ UPDATE-----

I seem to have fixed this by renaming the folder it downloaded from PSGSuite to PSGSuite-main.


So I'm trying to follow the directions located at https://psgsuite.io/Initial%20Setup/ I downloaded git and installed it on my windows 10 box. I copy and paste the commands and I get this error:

Error: 10/31/2022 9:28:47 AM: At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psm1:544 char:35 + foreach($resolvedPath in (Resolve-Path @PSBoundParameters)) + ~~~~~~~ [<<==>>] Exception: Cannot find path 'C:\users\schmittg\Downloads\PSGSuite-main\PSGSuite-main\PSGSuite\PSGSuite.psd1' because it does not exist.

Any ideas? Or can you share with me the link to the DLL's from google and I can just download it directly?

Thanks so much!

------ UPDATE-----

I seem to have fixed this by renaming the folder it downloaded from PSGSuite to PSGSuite-main.


schmittg25 commented 1 year ago

So now I am getting this issue:

Error: 10/31/2022 9:51:31 AM: At C:\users\schmittg\Downloads\PSGSuite-main\BuildOutput\PSGSuite\2.36.6\PSGSuite.psm1:29380 char:1 + Import-GoogleSDK + ~~~~ [<<==>>] Exception: Google.Apis.Core.dll: Unable to load assembly!

And now I'm really stumped.

Foggy2 commented 1 year ago

Hmm. I am not super familiar with the build process so I am not sure why that would be happening.

To get the DLLs the names are found in the ci/NuGetDependencies.json file. Simply search for them on Nuget. EG, Google.Apis.Core

I am not certain but I think it should be as simple as replacing the DLLs in the already installed module directory. eg, C:\Program Files\WindowsPowerShell\Modules\PSGSuite\2.36.4\lib\net45

schmittg25 commented 1 year ago

So I finally got it working, what a project.... I had to get the files from NuGet and replace them manually. Here's the steps I took:

  1. Install git for windows from https://gitforwindows.org/ version 2.38.1 64bit with all preselected options from installer
  2. Open powershell as admin
  3. Install-Module Configuration
  4. Clone repo to my computer: git clone https://github.com/scrthq/PSGSuite.git
  5. Rename folder from PSGSuite to PSGSuite-main
  6. Execute .\build.ps1 -Task Full
  7. Close powershell
  8. Go to NuGet Package Explorer (WASM) and download /lib/net45/Newtonsoft.Json.dll and place it in \builoutput\PSGSuite\2.36.6\lib\net45
  9. Open Powershell as admin
  10. Import-Module ./BuildOutput/PSGSuite -Force

Thank you for all the help @Foggy2

CharEmMech commented 6 months ago

So I finally got it working, what a project.... I had to get the files from NuGet and replace them manually. Here's the steps I took:

  1. Install git for windows from https://gitforwindows.org/ version 2.38.1 64bit with all preselected options from installer
  2. Open powershell as admin
  3. Install-Module Configuration
  4. Clone repo to my computer: git clone https://github.com/scrthq/PSGSuite.git
  5. Rename folder from PSGSuite to PSGSuite-main
  6. Execute .\build.ps1 -Task Full
  7. Close powershell
  8. Go to NuGet Package Explorer (WASM) and download /lib/net45/Newtonsoft.Json.dll and place it in \builoutput\PSGSuite\2.36.6\lib\net45
  9. Open Powershell as admin
  10. Import-Module ./BuildOutput/PSGSuite -Force

Thank you for all the help @Foggy2

For step 8, if you download the Newtonsoft.Json.dll from the internet you may also need to right click the file, select properties, and check "Unblock" and apply. The module would not import until I did this.