I am a long-time user of gam but at some point in the distant past, the error/exit codes were removed from most of the commands. When calling an executable from a batch file, checking exit codes is a standard process. GAM did a great job handling this until some of the codes were removed. I then had to capture the output and parse it to read the reported error text.
Redirected error output to a file must be done and then parsed to find the error number
Error output included the ERROR: ### for some of the commands but recent versions have changed the error descriptions, making it a long drawn out task to interpret what went wrong inside a program calling GAM.
With every upgrade, I have to save a version of the old program and run every GAM to see
- if an exit code was removed
- if the error output changed from any one of the previous versions that was in use for a particular scheduled task
- what exit code or text is returned when a command runs successfully - These exit codes are typically 0 but if some one of the errors returns a 0 for any of the possible errors, the standard output must be checked instead.
- backend server errors can only be checked when they occur so these can only be checked when the condition exists.
Why can't GAM add back exit codes? To upgrade a single process, I must spend days to check all of the possible errors that can be returned. When the output or errorlevels are the same as the previous version, I can put it into production. When an exit code or error number is not returned on std error, I have to modify the program to search for different text or come up with a different method for trapping the error.
How can this be made a priority?
Example #1: Running a command to add an owner to a group when the user is already an owner.
The error output was collected from GAM ver 3.65 and compared with GAM ver 4.65
gam update group valid_gr...@email.domain add owner new_...@email.domain 2>error.txt
Error output from Version 3.65
adding owner new_Owner@email.domain...
ERROR: 409: Member already exists. - duplicate
Error output from Version 4.65
Group: valid_gr...@email.domain, new_Owner@email.domain Add as OWNER Failed: Duplicate, already a OWNER
C:\Gam365>echo %errorlevel%
C:\Gam365>0
Since the exit code is a 0 even when there are errors, the output must be interpreted. At least on ver 3.65 an Error # is given but on ver 4.65 there are no unique error number to look for. Programers must run the command with specific errors every time there is a new version since there are no consistencies how error text is formatted.
Example #2: Running a command to add an owner to a group when the group does not exist.
No errorlevel is set and the error # was removed and replaced with the text "Does not exist".
Error output from Version 3.65
adding owner new_Owner@email.domain...
ERROR: 404: Resource Not Found: groupKey - notFound
C:\Gam365>echo %errorlevel%
C:\Gam365>0
Error output from Version 4.65
Group: invali...@email.domain, Does not exist
C:\Gam365>echo %errorlevel%
Example #3: Running different commands with errors returns an error code and others do not.
No errorlevel is set and the error # was removed and replaced with the text "Does not exist".
Error output from Version 4.65 for 2 different commands
C:\Admin\gamStd465>gam info user invali...@email.domain
ERROR: 404: Resource Not Found: userKey - userNotFound
C:\Admin\gamStd465>echo %errorlevel%
404
Group: invali...@email.domain, Does not exist
ERROR: User invalid_userid@email.com: invalid_grant: Invalid email or User ID
C:\gam465>echo %errorlevel%
0
ERROR: 404: Invalid delegate - notFound
C:\gam465>echo %errorlevel%
0