CSV import no longer working with Powershell

308 views
Skip to first unread message

rohern

unread,
Jun 7, 2012, 2:55:55 PM6/7/12
to google-ap...@googlegroups.com
Oddly, my CSV list imports using powershell are no longer working. I'm no guru, but my .ps1 script is very simple. See below for a very basic example. However, I am seeing the same thing with any .ps1 csv import I try.

Basically, my list is importing, but I get an error suggesting my GAM commands are wrong. If I substitute the $($entry.xxxx) with the actual gam command and usernames, it works fine. As soon as I switch back to pulling from a .csv $list, it fails again.

Script:
$list = Import-Csv users.csv
foreach ($entry in $list)
{
.\gam.exe info user $($entry.username)
}

Spreadsheet layout:

username,
rohern,

When I try to run the above ps1 script I get GAM message:
Google Apps Manager 2.5
Python 2.7.3 final
Windows-7-6.1.7600 AMD64

Usage: gam [OPTIONS]...

Google Apps Manager. Retrieve or set Google Apps domain,
user, group and alias settings. Exhaustive list of commands

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

Sandip Shah

unread,
Jun 7, 2012, 3:01:03 PM6/7/12
to google-ap...@googlegroups.com
I don't use PS, but do something like this:

foreach ($entry in $list)
{
$str1 = $($entry in $list)
print $str1 (or echo or whatever PS uses)
.\gam.exe info user $str1
}

See exactly what command is being run to nail it down further.

SS

--
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

rohern

unread,
Jun 7, 2012, 3:04:40 PM6/7/12
to google-ap...@googlegroups.com
Im not sure the addition of the str variable is necessary. I'm following the exact examples from the GAM Bulk operations page.

rus

To unsubscribe from this group, send email to

Sandip Shah

unread,
Jun 7, 2012, 3:09:23 PM6/7/12
to google-ap...@googlegroups.com
The only thing that will do is print what is being passed to the script (GAM).

You can then run the same thing from the command line and figure out what needs to be changed in the ps script to fix it.

Once you have the correct syntax for the version of GAM that you are using, feel free to remove the added variable.

SS


To unsubscribe from this group, send email to

rohern

unread,
Jun 7, 2012, 3:10:20 PM6/7/12
to google-ap...@googlegroups.com

ohhh, thanks Great idea

rus
Reply all
Reply to author
Forward
0 new messages