Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### CHECK OPERATIONS MANAGER MODULE ####
- $OM_Module = Get-Module -ListAvailable | Where-Object {$_.Name -eq "OperationsManager"}
- #### CREDENTIALS FOR AUTHENTICATION ####
- $Account = Get-AutomationPSCredential -Name 'SCOM Automation Account'
- $userName = $Account.UserName
- $securePassword = $Account.Password
- $credential = New-Object System.Management.Automation.PSCredential $userName, $securePassword
- #### IMPORTING OPERATIONS MANAGER MODULE ####
- if ($OM_Module)
- {
- Import-Module OperationsManager
- }
- else
- {
- $Session = New-PSSession -ComputerName XXXXXXXXXXXX -Credential $credential
- Import-Module -Name OperationsManager -PSSession $Session
- }
- #$Session = New-PSSession -ComputerName XXXXXXXXXXXX -Credential $credential
- #$ttt = New-SCManagementGroupConnection -ComputerName XXXXXXXX -Credential $credential
- #### UPDATE COMMVAULT ALERTS ####
- try
- {
- #[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")Microsoft.EnterpriseManagement.Monitoring.MonitoringAlert
- $Alerts = Get-SCOMAlert -Name "CommVault Alert*" | Where-Object {$_.ResolutionState -eq 0}
- Write-Output "Found the following alerts:"
- Write-Output $Alerts | select name,TimeAdded,Description,severity | fl
- $gm = $Alerts | get-member
- write-output $gm
- foreach ($Alert in $Alerts)
- {
- $TMP = New-Object Microsoft.EnterpriseManagement.Monitoring.MonitoringAlert $Alert
- Write-Output $TMP1.GetType()
- Write-Output "Closing alert: $TMP"
- Resolve-SCOMAlert -Alert $TMP -ResolutionState 255 -Comment "Closed by Azure Automation"
- }
- Write-Output "Runbook has been finished."
- Remove-Module OperationsManager
- Remove-PSSession $Session
- }
- catch
- {
- Write-Error -Message $_.Exception
- throw $_.Exception
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement