Quantcast
Channel: Operations Manager - General forum
Viewing all articles
Browse latest Browse all 11941

Powershell: SCOM and maintenance mode duration / ...timezone?

$
0
0

I've got a bit of PS code that will take a computer name, and put that computer into maintenance mode. The server is going into MM, but the duration is off (sometimes by a lot) and, when I use a separate bit of code to check the scheduled start date/time, the returned info doesn't match either my, or the SCOM server's timezone (we're both in Mountain).

Here is the bit for putting the server in MM:

$computer = 'server1'
$minutes = '10'

New-SCOMManagementGroupConnection mgmtServer1

$objectClass = Get-SCOMClass -Name Microsoft.Windows.Computer
$object = Get-SCOMClassInstance -Class $objectClass | Where {$_.DisplayName -match $computer}

Start-SCOMMaintenanceMode $object -EndTime ([DateTime]::Now).AddSeconds(10).AddMinutes($Minutes)


Last time I ran this code, the server was placed in MM for 21 minutes.

The following code was used to check the start time of MM

$computer = 'server1'

$object = Get-SCOMClassInstance -Class $objectClass | Where {$_.DisplayName -match $computer}

$mmEntry = Get-SCOMMaintenanceMode -Instance $object

Write-Host ("the server, {0} started MM at {1}, and will exit at {2}" -f $computerName, $mmEntry.StartTime, $mmEntry.ScheduledEndTime)

The start time was listed as being six hours in the future (though both PS and the console showed the server was currently in MM), and the end time was 21 minutes after that.

What gives?

Thanks.



Viewing all articles
Browse latest Browse all 11941

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>