###############################################################################################################
# SCOM-INST.PS1
# Install SCOM Agent on a list of machines.
#
$rootMS = "RMS01"
$list = "c:\server-list.txt"
clear-host
$Servers = Get-Content $list
#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;
#
#install SCOM client
$DiscoverCnfg = New-WindowsDiscoveryConfiguration -computername:$servers -performverification:$true
-computertype:"server"
$ms = Get-rootManagementServer
$DiscoverResults = Start-Discovery -managementserver $ms -windowsdiscoveryconfiguration:$DiscoverCnfg
$DiscoverResults.CustomMonitoringObjects
if ($DiscoverResults.CustomMonitoringObjects) {
install-agent -ManagementServer $ms -AgentManagedComputer: $DiscoverResults.custommonitoringobjects
}
else {
write-host "ERROR: Machine(s) not found"
}
#
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Showing posts with label scom. Show all posts
Showing posts with label scom. Show all posts
10/03/2011
6/22/2011
This script installs the Operations Management Server PowerShell SnapIn onto a given computer
Install SCOM SnapIn: "This script installs the Operations Management Server PowerShell SnapIn onto a given computer"
#=============================================================================#
# #
# Install-SCOMSnapIn.ps1 #
# Powershell Script to install Operations Management Server SnapIn #
# Author: Jeremy Engel #
# Date: 04.13.2011 #
# Version: 1.1.0 #
# #
#=============================================================================#
Param([Parameter(Mandatory = $true)]$Computer,
[Parameter(Mandatory = $true)]$ManagementServer
)
$fileRepository = "\\$ManagementServer\c$\Program Files\System Center Operations Manager 2007"
$rootPath = "C:\Program Files\System Center Operations Manager 2007\SnapIn"
$files = @("Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll",
"Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll-help.xml",
"Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Format.ps1xml",
"Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Types.ps1xml"
)
$sdkfiles = @("Microsoft.EnterpriseManagement.OperationsManager.Common.dll",
"Microsoft.EnterpriseManagement.OperationsManager.dll"
)
function Main {
$remotePath = $rootPath.Replace("C:","\\$Computer\c$")
if(!(Test-Path $remotePath)) { $null = New-Item $remotePath -Type Directory }
foreach($file in $files) {
if(!(Test-Path "$remotePath\$file")) {
Copy-Item -Path "$fileRepository\$file" -Destination $remotePath
}
}
foreach($file in $sdkfiles) {
if(!(Test-Path "$remotePath\$file")) {
Copy-Item -Path "$fileRepository\SDK Binaries\$file" -Destination $remotePath
}
}
$hklm = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Computer)
$scom = $hklm.CreateSubKey("SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.EnterpriseManagement.OperationsManager.Client")
$scom.SetValue("ApplicationBase",$rootPath,"String")
$scom.SetValue("AssemblyName","Microsoft.EnterpriseManagement.OperationsManager.ClientShell, Version=6.0.4900.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","String")
$scom.SetValue("ModuleName","$rootPath\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll","String")
$scom.SetValue("PowerShellVersion","1.0","String")
$scom.SetValue("Vendor","Microsoft Corporation","String")
$scom.SetValue("Version","6.0.4900.0","String")
$scom.SetValue("Description","Microsoft Operations Manager Shell Snapin","String")
$scom.SetValue("Types","$rootPath\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Types.ps1xml","String")
$scom.SetValue("Formats","$rootPath\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Format.ps1xml","String")
}
Main
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.
$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")
Subscribe to:
Posts (Atom)