テスト環境にてSCOMとSCSMの連携を行っている上で、大量のインシデントがたまっており、動作が非常に遅くなってしまっている状況があったので、インシデントを「削除」しました。
大まかな流れは以下です。
- SMLetを導入
- PowerShellでOperations Managerによって作成されたインシデントのみ削除
Import-Module SMLets
$SCOMIncidents = Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$) | Where-Object {$_.Source.displayname -eq “Operations Manager”}
$SCOMIncidents | Remove-SCSMObject -Force 以下は参考にした記事や作業のログ等です。
最初にまず、SMLetsを導入します。
SCSM PowerShell Cmdlets - Home http://smlets.codeplex.com/
PS > Import-Module SMLets
上記のようにモジュールをインポートすることで、SMLetsを使用可能にできる。
下記のようにすることでインシデント一覧を取得できる。
Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$)
インシデントがどのようなプロパティとどのような値を持っているのかを確認する。
PS > $incidents = Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$)
PS > $incidents[0] | fl
TargetResolutionTime :
Escalated : False
Source : ポータル
Status : 解決済み
ResolutionDescription : close test issue.
NeedsKnowledgeArticle : False
TierQueue : S&TC
HasCreatedKnowledgeArticle : False
LastModifiedSource : コンソール
Classification : その他の問題
ResolutionCategory : アナリストによって修正されました
Priority : 8
Impact : 中 (影響範囲が一部の組織単位)
Urgency : 低 (サービスが停止していない)
ClosedDate :
ResolvedDate : 2013/03/28 4:06:57
Id : IR2
Title : Test Issue
Description : Issue Detail
ContactMethod :
CreatedDate : 2013/03/13 4:47:50
ScheduledStartDate :
ScheduledEndDate :
ActualStartDate :
ActualEndDate :
IsDowntime :
IsParent :
ScheduledDowntimeStartDate :
ScheduledDowntimeEndDate :
ActualDowntimeStartDate :
ActualDowntimeEndDate :
RequiredBy :
PlannedCost :
ActualCost :
PlannedWork :
ActualWork :
UserInput :
Source : Operations Manager
今回はSCOMから連携されて大量に作成されたレコードを削除したいので、Sourceプロパティでフィルタすることにする。
PS > $SCOMIncidents = Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$) -Filter “So urce -eq ‘Operations Manager’” Get-SCSMObject : Source_96FD9295_16FA_3D7A_5995_F805B7B01F21=‘Operations Manager’ – GUID には、ハイフンを 4 つ含む 32 桁の数字 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) を含んでいなければなりません。 発生場所 行:1 文字:18
- $SCOMIncidents = Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Inci …
- CategoryInfo : NotSpecified: (:) [Get-SCSMObject], UnknownDatabaseException
- FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.UnknownDatabaseException,SMLets.GetSMObjectCommand
こういう書き方は出来ないらしい。
PS > $incidents[100].Source ordinal name displayname ——- —- ———– 25 IncidentSourceEnum.SCOM Operations Manager
PS > $SCOMIncidents = Get-SCSMObject –Class (Get-SCSMClass –Name System.WorkItem.Incident$) | Where-Obj ect {$_.Source.displayname -eq “Operations Manager”} PS > $SCOMIncidents | ft name, Source Name Source —- —— IR41 Operations Manager IR42 Operations Manager IR43 Operations Manager IR44 Operations Manager IR45 Operations Manager
これで意図した通りの抜き出しができているようなので、削除する。
PS > $SCOMIncidents | Remove-SCSMObject -Force