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 (190 points)
0

Hello,

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

1 Answer

0 votes
by (215k 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

I would like users to use Adaxes to add themselves or others to a group, but instead of it just working, it has to go thru an approval process and be approved by the group owner before they are added. Thanks!

asked Jun 30, 2021 by RayBilyk (200 points)
0 votes
1 answer

I had a script that would copy the values from adm-CustomAttributeTextMultiValue1 and save them into extensionAttribute15 as a comma seperated list. The script somehow got deleted and I can't seem to find the tutorial I used to create it before.

asked 4 days ago by jordan (110 points)
0 votes
1 answer

Hello, I need some advice. I'd like to create a specific After user creation action, but I don't know exactly how. In our environment a new user need to assign a MS365 ... 313/create-user-mailbox-in-office-365 Will it work in 2020? Thank you for your answer.

asked Dec 14, 2020 by the7thever (50 points)
0 votes
1 answer

We are evaluating the product and would like to let users of AD to change password in self service page. We would like to set a 90 days change password policy, ... self service page? Is it achievable (with customization and batch program)? Thanks in advance.

asked Apr 27, 2020 by eric (20 points)
0 votes
1 answer

Is there a way to email a notification when there are errors? Our human resources will often delay or forget to let our IT staff know that there was an error on the web interface.

asked Nov 11, 2014 by mobosys (190 points)
2,761 questions
2,495 answers
6,538 comments
1,483,214 users