Onboarding Script

So I’ve been working on an onboarding script for workstations. Since we do not have a way to set global variables I decided I would write some scripts that reference MachineProperties using the new API. Here is my goal and hopefully everyone will give me some feedback on if this is a good idea. Not sure how well this will scale but I guess we will find out. :slight_smile:

So here is how I envision this script being used.

  1. Every device should be onboarded, so if you run a report (not sure if we can do this based on machineproperties or not yet) you can see the devices that have not had this script ran agsinst it.
  2. You would use this to set different variables to the machine and then scripts would pull them via the API to know what to do and determine if they should even run against this machine or not.
  3. You would have a “MASTER DEVICE/AGENT” that the machine would reference so that if you had any “global” variables the scripts would use those to run.

Note: Can be ran across multiple devices at once.

Future additions
Have Master Device / Agent script

This is in PRE Alpha so don’t beat me up too bad! :slight_smile:

On-Boarding Script - v0.1a

# Onboarding Script used to set some variables on the device that are used
# for scripting & automation
#
# v0.1a

# Check if this device has already been onboarded
# Yes = Prompt for overwrite
# No = Continue
$OnboardStatus = 'ServerUtilsGetMachineProperty(@ThisMachine(),OnboardStatus)'

# Display form
ServerUtilsAskTech(New Device OnBoarding Form,title)
$ServiceLevel = "ServerUtilsAskTech(Service Level,choice,None,None,-,TotalCARE Esentials,TotalCARE Business,TotalCARE Enterprise)"
$WorkingDir = "ServerUtilsAskTech(Working Directory,text,%SYSTEMDRIVE%\NetVISION,required)"
$MasterAgent = "ServerUtilsAskTech(Master Agent,text,-,required)"
$OnboardStatusOverride = "ServerUtilsAskTech(Override Onboarding Check?,choice,False,-,True,False)"

if ($OnboardStatus -eq 1 -AND $OnboardStatusOverride -eq 'False'){
	write-host("System has already been onboarded, Aborting...")
	write-host("If you need to override the settings, please re-run the script with Override Onboarding Check set to True")
	exit 0
} Else {
	# Check for override if system is already onboarded
	if ($OnboardStatus -eq '1' -AND $OnboardStatusOverride -eq 'False') {write-host("2|System has already been onboarded, re-run with override option set to True"); exit 0}

	# This system is now considered onboarded
	write-host("Onboarding device, please wait...")
	ServerUtilsSetMachineProperty(@ThisMachine(),OnboardStatus,1)

	# Set the service level agreement for this system
	#If ($ServiceLevel -ne "None") {ServerUtilsSetMachineProperty(@ThisMachine(),ServiceLevel,"$ServiceLevel")}
	If ($ServiceLevel -eq "TotalCARE Esentials") {ServerUtilsSetMachineProperty(@ThisMachine(),ServiceLevel,1)}
	If ($ServiceLevel -eq "TotalCARE Business") {ServerUtilsSetMachineProperty(@ThisMachine(),ServiceLevel,2)}
	If ($ServiceLevel -eq "TotalCARE Enterprise") {ServerUtilsSetMachineProperty(@ThisMachine(),ServiceLevel,3)}

	# Set the working directory for scripts
	If ($WorkingDir) {ServerUtilsSetMachineProperty(@ThisMachine(),WorkingDir,"$WorkingDir")}

	# Done!
	exit 0
}

image
Service Level - Used to set a numerical value to use for scripts to determine if they should be ran on this device
Working Directory - Used to set the default working directory for scripts
Master Agent - Will be used to pull Global Variables from when running scripts
Override Onboarding Check - Used to re-run onboarding script to update variables

After Script runs you will see them variables set on each device

More to come soon, Feedback is always welcome!

1 Like

Here’s a copy of my Managed Reboot script. So I have scheduled this across all machines. I’m using the the API to pull the machineProperties to see if the machine has a MasterAgent and then we check to see if the machine is subscribed to a high enough service level. If everything checks out we call the script and off it goes.

  1. We check if there is a MasterAgent set for the workstation if not we abort
  2. We check to see what service level the workstation is subscribed to (must be greater than basic)
  3. We then call the script (Standard Reboot)
# Get Master Agent machine
$MasterAgent = "ServerUtilsGetMachineProperty(@ThisMachine(),MasterAgent)"

# Abort if there is no MasterAgent set
If ($MasterAgent -eq 'null' -or $MasterAgent -eq '') {Write-Host("1|No Master Agent, aborting"); exit 0}

# Get ServiceLevel for this machine
$ManagedStatus = "ServerUtilsGetMachineProperty(@ThisMachine(),ServiceLevel)"

If ($ManagedStatus -ge 2){
	write-host("Calling Script... Standard Reboot")
	ServerUtilsRunTool(@ThisMachine(),@TechsByLogin(AgentID),@Tool(Standard Reboot))
	exit 0
} else {
	write-host("2|System is not subcribed to service... Please contact sales")
	exit 0
}

Here’s a copy of my Windows Update script. So I have scheduled this across all machines. I’m using the the API to pull the machineProperties to see if the machine has a MasterAgent and then we check to see if the machine is subscribed to a high enough service level. If everything checks out we call the script and off it goes.

  1. We check if there is a MasterAgent set for the workstation if not we abort
  2. We check to see what service level the workstation is subscribed to (must be greater than basic)
  3. We then call the script (Windows Updates, No Reboot)
# Get Master Agent machine
$MasterAgent = "ServerUtilsGetMachineProperty(@ThisMachine(),MasterAgent)"

# Abort if there is no MasterAgent set
If ($MasterAgent -eq 'null' -or $MasterAgent -eq '') {Write-Host("1|No Master Agent, aborting"); exit 0}

# Get ServiceLevel for this machine
$ManagedStatus = "ServerUtilsGetMachineProperty(@ThisMachine(),ServiceLevel)"

If ($ManagedStatus -ge 2){
	write-host("Calling Script... Windows Updates, No Reboot")
	ServerUtilsRunTool(@ThisMachine(),@TechsByLogin(AgentID),@Tool(Windows Updates, No Reboot))
	exit 0
} else {
	write-host("2|System is not subcribed to service... Please contact sales")
	exit 0
}
1 Like

Hi Ted, we are looking at implementing some scripts that use machine properties also, so I appreciate you helping make my brain gears move with ideas. I understand what you are doing, and it’s not a big deal to me, but I’m curious what “MasterAgent” is, and what you guys are using it for. Not sure if that’s a person/machine/contact. Again I realize it’s specialized towards your business, but just curious.