I haven't had the time to finish the module and functions but will get you
started. You will need the console or a way to import SCOM module, there is
a standalone way that can be done.
Import-Module 'OperationsManager'
New-SCOMManagementGroupConnection -ComputerName localhost
Function Set-MaintenanceMode
{ Param($ServerList)
#$ServerList = Get-Content .\MaintSystems.txt
$time = $ServerList[0]
$reason = $ServerList[1]
$comment = $ServerList[2]
$StartLine = 3
$Endline = $ServerList.Count - 1
$StartTime=[System.DateTime]::Now
$endTime=$StartTime.AddMinutes($time)
While($StartLine -le $Endline)
{
$server = $ServerList[$StartLine]
Write-Host "Windows Server from list: " $Server
$Inst = Get-SCOMClass -Name 'Microsoft.Windows.Computer'|
Get-SCOMClassInstance | where {$_.DisplayName -eq $Server }
Start-SCOMMaintenanceMode -Instance $Inst -EndTime $endTime -Reason
"PlannedOther" -Comment "Test Maint"
$StartLine = $StartLine + 1
}
}
Function Remove-MaintenanceMode
{ Param($ServerList)
$ServerList = Get-Content .\OutMaint.txt
foreach ($Server in $ServerList)
{
write-host "Windows Server from list: " $Server
$Instance = Get-SCOMClassInstance $Server
$MaintInst = Get-SCOMMaintenanceMode -Instance $Instance
Set-SCOMMaintenanceMode -MaintenanceModeEntry $MaintInst
-EndTime(get-date) -Comment "Maint Complete Removed from Maintenance"
}
}
Set-MaintenanceMode
On Thu, Jan 22, 2015 at 3:18 PM, elsalvoz <[email protected]> wrote:
> You can trigger a command and use PS script to set the windows computer
> object into MM. I have a script that does that. I will share it when I get
> to my desktop.
>
> Cesar
> On Jan 22, 2015 8:36 AM, "Todd Hemsell" <[email protected]> wrote:
>
>> Anyone find a way to put SCCM into maint mode while the backup runs?
>>
>>
>