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

Update-GSUser Invalid Password #251

Closed Koftic closed 4 years ago

Koftic commented 4 years ago

Good afternoon, I am having issues updating passwords for GSUsers, when I run the lines below I get an error that says: image

Here is the code:

`

Check for user on google

Write-Output "Checking for AD sync to google." do { Try { $Replication = Get-GSUser -User $Username -ErrorAction Stop }Catch{ Start-Sleep -Seconds 5 $Replication = $null } }while ($null -eq $Replication)

Write-Verbose "Setting password"

sync password to google

Update-GSUser -User $Username -Password (ConvertTo-SecureString $Password -AsPlainText -Force) -Confirm:$false

Write-Output "Student account created and synced with Google" ` Any help would be greatly appreciated.

scrthq commented 4 years ago

hey @Koftic - it seems like Google isn't liking the password you're trying to provide, as that is the response returned by Google's server specifically. Have you tried removing special characters to test a bare password update?

Considering you're syncing from AD to Google, are you also using something like Google Cloud Password Sync to also sync those passwords from AD to Google as well?

scrthq commented 4 years ago

for reference: https://support.google.com/a/answer/2611859?hl=en

Koftic commented 4 years ago

@scrthq Hey thanks for replying so quickly! We are using Google Cloud Password Sync and I have been testing it with a basic password. 1 Uppercase, letters and numbers, no special characters.

scrthq commented 4 years ago

Considering you're using GSPS, what would be the use case for updating the password directly on the Google side? I don't use it internally, but we were gearing up to do so not too long ago and from my understanding, you would be updating on the AD side only with GSPS in place. Could be completely wrong, but I'm curious if Google blocks direct password updates in this scenario as well when it sees that you're using GSPS

Koftic commented 4 years ago

We are having issues with GSPS, it only works about 20% of the time. Whenever a user in AD changes their password GSPS should sync it with their Google account but it rarely works.. We were hoping that we could reliably push the passwords of new students if we updated it directly. Also I just ran the script again without changing anything and this time it worked. No idea why. I'll continue to test this to see if the issue comes back.

scrthq commented 4 years ago

hey @Koftic - Odd that it just started working, maybe something messing with the session. Let me know if this pops up again!