Archive Users

284 views
Skip to first unread message

Timothy Smith

unread,
Nov 20, 2023, 12:27:59 PM11/20/23
to GAM for Google Workspace
Hi - is there an easy way to apply the Archive license to everyone in a given OU.  I'd run the command every couple weeks, just anyone in a given OU should be archived.

Aston Wooller

unread,
Nov 20, 2023, 8:14:40 PM11/20/23
to GAM for Google Workspace
You could use Powershell to determine what users should be archived.

Example:
$CSVLocation = "c:\a place to put this file\examplereport.csv
gam print users allfields | Out-File $CSVLocation -encoding ascii

$ArchiveCheck = import-csv $CSVLocation  | Where-Object {$_.orgUnitpath -eq '/Terminated Staff/Archive' -and $_.archived -eq 'FALSE'}

foreach ($user in $ArchiveCheck) {
gam update user $($user.primaryEmail) suspended on archived on
}

I have a similar script scheduled to run every morning to archive users.


Ian Bevan

unread,
Nov 21, 2023, 8:01:05 AM11/21/23
to GAM for Google Workspace

Timothy Smith

unread,
Nov 22, 2023, 4:13:16 PM11/22/23
to GAM for Google Workspace
Does this need GAM Advanced to work?

Aston Wooller

unread,
Nov 22, 2023, 5:40:05 PM11/22/23
to GAM for Google Workspace
I've only used GAMADV-XTD(3). But can find reference to both GAM commands in the standard GAM wiki.

I've also missed a close quote for $CSVLocation. 

Aston Wooller

unread,
Nov 22, 2023, 8:38:45 PM11/22/23
to GAM for Google Workspace
Assigning an Archive User licence is dependent on the user account being in an Archived state. So you can't assign it to an OU. 

OR if you could assign it to an OU and nobody could unarchive a user account while it's in that OU, you'd have a separate nightmare when operational admins might start pulling archived users out of the archive OU so that they can unarchive it. I think it's better they stay in the correct OU and you just have a watchdog script to archive the account again overnight.
Reply all
Reply to author
Forward
0 new messages