私は SCOM (SystemCenterOperationsManager) を使用しており、スケジュールされたタスク用の小さなスクリプトを書きました。
すべてのアラートを収集NEW ( ResolutionState = 0 )
し、ワイルドカード ルールでフィルタリングする必要があります。
収集されたすべてのアラートの解決状態を特定の解決状態に変更します。
私の問題:
選択されたすべてのアラートのレポートを取得するには、「出力ファイル」を生成したいのですが、どこに配置すればよいですか?
これが私のコードです:
if ($LastHourAlerts)
{
foreach($Alert in $LastHourAlerts)
{
$newState = $null
switch -wildcard ($Alert.Name)
{
"Operations Manager failed to start a process" { $newState = 255 }
"Operations Manager failed to check the state of a service" { $newState = 255 }
"Operations Manager failed to run a WMI query" { $newstate =255 }
"Interface Utilization Alert" { $newState = 15 }
"Veeam VMware: Datastore Provisioning Analysis" { $newState = 17 }
"Veeam VMware Collector: VMware connection data processing errors" { $newState = 17 }
"Veeam VMware Collector: VMware connection is unavailable" { $newState = 17 }
"Veeam VMware: Virtual Machine Memory Usage Analysis" { $newState = 17 }
"Veeam VMware: Virtual Machine CPU Usage Analysis" { $newState = 17 }
"Veeam VMware: Virtual Machine Memory Ballooning and Swapping Analysis" { $newState = 17 }
"Veeam VMware: Virtual Machine Storage Latency Analysis" { $newState = 17 }
"Veeam VMware: Virtual Machine Consolidation Needed status Alarm" { $newState = 17 }
"Veeam VMware: Maintenance Mode Tracker" { $newState = 17 }
"Veeam VMware: vSphere Host Storage Commands Failed Analysis" { $newState = 17 }
"Veeam VMware: vSphere Host Network Packet Loss Analysis" { $newState = 17 }
"Veeam VMware: vSphere Host Memory Swapping Analysis" { $newState = 17 }
"Veeam VMware: vSphere Host Memory Usage Analysis" { $newState = 17 }
"Veeam VMware: vSphere Host Kernel Latency Analysis" { $newState = 17 }
"Veeam VMware: vSphere Cluster Memory Overcommit Analysis" { $newState = 17 }
"Veeam VMware: VM customization failed" { $newState = 17 }
}
if($newState -ne $null)
{
$Alert.ResolutionState = $newState
$Alert.Update(“Resolution State changed automatically by Automation”)
}
}
}
if ループの最後で次のようなことを試しました。
$Alert.Name | Out-File ("$path\" + "Report.csv") -Append
名前は取りますが、処理されたすべてのアラームの数で最初のアラーム オブジェクトの名前のみを書き込みます。例えば:
5 つの異なるアラート:
Operations Manager failed to start a process
Interface Utilization Alert
Veeam VMware: VM customization failed
Veeam VMware: Virtual Machine CPU Usage Analysis
Veeam VMware Collector: VMware connection is unavailable
そしてそれは.csvにあります:
Operations Manager failed to start a process
Operations Manager failed to start a process
Operations Manager failed to start a process
Operations Manager failed to start a process
Operations Manager failed to start a process
データ出力を取得するより良い方法はありますか? $Alert.Name
また、 but が
欲しいだけではありません$Alert.Name, $Alert.TimeRaised, $ResolutionState
。