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 66 forks source link

v2.34.0 - Error in New-GoogleService when config path contains a space #247

Closed cobra3k closed 4 years ago

cobra3k commented 4 years ago

Running PSGSuite v2.34.0

After creating a configuration successfully, attempting to run any commandlet results in the following:

New-GoogleService : Exception calling ".ctor" with "3" argument(s): "Cannot find the requested object.

After looking through the issues in GitHub and seeing #189, I decided to try changing the profile path of my Windows profile from "C:\Users\Jason Hepler" to "C:\Users\jhepler".

After making that change, and recreating the PSGSuite configuration, the commands ran successfully.

scrthq commented 4 years ago

hey @cobra3k - That issue wasn't regarding a path with a space in it, that was a path with special characters in it. I think this is more coincidental than anything, as that .ctor error can happen when the SDK's are correctly loaded (e.g. when the module is auto-imported by running commands directly instead of calling Import-Module PSGSuite first. Also worth noting that it wasn't the path so much as it was the username, which I've completely removed from New-GoogleService since.

Currently, the only section referencing the profile path would be this line from New-GoogleService. This would only come into play though if you are using the client_secrets.json method (e.g. non-G Suite Admin) and should allow any path you throw at it, spaces or not.

If possible, could you revert your profile back and test once more?

cobra3k commented 4 years ago

I created a new account with a space in the name and was unable to replicate the issue. At this point I'm questioning if it was user error on my end somewhere in the process.

I would say we can just close the issue and call it user error and if I encounter it again on another machine I can be more thorough on documenting the environment and errors and submit another issue.

scrthq commented 4 years ago

I think it was honestly just coincidental! Worth an ask though, I appreciate you posting here in case someone else comes across the same issue!

General best practice would be to ensure that the module is explicitly imported first before running commands ✔️

Since you got it working on a new user account, is it working when you revert and try again with the account you were originally hit the error with? Just want to make sure you're 100% good to go, as if it's not working still on the other account, then it's worth a sanity check at least =]

cobra3k commented 4 years ago

I"m just leaving my account as is, as I prefer it without the space anyway. I appreciate you following up to make sure I'm functioning in my steady state =)

scrthq commented 4 years ago

Gotcha! No problem at all, just want to make sure you're good to go and any potential bugs are squashed!