Powershell Program for basic functionality and looking to grow

1,573 views
Skip to first unread message

Matt Dillinger

unread,
Mar 13, 2014, 3:36:42 PM3/13/14
to google-ap...@googlegroups.com
I just started using GAM and I have to say that I love it!!! The problem is that the other person that helps me manage my Google Apps Domain still bumps and jumps around the Google console. I would like to get her working through GAM as well. So what I did was take the basic functionality of GAM and put it into a powershell script. I would like to get some of the advanced functionality that GAM offers built into the script and didn't know if anyone would like to help build it or even use this for their domain. I have posted the .ps1 file for your revisions. Let me know what you think!

Cheers! 
googleappsmanager.ps1

Bryan Wilkerson

unread,
Mar 13, 2014, 5:28:42 PM3/13/14
to google-ap...@googlegroups.com
Interesting thanks for sharing.  I did a quick look and noticed a couple things.

Looks like after each of your functions you are calling your infomnu function that cls the screen.  So when I did a user lookup it presented my data but when it finished it cleared the screen (may want to change that ;) ) . 

Also when I run it the "pause" in the code error out for me as its not a cmdlet. 

Last I found 2 typo's (you can probably find more then that in my reply :D )
#Start off the program should be Start of the program
and
Write-Host "[6] Undelete a User)  - Looks like you have a trailing ) 

Great start ..Wrapper for a Wrapper ;)


On Thu, Mar 13, 2014 at 3:36 PM, Matt Dillinger <mdill...@dekalbcentral.net> wrote:
I just started using GAM and I have to say that I love it!!! The problem is that the other person that helps me manage my Google Apps Domain still bumps and jumps around the Google console. I would like to get her working through GAM as well. So what I did was take the basic functionality of GAM and put it into a powershell script. I would like to get some of the advanced functionality that GAM offers built into the script and didn't know if anyone would like to help build it or even use this for their domain. I have posted the .ps1 file for your revisions. Let me know what you think!

Cheers! 

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/28fdcded-f78d-483f-8a29-e8bc3fb7dfcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt Dillinger

unread,
Mar 14, 2014, 10:36:29 AM3/14/14
to google-ap...@googlegroups.com
That's very interesting about the pauses. I would say that the reason it is clearing the data after you look-up a user is because it is not reading that pause. It should do a data read out then pause so you can read it. I am running Powershell 4.0 and it is reading the pauses just like it would in .bat programming. 

Here is the command to find out what version you are running $PSVersionTable.psversion

I did some research and it looks like in powershell 2.0 (which is what I believe 7 shipped with.) Pauses were something that Powershell was incapable of doing the pause command. They must have added it when enough people complained.
I found this wonderful article on Stackoverflow.com


And in V2 added a the pause function found in one of the replys

<5> ReadKey composite

This is a composite of <1> above with the ISE workaround/kludge extracted from the proposal on Adam's Tech Blog (courtesy of Nick from earlier comments on this page). I made two slight improvements to the latter: added Test-Path to avoid an error if you use Set-StrictMode (you do, don't you?!) and the final Write-Host to add a newline after your keystroke to put the prompt in the right place.

Function Pause ($Message = "Press any key to continue . . . ") {
    if ((Test-Path variable:psISE) -and $psISE) {
        $Shell = New-Object -ComObject "WScript.Shell"
        $Button = $Shell.Popup("Click OK to continue.", 0, "Script Paused", 0)
    }
    else {     
        Write-Host -NoNewline $Message
        [void][System.Console]::ReadKey($true)
        Write-Host
    }
}
  • Advantage: Accepts any key but properly excludes Shift, Alt, Ctrl modifier keys.
  • Advantage: Works in PS-ISE (though only with Enter or mouse click)
  • Disadvantage: Not a one-liner!
I have attached the new V2 program to this reply. Thanks for your input! Let me know if you have any other suggestions/requests. 

Cheers!

googleappsmanagerp_v2.ps1

PatrickR

unread,
Mar 13, 2015, 4:08:20 PM3/13/15
to google-ap...@googlegroups.com
I cam up with several GAM functions for my AD User Management script in powershell. After finding this post I thought i'd peel them off to a new script and set it up to generalize the functionality for any AD environment.

It starts off by prompting for:
  1. Primary Google Apps accounts OU in AD
  2. Location of the GAM exe file
  3. The primary Google Apps domain
It then builds a list of your GAPPS Orgs to use in other functions.

The menu allows for the following functions:
1. Add Delegate
2. Remove Delegate
3. Audit User
4. Move User Accounts to org
5. Reset Google Apps Password

G - Show Google Apps Group Members

A - Export Delegate Access List
E - Export Delegate Pairings List

R - Refresh delegate pairings (Warning: this takes at least 10 minutes to complete. Updates $Global:GAM_RawDelegateList)
D - Get Delegates (current from GAM)
S - Show Delegates (cached in $Global:GAM_RawDelegateList)
T - Remove Terminated Delegates

U - Update Google Apps orgs list

Q - Quit


Check it out and let me know what you think.
GAM-UTILITY.ps1

PatrickR

unread,
Mar 25, 2015, 4:56:31 PM3/25/15
to google-ap...@googlegroups.com
I found a major error my original script so I have posted an updated one here:

Same menu and functions.

The problem was the use of the variable named "$Args". Since I don't use command line arguments all that much, I forgot that PowerShell reserves the $Args variable....



On Thursday, March 13, 2014 at 2:36:42 PM UTC-5, Matt Dillinger wrote:
GAM-UTILITY.ps1

Shruthi Kaushik

unread,
Mar 8, 2018, 9:28:59 AM3/8/18
to GAM for G Suite
I am getting "gam : The term 'gam' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of 
the name, or if a path was included, verify that the path is correct and try again."

Is it mandatory to create project? Will this involve any cost?

Ross Scroggs

unread,
Mar 8, 2018, 10:30:11 AM3/8/18
to google-ap...@googlegroups.com
Shruthi,

You need to put your GAM directory on your system path.
Open Control Panel
Click System
Click Advanced system settings
Click Advanced
Click Environment Variables...
Under System variables, school down and click Path and the Edit...
Click New
Add a line with C:\GAM or whatever your path to Gam is
Click OK OK OK

Ross


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/75e14a1c-e129-459e-b75e-e396bc6b0a81%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Shruthi Kaushik

unread,
Mar 8, 2018, 10:38:08 AM3/8/18
to GAM for G Suite
Thanks Ross. I will perform the below steps.
To post to this group, send email to google-ap...@googlegroups.com.



--
Reply all
Reply to author
Forward
0 new messages