Bulk Changing the Change Password setting to No

4,307 views
Skip to first unread message

David Burkhart

unread,
Aug 30, 2012, 6:25:00 PM8/30/12
to google-ap...@googlegroups.com
I recently implemented the Google Apps Password Sync. Unfortunately, I failed to remove the Change Password at First Logon check from the Google Apps Directory Sync before it created thousands of accounts. Before most of them get the chance to logon, I'd like to use the GAM to change this option.
 
I found the needed command (gam update user [username] changepassword no) but have been unsuccessful in using a PowerShell script with a csv file to run. I have a csv with all the users and was using the following in the script.
$list = Import-Csv AllStudents.csv
foreach ($entry in $list)
   {     .\gam.exe update user $($entry.mail) changepassword no
   }
When I run this, I get
gam.exe : Traceback (most recent call last):
At C:\AllStudents-ChangePasswordNo.ps1:3 char:19
+    {     .\gam.exe <<<<  update user $($entry.mail) changepassword no
    + CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [
   ], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
  File "gam.py", line 6351, in <module>
  File "gam.py", line 2613, in doUpdateUser
  File "gdata\apps\multidomain\service.pyo", line 96, in UpdateUser
  File "gdata\apps\service.pyo", line 537, in _PutProperties
  File "gdata\apps\service.pyo", line 498, in _PropertyEntry2Dict
TypeError: 'NoneType' object is not iterable
 
Does the last line mean that I am unable to use this GAM command with a csv in a script, or else why is this failing. Thanks for any help for this non-programmer.

Jay Lee

unread,
Aug 31, 2012, 7:24:16 AM8/31/12
to google-ap...@googlegroups.com
the command should be:

gam update user <email> changepassword off

verify that the command is working against 1 user before attempting it in bulk.

Regards,

Jay Lee
LCS Deployment Lead   |  ⚡ Dito



--
You received this message because you are subscribed to the "Google Apps Manager" group.
To post to this group, send email to
google-ap...@googlegroups.com
To unsubscribe from this group, send email to
google-apps-man...@googlegroups.com
For more options, visit this group at
https://groups.google.com/forum/#!forum/google-apps-manager

David Burkhart

unread,
Aug 31, 2012, 10:13:50 AM8/31/12
to google-ap...@googlegroups.com
I see what you mean - changing "no" to "off". I updated the script and it appears to be running; not getting the errors, anyway. I'll post again when the script finishes. Thanks for catching that!

David Burkhart

unread,
Aug 31, 2012, 1:33:00 PM8/31/12
to google-ap...@googlegroups.com
This script has been running for over three hours now. The only change to the blue PowerShell screen came more than an hour into its running. There are roughly 13,000 students in the csv file. How can I tell if this is really doing something? I wish it would give some sort of output along the way.
 
PS C:\> .\AllStudents-ChangePasswordNo.ps1
Google Apps Manager 2.51
jay@ (Jay Lee)
Python 2.7.3 final
Windows-2008Server-6.0.6001-SP1 x86
Usage: gam [OPTIONS]...
Google Apps Manager. Retrieve or set Google Apps domain,
user, group and alias settings. Exhaustive list of commands
can be found at: http://code.google.com/p/google-apps-manager/wiki
Examples:
gam info domain
gam create user jsmith firstname John lastname Smith password secretpass
gam update user jsmith suspended on
gam.exe update group announcements add member jsmith
...
 
 

David Burkhart

unread,
Aug 31, 2012, 2:28:17 PM8/31/12
to google-ap...@googlegroups.com
OK - the script FINALLY finished. Random sampling indicates it completed successfully. Thank you.

Seb Harrington

unread,
Oct 14, 2012, 7:53:04 AM10/14/12
to google-ap...@googlegroups.com
Is there no way to do this in bulk for every user i.e.

update all users changepassword off

Thanks,

S

Jay Lee

unread,
Oct 14, 2012, 6:51:52 PM10/14/12
to google-ap...@googlegroups.com
You'd need to pull down the list of all users with:

gam print users:

and then run the command for each user. If you're one Linux, you could run a one liner like:

for user in `python gam.py print users`; do python gam.py update user $user changepassword off; done

5 points to the 1st person who responds to this thread with a 1-line Windows Powershell equivalent! 

Regards,

Jay Lee
Large Customer Deployment Lead   |  ⚡ Dito



Michael Harris

unread,
Oct 15, 2012, 10:27:03 AM10/15/12
to google-ap...@googlegroups.com
This is the TWO line power shell version starting from the bulk operations section of the GAM website. I have changed the way the list was assigned to the variable. The previous import-csv command was causing issues because it assigned column headers and "------------------------" to the $list variable.
Of course you will first need to create a text file with all your users with one user on each line of the file as noted previously.
these commands can simply be executed from a PS command windows subsequently without needing to create and sign a .PS1 script.

$list = get-content Accounts.txt
foreach ($user in $list) { .\gam update user $user changepassword off }

I also have a much more complex windows batch file version.
It runs with the text file name as a paramater. i.e. if you save it as pwdoff.BAT then run it as pwdoff.bat accounts.txt
Please also note that this must be executed in a command window with delayed environment variable enabled (for more info look here).
/V:ON Enable delayed environment variable expansion using c as the delimiter. For example, /V:ON would allow !var! to expand the variable var at execution time. The var syntax expands variables at input time, which is quite a different thing when inside of a FOR loop.


::Password reset off command using GAM tool
::Created by Michael Harris = michael (AT) sterlingclouds.com
if "%1"=="" GOTO FAIL
Echo Parsing users found in %1 file.
for /F "eol=; tokens=1-3 delims=," %%i in (%1) do (
     set userName=%%i
     set gambatch1="gam update user !userName! changepassword off"
     echo !gambatch1:~1,-1! >GAMBATCH.CMD
     call GAMBATCH.CMD
     )
del GAMBATCH.CMD

:FAIL
Echo FAILURE Check: Did you include the user account text file on the command line? 

:END


Tim Jing

unread,
Jul 29, 2013, 3:17:04 PM7/29/13
to google-ap...@googlegroups.com, mha...@luxuryresorts.com
Hey Michael

Have you tried this on the new 2.99? I cant get past the authentication part. I do get a browser opening with a prompt to accept which says success.  Then I end up at this in power shell.




Your browser has been opened to visit:


If your browser is on a different machine then exit and re-run this
after creating a file called nobrowser.txt in the same path as GAM.
Authentication successful.
Google Apps Domain: 5437979346.com
Temp error backendError. Backing off 16 seconds...attempt 5/10


RooDavis

unread,
Aug 20, 2017, 1:07:12 PM8/20/17
to GAM for G Suite, j...@ditoweb.com
Since this is an old thread, I would like to verify that this is still the preferred method to change a setting in bulk using GAM 4.3, Mac OS. Several new users were created with the "Must Change Password" check box on. So their "Must Change Password" setting is true. I would like to run a GAM command to change that to false for all domain users. Do I still need to print all users?  I noticed it is no longer name gam.py. Do I still need to call GAM with python?

Thanks and have a great day.

Rick

For more options, visit this group at
https://groups.google.com/forum/#!forum/google-apps-manager

Ross Scroggs

unread,
Aug 20, 2017, 1:19:40 PM8/20/17
to google-ap...@googlegroups.com
Rick,

This should do it: gam all users update user changepassword false

Ross
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/ec77e1ab-02b9-4aa2-91ff-b71e699b4cfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Davis

unread,
Aug 20, 2017, 1:29:04 PM8/20/17
to google-ap...@googlegroups.com
Yes, Thank you very much!!

Rick Davis

You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/D8-R67Ah3zQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
Reply all
Reply to author
Forward
0 new messages