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

Updating users ExternalIds #224

Closed Chris4678 closed 5 years ago

Chris4678 commented 5 years ago

I need to update existing users externalIds. I follow the Wiki and see that I first need to create an object using Add-GSUserExternalId and then pass that object to the Update-GSUser command. However, when I try to create the first ID object the command always gives me an error saying: Add-GSUserExternalId : Cannot process argument transformation on parameter 'InputObject'. Cannot convert the "xxxxxxxxxx" value of type "System.Int32" to type "Google.Apis.Admin.Directory.directory_v1.Data.UserExternalId[]".

My syntax looks like this: $test = Add-GSUserExternalId -InputObject xxxxxxxxxx -Verbose Update-GSUser -User "email@domain.com" -ExternalIds $test

Any idea what I might be doing wrong or is this a bug?

scrthq commented 5 years ago

Hey @Chris4678 - The InputObject parameter set is there to allow piping existing ExternalId objects into it (i.e. for copying from another user). You'll want to use the other parameter set to specify the Type and Value of the external ID, i.e.:

$test= Add-GSUserExternalId -Type login_id -Value 1234567890
Update-GSUser -User "email@domain.com" -ExternalIds $test
Chris4678 commented 5 years ago

Well now the command runs without an error, however, I may still not be doing something correctly. What I want is for this ID to appear as the "EmployeeID" in Google. I dont see any direct command for updating employee ID and I thought this was it. Should I be using something else?

Chris4678 commented 5 years ago

Hey I just figured it out. For anyone that finds this I had to change the -Type tag to "-Type Organization" Thanks for the help!

scrthq commented 5 years ago

Nice!! Yeah, it's a bit odd with how it's worded but I'm glad you're sorted!!