Download all Users to CSV using powershell

380 views
Skip to first unread message

John French

unread,
May 19, 2015, 2:00:54 PM5/19/15
to google-ap...@googlegroups.com
Hi, I am new to powershell and I am looking download all user to a csv file so I can upload it to my database.   I have figured out how to upload data from csv files to game but not the other way.  I must be missing something simple.  Any suggestions would be much appreciated and I thank you in advance.

This is the code I used to move accounts to a different ou

 $list = Import-Csv "\\rdat.rsssd.internal\F$\Exports\Google\Student Accounts\studentaccounts.csv"
foreach ($entry in $list)
  {
    C:\Tools\gam-RCssKIDS\gam.exe update org $($entry.neworg) add user $($entry.newuser)
  }
  Start-Sleep -s 10


I have been using this command to get the data I need  gam print users allfields >allgoogle.csv

I thought I would do something like this and I would like the file to reside in the same directory as above files    Export-Csv "\\rdat.rsssd.internal\F$\Exports\Google\Student Accounts\studentaccounts.csv"



  {
    C:\Tools\gam-RCssKIDS\gam.exe  print users allfields >allgoogle.csv
  }
  Start-Sleep -s 10

John French

unread,
May 19, 2015, 2:35:19 PM5/19/15
to google-ap...@googlegroups.com
I have also tried this  {
    C:\Tools\gam-RCSDKIDS\gam.exe print users allfields >Export-Csv "\\Qdata.rcsd.internal\F$\Exports\Google\Student Accounts\studentaccountstest.csv"
  }

Nate Ferrell

unread,
Aug 11, 2016, 11:34:48 PM8/11/16
to Google Apps Manager
Hi John,

Found this old post that doesn't seem to have ever received an answer... in case (or anyone else) is still looking, here is how I do it in Powershell (note the dot notation at the front to launch the exe correctly:

. C:\Tools\gam-RCSDKIDS\gam.exe print users | ConvertFrom-Csv | Export-Csv -NoTypeInformation "\\Qdata.rcsd.internal\F$\Exports\Google\Student Accounts\studentaccountstest.csv"


One huge risk that comes up when using the 'allfields' parameter is that property values that have blank lines in them can cause objects to split in half. If you find that you have odd results, try slimming down to just the fields that you need and building back up until you find the break point. The big one for me that did this was the Address property.


Hope this helps!
Reply all
Reply to author
Forward
0 new messages