Useful cmdlets for System Center 2012 Service Manager using SMlets

The following code snippets were used to modify data in the SCSM environment I was working in. Using the SCSM PowerShell Cmdlets (, I was able to achieve it a lot easier than using the built-in PowerShell cmdlets for SCSM.

As always, make sure you check the product documentation, check with Microsoft support and test in a lab environment prior to implementing anything in a production environment.

Reopening Tickets

This snippet can be used to re-open a Service Request if it were closed accidentally or automatically. Simply change the $Id to the respective ticket number.

$SMDefaultComputer ="SCSM02"
Import-Module SMLets
#$Class = Get-SCSMClass System.WorkItem.Incident$
$Class = Get-SCSMClass System.WorkItem.ServiceRequest$
$Id = 'SR136143'
Get-SCSMObject -Class $Class -filter "Id -eq $Id" | Set-SCSMObject -Property Status -Value "In Progress"

You can do the same for an Incident by uncommenting the $Class calling the WorkItem.Incident$ and commenting the $Class calling the WorkItem.ServiceRequest$...You can easily change the value to whatever you need to, just make sure that you set it to one that you actually use in your environment. 🙂

Modifying the Support Group or Tier Queue for multiple tickets

The following two code snippets came about because we had people selecting the wrong Support Groups and Tier Queues. The problem was overlooked for a while and was eventually noticed when we started introducing some reports for the customer. We needed a quick solution that we could use to change the groups over the correct Support Group and Tier Queue.

These work by taking a list of the IRs & SRs (sr.txt & ir.txt) which have the wrong Support Group or Tier Queue and setting them to the desired one. For these, the .txt files have a list of IRs and SRs, one ID per line in the text file.

#Service Request SupportGroup Mod
$SMDefaultComputer = "SCSM02"
Import-Module SMLets
$SRClass = Get-SCSMClass System.WorkItem.ServiceRequest$
$tickets = Get-Content 'c:\temp\sr.txt'
foreach ($ticket in $tickets)
      Get-SCSMObject -Class $IncClass -filter "Id -eq $Ticket" | Set-SCSMObject -Property SupportGroup -Value "Asset_Mgmt_Hardware"

#Incident TierQueue Mod

$SMDefaultComputer = "SCSM02"
Import-Module SMLets
$IncClass = Get-SCSMClass System.WorkItem.Incident$
$tickets = Get-Content 'c:\temp\ir.txt' #
foreach ($ticket in $tickets)
      Get-SCSMObject -Class $IncClass -filter "Id -eq $Ticket" | Set-SCSMObject -Property TierQueue -Value "Asset_Mgmt_Hardware"

Update the Employer field for a number of users

This is a snippet which allowed us to update the employer field for a large list of users. The customer wanted this so they could provide a more granular level or reporting.
The users.txt is simply nothing more than an AD user name in a text name per line. The second line in the script block just writes the data out so you can see make sure it changed the field.

$SMDefaultComputer = "SCSM02"
Import-Module SMLets
$userClass = Get-SCSMClass Microsoft.AD.User$
$users = Get-Content 'c:\temp\users.txt'

foreach ($user in $users)
      Get-SCSMObject -Class $UserClass -filter "username -eq $user" | Set-SCSMObject -Property Employer -Value "Contoso"
      Get-SCSMObject -Class $UserClass -filter "username -eq $user" | ft username, employer

That's all for now, I have a few more that I wrote a while back that I'll dig up and post at a later time.

Comments (2)
  1. Anonymous says:

    I can’t apply Get-SCSMObject by Service manager powershell in SCSM R2 environment. But this command worked.
    get-scsmClassInstance -class (Get-SCSMClass -name System.WorkItem.ServiceRequest) | Where-Object {$_.ID –
    eq “SR2”} | %{ $_.Status = “In Progress”; $_ } | Update-SCSMClassInstance

    I couldn’t see get-scsmobject powershell command below link.

    and I found update-scsmclassinstance powershell command on

  2. Adrian says:

    The "Modifying the Support Group or Tier Queue for multiple tickets", #Service Request SupportGroup Mod has as problem.. you have defined $SRClass but targeting $IncClass in the foreach loop. Should be $SRClass

Comments are closed.

Skip to main content