Scheduled PowerShell Script Not Working

133 views
Skip to first unread message

Wes C

unread,
Nov 15, 2021, 3:08:29 PM11/15/21
to GAM for Google Workspace
I have a PowerShell script that calls GAM is export specific data and then formats the data in a specific way for a variety of other integrations.  Pulling the data works just fine but using GAM to reset passwords does not. I have tried calling the GAM command via bat file

Start-Process "cmd.exe" "/c C:\Scripts\PasswordSet\SetPasswords.bat" 

as well as  calling the command directly

gam csv C:\Scripts\PasswordSet\passwordset.csv gam update user ~user password ~pass changepassword ~changepassword

In either case, 

Wes C

unread,
Nov 15, 2021, 3:11:15 PM11/15/21
to GAM for Google Workspace

Whoops, hit send too soon.

In either case, the script will run 100% as expected during tests or when manually triggered but when running it as a scheduled task, passwords will not be set.  I've confirmed that the task is running with highest privileges and have tried running the scrip as different users (including local admin and SYSTEM).  

What am I missing?

Ross Scroggs

unread,
Nov 15, 2021, 5:19:32 PM11/15/21
to google-ap...@googlegroups.com
Wes,

What is your GAM version; what output do you get from the scheduled task?

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/7921d0e1-9235-4575-a122-706652a19ff3n%40googlegroups.com.

Wes C

unread,
Nov 18, 2021, 2:53:30 PM11/18/21
to GAM for Google Workspace
Hi Ross,

I'm currently on the latest version, 6.10, but was having this issue with 6.08 as well.
Task scheduler is reporting "The operation completed successfully. (0x0)"

The only output the script generates is a CSV with the of accounts that have had their passwords reset (which is then piped into the GAM command). But in this case, the passwords aren't being reset.

Ross Scroggs

unread,
Nov 18, 2021, 3:36:09 PM11/18/21
to google-ap...@googlegroups.com
Wes,

Send me s Meet/Zoom invitation.

Darrin Tams

unread,
Nov 19, 2021, 12:30:53 PM11/19/21
to GAM for Google Workspace
I do all my gam within power shell and never call cmd. For example putting your command into a .ps1 file of: for your example we'll name the file "pwdChange.ps1"

gam csv C:\Scripts\PasswordSet\passwordset.csv gam update user ~user password ~pass changepassword ~changepassword
May want to add the gam as fully qualified C:\<InstallationPathTo gam>\gam.exe csv C:\Scripts\PasswordSet\passwordset.csv gam update user ~user password ~pass changepassword ~changepassword

Then for the scheduled task:
* Create/Edit task and for the "Actions" tab
** In the Program/script: box enter 
******   C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (If that's your powershell path.)
** In the Add arguments (optional): box enter:  
******   -file "<fully qualified path to>\pwdChange.ps1"


Reply all
Reply to author
Forward
0 new messages