Putting Unix/Linux servers in MM with Powershell

I saw a question in the TechNet forum today on how to schedule Maintenance mode for Unix/Linux servers.
After some testing this powershell script came out, put it in the task scheduler to automate it, or even better put it in the Opalis policy that is taking care of your maintenance..

$rmsServer=”RMS.fqdn
add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”;
Set-Location “OperationsManagerMonitoring::”;
$mgConnection = New-ManagementGroupConnection -connectionString:$rmsServer;

Set-Location $rmsServer;

$unixClass = get-monitoringclass -name “Microsoft.Unix.Computer”
$monObject = Get-MonitoringObject -monitoringclass:$unixClass
$mmServer = $monObject | where {$_.displayname -eq “unixserver.fqdn”}

New-MaintenanceWindow -MonitoringObject $mmServer -Comment “Enter maintenance mode reason here” -StartTime (Get-Date) -EndTime (Get-Date).AddMinutes(60)

Written on February 9, 2011