Gam with Adaxes

90 views
Skip to first unread message

Austin Dukes

unread,
Dec 6, 2022, 8:35:04 AM12/6/22
to GAM for Google Workspace
Hopefully someone uses Adaxes a can help out. I already reached out to them and I got the run around to a 3rd party. Anyway here is what i am trying to do. 

When creating a new user via Adaxes, it creates the AD account, Exchange mailbox and google account, but next I want it to move the user to the right OU based on how the account creation form was filled out. Most everything is done via powershell so I am trying to get PS to work here. 

If I open PS directly and use: gam update org "OU with spaces here" add users %userprinciplename%   (<--- variable within Adaxes), this works great. But if I run it as a powershell command within an Adaxes rule, gam is not a known cmdlet. blah blah. So I can get it to work if I use: c:\gam\gam.exe update org "OU with spaces here" add users %userPrincipalName%. This actually moves it in Google admin as it should but on the Adaxes side it give me an error saying: Stack trace: at <ScriptBlock>, <No file>: line 1

I cannot find how to stop that error and have the command work. I can get the command to not error, but then the move doesn't happen.

Kim Nilsson

unread,
Dec 18, 2022, 6:15:04 AM12/18/22
to GAM for Google Workspace
Try setting the path to the gam.exe as a variable, which you then can use in the PS.

This has nothing to do with GAM, as it is a conflict between PS and Adaxes.

Austin Dukes

unread,
Dec 18, 2022, 9:33:59 PM12/18/22
to GAM for Google Workspace
I did that but it would "fail successfully". Adaxes doesn't like it being called for whatever reason. However, here is what does work:

$gamPath = "C:\Gam\gam.exe"
$waitTimeMilliseconds = 8 * 60 * 1000

# Get user information and build arguments
$arguments = @('update org "Path of OU Here" add users "%userPrincipalName%"')

# Start GAM process
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
$processInfo.FileName = $gamPath
$processInfo.RedirectStandardOutput = $true
$processInfo.RedirectStandardError = $true
$processInfo.UseShellExecute = $false
$processInfo.Arguments = $arguments
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processInfo
$process.Start() | Out-Null
$process.WaitForExit($waitTimeMilliseconds)
$resultErrors = $process.StandardError.ReadToEnd()
$resultOutput = $process.StandardOutput.ReadToEnd()


Reply all
Reply to author
Forward
0 new messages