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.
- We check if there is a MasterAgent set for the workstation if not we abort
- We check to see what service level the workstation is subscribed to (must be greater than basic)
- 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
}