テスト環境にて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 : <UserInputs>
<UserInput Question=”Please enter the title for the issue” Answer=”tes
t issue” Type=”string” />
<UserInput Question=”Please describe the symptoms of the issue in deta
il” Answer=”issue detail” Type=”string” />
<UserInput Question=”Please select a category of the issue” Answer=”e1
480348-20aa-942c-4896-44dba726424f” Type=”enum” />
<UserInput Question=”How urgent is the issue” Answer=”725a4cad-088c-4f
55-a845-000db8872e01″ Type=”enum” />
<UserInput Question=”Please enter alternate contact information if nee
ded” Answer=”” Type=”string” />
</UserInputs>
FirstAssignedDate : 2013/06/28 7:07:23
FirstResponseDate :
DisplayName : IR2 – Test Issue
Name : IR2
Path :
FullName : System.WorkItem.Incident:IR2
ManagementPackClassIds : {a604b942-4c7b-2fb2-28dc-61dc6f465c68}
LeastDerivedNonAbstractManagementPackClassId : a604b942-4c7b-2fb2-28dc-61dc6f465c68
TimeAdded : 2013/03/13 4:47:52
LastModifiedBy : 7431e155-3d9e-4724-895e-c03ba951a352
Values : {(null), False, IncidentSourceEnum.Portal, IncidentStatusEnum.Resolved..
.}
LastModified : 2013/06/28 16:07:24
IsNew : False
HasChanges : False
ManagementGroup : SM_JBS
ManagementGroupId : ca13caa6-05d6-9114-01e3-8a34a87354d0
GroupsAsDifferentType : False
ViewName : ManagedEntityGenericView
ObjectMode : All
ClassName : System.WorkItem.Incident
TypeName : System.WorkItem.Incident
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
Leave a Reply