GAM output formatting

20 views
Skip to first unread message

Tim Daye

unread,
Sep 21, 2026, 1:08:30 PMSep 21
to GAM for Google Workspace
Hello All:

I have this little PS script I wrote (see below).  It works great, but output is not anything that resembles aesthetically pleasing.  Is there a way to format this output to make it easier to read?

Thanks very much for your time,
-Tim

param (
    [string]$School,
    [string]$SN
)

Write-Host "School: $School"
Write-Host "SN: $SN"
gam select $School print cros query "id:$SN" fields osversion, lastEnrollmentTime, model, orgUnitPath, status, recentUsers

Paul Ogier

unread,
Sep 22, 2026, 2:50:28 AMSep 22
to GAM for Google Workspace
print always writes CSV, that's its job. Two ways round it.

If you're only ever looking at one device, swap print for info. Same query, and it prints an indented list of keys and values instead:

gam select $School info cros query "id:$SN" fields osversion,lastEnrollmentTime,model,orgUnitPath,status,recentUsers

Or keep print and let PowerShell format it:

gam select $School print cros query "id:$SN" fields osversion,lastEnrollmentTime,model,orgUnitPath,status,recentUsers | ConvertFrom-Csv | Format-List

The second one is the better bet if you ever widen the query to more than one device, since Format-List will page through them.
Reply all
Reply to author
Forward
0 new messages