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

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

This procedure can be used to run scripts on Remote SCSM Management Server

Run $cred = Get-Credential to get the Username/Password

$cred = Get-Credential

  • $cred variable will hold the required username and password, could be from a user who has admin rights on the SCSM Management Server
  • Use the below method to write the Credential to a File

Read-Host  -AsSecureString  $cred  | ConvertFrom-SecureString | Out-File c:\Temp\cred.txt

  • Read from the file and store the Password to a variable as follows

$password = get-content  C:\temp\cred.txt | convertto-securestring

  • Pass the credential as follows

$cred =  New-Object System.Management.Automation.PSCredential ("domain\username", $password)

Invoke-Command  -ComputerName ServerName {

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

} -Credential $Cred

 

Requirements :

  • SMlets Powershell Library should be loaded in the Remote Management Server

Notes :

  • ServerName = SCSM Management Server
  • Tests should be done on non-productive environment
    • Not responsible for loss of any data with the usage of this script/function
  • Can be used to carry out various functions as applicable to variable classes within SCSM
  • The cred.txt is an encrypted file containing the password of the associated user used to create the password

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

#Should be executed on the SCSM Data Warehouse Server

if ( -not (get-module  -name  Microsoft.EnterpriseManagement.Warehouse.Cmdlets)) {import-module  'C:\Program Files\Microsoft System Center 2012 R2\Service Manager\Microsoft.EnterpriseManagement.Warehouse.Cmdlets.psd1'}

Get-SCDWJob | Select  Description, LastRunTime,NextRunTime | SortDescription  | ConvertTo-HTML  | Out-File   e:\DWJobSch\dwjsch.htm

 

Sample html received by e-mail

 

 Notes :

SMTPServer configuration required

sendingaddress and receivingaddress should be within "" (double quotes)

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

 

Subcategories