User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

 # Pre-Requisites

1. SCSM PowerShell Cmdlets library from https://smlets.codeplex.com/

2. Download and install this on the SCSM Management Server(s)

3. Execute them on the Server itself or using Remote SCSM Management Server routine at http://www.veluconsult.ca/index.php/10-system-center-service-manager/9-remote-powershell-on-scsm-management-server

# Script starts here

if ( -not (Get-Module -Name SMLets)) {Import-Module Smlets}

# The above command confirms SMlets is available for the session

# Get-SCSMObject to list various classes available with Service Manager

Get-SCSMObject  -Class (Get-SCSMClass  -Name System.WorkItem.ChangeRequest$)

Get-SCSMObject  -Class (Get-SCSMClass  -Name System.WorkItem.Incident$)

Get-SCSMObject  -Class (Get-SCSMClass  -Name System.WorkItem.Problem$)

Get-SCSMObject  -Class (Get-SCSMClass  -Name System.WorkItem.ReleaseRecord$)

Get-SCSMObject  -Class (Get-SCSMClass  -Name System.WorkItem.ServiceRequest$)

# Change Requests

Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ChangeRequest$) | ?{$_.ID  -like "*CR4618*"}

Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ChangeRequest$) | ?{$_.Title  -like "*Cancelled CR*"}

Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ChangeRequest$) | ?{$_.Title  -like "*Fill in the Title*"}

# Incidents

Get-SCSMObject -Class (Get-SCSMClass - Name System.WorkItem.Incident$) | ?{$_.ID -eq"IR12759"}

#Service Requests

Get-SCSMObject -Class (Get-SCSMClass  -Name System.WorkItem.ServiceRequest$) | ?{$_.Title -like "*234*"}

Get-SCSMObject -Class (Get-SCSMClass -NameS ystem.WorkItem.ServiceRequest) | ?{$_.ID -eq "SR21030"}

# Similiar commands can be used to extract objects on Release Record and Problems

# Remove any objects the following command has to be applied

Get-SCSMObject-Class (Get-SCSMClass-NameSystem.WorkItem.Incident$) | ?{$_.ID -eq "IR12759"}| Remove-SCSMObject -Force

# Similiar commands can be used to Removet objects from otherl classes

#Update objects with the following command

Get-SCSMObject  -Class (Get-SCSMClass -Name System.WorkItem.ChangeRequest$) | ?{$_.ID -like "*CR13610*"} | Set-SCSMObject  -Property  Status  -Value InProgress

#The above changes the Status of CR13610 from whatever to 'InProgress'. Could be used to change 'Closed' to 'In Progress'with the above command

Notes :

  • Tests should be done on non-productive environment
    • Not responsible for loss of any data with the usage of this script/function