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
235 stars 67 forks source link

Unable to use Update-GSOrganizationalUnit #218

Closed Chris4678 closed 5 years ago

Chris4678 commented 5 years ago

I have been trying to use the Update-GSOrganizationalUnit command to move an OU. Using the Wiki I have tried both the ID and path method but get an error every time. For example: Update-GSOrganizationalUnit -OrgUnitID "IDofOUtoBeMoved" -ParentOrgUnitPath "/NewParentOU" -ParentOrgUnitID "IDofNewParent"

This gives me an error saying parent org unit not found. I copy and pasted the path and ID from the output of Get-GSorganizationalUnit.

I then tried to get just anything at all working and tried to rename an OU: Update-GSOrganizationalUnit -orgUnitID "IDofOU" -name "test"

This gives me a different error: "You cannot call a method on a null-valued expression" This one is pretty much an exact copy of one of the examples on the wiki so I am really not sure what to change. Any idea what I am doing wrong?

I really need to be able to move OUs, if there is another way to do this I am happy to try it out.

scrthq commented 5 years ago

Hey @Chris4678 - Checking this out tonight! Thanks for raising this issue, sounds like a bug to me!

scrthq commented 5 years ago

side note - are you explicitly importing the module first or are you autoloading by running one of the command directly? if autoloading, can you try restarting your session, running Import-Module PSGSuite, then running the command and seeing if it replicates the error?

Chris4678 commented 5 years ago

I am using the import-module method. I have it as one of the first lines in my script as well as the switch config command so that I make sure I am accessing the correct account.

scrthq commented 5 years ago

@Chris4678 - Found the issue and got it sorted! Working on a couple other issues and enhancements but I'll have this out soon!

image

scrthq commented 5 years ago

Hey @Chris4678 - fix deploying now in v2.31.0! I'll ping here once available in PSGallery, should be about 10 minutes

scrthq commented 5 years ago

annnnnd update when you can and let me know!

Chris4678 commented 5 years ago

It works! Thanks so much!

scrthq commented 5 years ago

You bet!

Sent with GitHawk

sigvaldhoy commented 3 years ago

Hi @scrthq , I hope you can help me, I'm having this issue in v.2.36.4

Trying to update using: Update-GSOrganizationalUnit -OrgUnitID idOfOrgUnit -Description "New description" -Verbose

Output:

VERBOSE: Updating OrgUnit ''
Update-GSOrganizationalUnit : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Org unit not found [404]
Errors [
    Message[Org unit not found] Location[ - ] Reason[notFound] Domain[global]
]
"
At line:1 char:1
+ Update-GSOrganizationalUnit -OrgUnitID "id:03ph8a2z0t0cibm" -Descript ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-GSOrganizationalUnit

And trying to use path: Update-GSOrganizationalUnit -OrgUnitPath /root_org_unit/target_org_unit -Description "New description" -Verbose

Output:

Get-GSOrganizationalUnit : Exception calling "Execute" with "0" argument(s): "Google.Apis.Requests.RequestError
Org unit not found [404]
Errors [
    Message[Org unit not found] Location[ - ] Reason[notFound] Domain[global]
]
"
At C:\Program Files\WindowsPowerShell\Modules\PSGSuite\2.36.4\PSGSuite.psm1:22467 char:21
+ ...             Get-GSOrganizationalUnit -SearchBase $OrgUnitPath -Search ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-GSOrganizationalUnit

VERBOSE: Updating OrgUnit '/root_org_unit/target_org_unit'
Update-GSOrganizationalUnit : You cannot call a method on a null-valued expression.
At line:1 char:1
+ Update-GSOrganizationalUnit -OrgUnitPath /root_org_unit/target_org_unit ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Update-GSOrganizationalUnit