0 votes

I am attempting to run a command using powershell. The command is using Google Apps Manager (GAM). Whenever the command runs and is successful, Powershell reports that it has failed and Adaxes see this with an exclamation point in the web operation feedback.

Here is a sample of the portion of code I am concerned with:

Invoke-Expression -command:"C:\googleapps_manager\gam.exe update group employees@company.com remove user mr.testy106"

There is some output when the command is being run from the command line and powershell. I think this is what is throwing Adaxes off. But $LastExitCode = 0 and there are no other errors that can be determined.

Here is a sample of the output after running the command:

removing mr.testy106@company.com

Here is the error from the web interface:
https://docs.google.com/file/d/0B30Z5VM ... edit?pli=1

Does anyone know what I might be doing wrong or how to get Adaxes to accurately report an error?

[edit]
To explain more clearly the issue and not appear as though this post describes an issue with Adaxes. The issue lies with the software I am using and how it works with Powershell.

by (290 points)
0

Hello,

Hmm ... that looks really strange. We've asked our script guys to have a look.

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

The reason for the issue is that some output from gam.exe is being sent to STDERR, and redirection works differently in PowerShell than in CMD.EXE. For more information on this issue, you can have a look at this post on the Stackoverflow forum.

To work around this issue, you can redirect the STDERR output to a PowerShell variable, and then update the Execution Log of the operation with the content of that variable using the $Context.LogMessage method. For example:

$commandResult = Invoke-Expression -command:"C:\gam-64\gam.exe update group employees@softerra.com remove user crashtestdummy 2>&1"
$Context.LogMessage($commandResult, "Information")
0

Your suggestion is perfect. Thank you.

Here is what I ended up doing (I took things a little further):

Import-Module Adaxes
$commandResult = Invoke-Expression -command:"C:\googleapps_manager\gam.exe user mr.testy106 deprovision 2>&1"
$myResult=$commandResult | Select-String -pattern "Error"
If ($myResult){
    $Context.LogMessage($commandResult, "Error")
}
Else {
    $Context.LogMessage($commandResult, "Information")
}

Notice the sample code is different than the OP, but it is much easier to test with and view.

0

Hello,

Thanks for your contribution. We really appreciate it.

Related questions

0 votes
1 answer

We use TOPdesk as our ITSM solution. Several departments are able to create new users. When a create user task fails we would like to receive the alert as the Adaxes ... Adaxes to sent out the incident to our TOPdesk. Is there a solution for this?

asked Oct 5, 2023 by mrkvd16 (50 points)
0 votes
1 answer

For context, up until now, we had a business rule in place stopping accounts from being created for users with the same name e.g. Jacob Smith and Jacob Smith. This business ... , or how to, if possible, remove this. Any help would be most appreciated! Thanks

asked Oct 22 by Charlie.Evans (70 points)
0 votes
1 answer

How can i différenciante the two user without opening each one of them ?

asked Jan 20, 2023 by eric.lebrun (20 points)
0 votes
0 answers

Hi All, I have setup an action to cancel all meetings in outlook when a user is leaving. We use Exchange online but I'm getting an error 'The operation is supported by Exchange online and Exchange versions starting from 2019' I cant see where you specify.

asked Sep 6 by DarrenFisk (60 points)
0 votes
1 answer

Where can I get training for Adaxes? Is there an instructor-led course on online self-paced class?

asked Oct 10 by ChrisLumpkin (20 points)
3,541 questions
3,232 answers
8,225 comments
547,802 users