#########################################################################################
All my work is free to use.  I ask that you don't sell it, but I'm not your mom.
No warranty is implied.  This stuff is free and doesn't break anything in my district.
I can't make guarantees on what it will do in your environment.  
#########################################################################################

The Universal Variable block in each script contains variables that are used in most of the PowerShell scripts.  This block should only need to be modified if you're changing the file names.  Otherwise the file paths, student OU path, email domain, and other universal variables are all in the UniVar.xml file.

Important note: The path is very important for all these scripts.  I'm saving the locations for each file path in a universal variable xml file in C:\PowerShell\UniVar.xml.  If you change the location of GAM, you need only change the path in the UniVar.xml file and it will update in all the PowerShell scripts.

Use ISE.  You can edit PowerShell scripts with Notepad or a good editor like Notepad ++, however ISE makes everything so much easier.  If you don't have a shortcut for ISE, simply open PowerShell and type "ise".  If you're in Windows 10, you can search for "ise" from Cortana and pin the shortcut to your start menu.

To test any of these PowerShell scripts without actually having it make changes to your environment, use the "Write-Output" command.  You just have to take the command that's actually doing something, surround it by quotes, and put "Write-Output " (note the space) in front of it.  Rather than actually running the command, it will write what it *should* be doing on the screen.  That way you can test to be sure the correct thing is being submitted.  It helps to be sure you're pulling the right data from the database (in my case, Active Directory).

Write-Output "& $gamPath update org $googleou add users $email"

Will display on the screen:

C:\GAMADV\gam.exe update org /Students/2020 add users test@tricountyschools.com

#########################################################################################

My scripts all contain a lot of commenting.  Don't ignore the comments, they're useful.  Just look for the green letters that come after the # mark.

Likewise, all my scripts contain a ridiculous amount of logging.  I'm not going to note below which files have logging, because they all do.  Some more than others, but they're all logged.  When you run these scripts on a timer in the middle of the night, it's nice to figure out what happened and when.  There's a cleanup script to keep these from growing out of control.  I recommend using it on a timed interval of your choosing.

#########################################################################################

#\UniVar.xml
This file contains many variables used throughout all my scripts.  Basically if the variable existed in multiple scripts, I put it in here.  The first thing you should edit is this file.  Make sure all the paths are correct and all your information is updated in this file since what's in here will be used in all my scripts.  This file must reside in C:\PowerShell\UniVar\ folder, otherwise you'll have to change the location in all of my scripts.

Note - you'll still have to change variables in some scripts.  Not every variable exists in the Universal Variable XML file.  Only those variables that exist in multiple files were placed in this central repository.  Check each script and read the comments to make sure you've updated everything that is necessary to update.

#####
#\ArchiveLogs.ps1
This script deletes everything in the \Logs\Archive folder, then moves everything from the \Logs folder into the \Logs\Archive folder.  I run this weekly so that my log files don't get too big.  Your mileage may vary, when you're starting out you might only run it monthly.

#\Synergy_Export_Check.ps1
This script simply checks the folder for the file that's supposed to come from Synergy.  If it's there, it does nothing.  If the file is missing, it sends me an email.

#####
#\ActiveDirectory\IMPORT_to_AD.ps1
Simply does what it says.  This script takes the output from the format script and imports the data into Active Directory.  Missing students are added, removed students are disabled.  Once complete, this script also removes all the txt files created by WinSCP and the Format Script to keep student data from living in a plain text file on the server.

#\ActiveDirectory\MOVE_Inactive_Students.ps1
I run this once a week.  It moves any students who are disabled into an "Exited" OU in Active Directory.

#\ActiveDirectory\EMAIL_Welcome_New_Students.ps1
This script gets run last in the order.  After the email accounts have all been created, this script sends each one of them a welcome email telling them how to go about changing their password.

#\ActiveDirectory\FORMAT_for_AD.ps1
This script does the heavy lifting for the whole system.  Bad data here will ruin everything.  I only ask for 5 things from Synergy: first name, last name, grade level, student ID, and teacher (for pre-K - 5th grade students).  This script manipulates that data, adds to it, and generates enough information to perform all the tasks of the system.

#####
#\GAM\GAM_ClassGroups.ps1
Adds NEW students into their respective class groups (ie 2019@tricountyschools.com).

#\GAM\GAM_MoveStudents.ps1
Moves NEW students into their respective class OUs in Google.

#\GAM\GAM_MoveStudents_Weekly.ps1
Moves ALL students into their respective class OUs in Google.  I run this one weekly in case there's a mistake when they're originally entered and they need to be moved.

#\GAM\GAM_PrintGroups.ps1
Adds NEW students into their respective print groups (for Google Cloud Print).  I'm currently in the process of moving over to "Mobility Printing" from Papercut, which will make this obsolete soon.

#\GAM\GAM_SetPasswords.ps1
Sets the initial password for NEW students in Google.  GCDS doesn't sync passwords well, so I do it with GAM.

#####
#\WinSCP\StartWinSCP.ps1
Calls WinSCP and tells it to use the settings in the txt file.

#\WinSCP\ftpwinscp.txt
All the settings for WinSCP go in here.

#####

If you've actually read down this far, kudos to you and good luck using what I've done in your environment.