Hi, I'm trying to find a basic powershell script/comandlet for automatically setting main mode on servers which are being shutdown/rebooted as part of a patching schdule. I've seen quite a few maint mode scheduling tools but they aren't what I need
here. Our Server patching team use a 3rd party product (Shavlik) which essentially runs its own powershell script that calls a psshutdown exe which actually does the reboot of the server. What I was hoping was to be able to edit the existing powershell
to set the Main mode on the server (the servers/schedules etc are read in as params from basically text files) just prior to the call within the script that executes the psshutdown command.
What I was thinking was to embed within the existing powershell the snapin for OpsManager commandlets and then set the new maintenance window ie:
$starttime = [System.DateTime]::Now
$endtime = $starttime.AddHours(0.5)
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
New-MaintenanceWindow -starttime $starttime -endtime $endtime -reason PlannedOther -reason "Patches applied"
Is this all I would need to set Main mode within the existing Powershell script or is there more to it? I'm not all that familiar with powershell but need to start somewhere I suppose!!
Cheers...