Reactivate CRs and all related MAs

The following short script will set a specific CR in progress and all related MAs to active.

$smdefaultcomputer = <computer>
$crclass=Get-SCSMClass System.Workitem.ChangeRequest$
$maclass
= Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity$
$maStatusActive
=get-scsmenumeration ActivityStatusEnum.Active$
$crStatus
=get-scsmenumeration ChangeStatusEnum.InProgress$
$cr
=smlets\get-scsmobject -Class $crclass -Filter “Name -eq ‘CR83769′”
$mas
=Get-SCSMRelatedObject $CR | ? classname -eq ‘System.WorkItem.Activity.ManualActivity’
$masu=$mas | %{$i=$_.id;get-scsmobject -class $maclass -Filter “Id -eq $i}
$masu
| Set-SCSMObject -Property status -Value $maStatusActive
$cr
| Set-SCSMObject -Property status -Value $crStatus

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s