$rootMS = "PRIRMS01"
$Folder="c:\util\wsus-groups\"
"SET MAINTENANCE MODE"
"LISTS:"
$list = get-childitem $Folder -Name
$list = $list -replace ".TXT",""
$list | format-wide {$_} -Column 3 -Force
$group = Read-Host "LIST [WSUS-Test-Group-2]"
if (!$group) { $group = "WSUS-Test-Group-2" }
$t = Read-Host " TIME[60]"
if (!$t) { $t = "60" }
$comment = Read-Host "COMMENT [Windows Updates]"
if (!$comment) { $comment = "Windows Updates" }
#####################################
#attach SCOM SnapIn
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;
#
$File = $Folder + $group + ".TXT"
$servers = get-content $File
"Setting maintenance mode for $t minutes:"
foreach ($server in $servers) {
write-host " $server" -nonewline
$strServer = Get-Agent | Where-object {$_.Name -match $server}
if (!$strServer) { write-host " - ERROR finding SCOM Agent!" -nonewline }
if ($strServer) { $strServer.HostComputer | New-MaintenanceWindow -StartTime (Get-Date) -EndTime (Get-Date).AddMinutes($t)-Comment $comment }
write-host ""
}
"COMPLETE"
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
6/17/2011
Put list of servers in SCOM maintenance mode
- have a folder which contains text files with lists of servers to define groups.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment