PowerShell/SCSM - My first steps

I recently started to work with System Center Service Manager 2012 R2 (also known as SCSM) which provides provides an integrated platform for automating and adapting an organization's IT service management best practices, such as those found in Microsoft Operations Framework (MOF) and Information Technology Infrastructure Library (ITIL). It provides built-in processes for incident and problem resolution, change control, and asset lifecycle management.

This platform can easily be integrated with the other products of the System Center suite. In my case we are using System Center Orchestrator at work (also known as SCO or SCORCH) to handle the background automation part.

I really started to play and learn about SCSM 2 months ago with the help of the consultants from Prosum (David Gibbons) and Cireson (Will Udovich). Those guys also did a really awesome work and put in place some awesome processes using PowerShell Magic/SCSM and SCORCH, Thanks guys!

Getting Started with SMLets to manage SCSM

Today I will show a few examples using the SMLets module that I learned in the past weeks.
SMLets download and documentation can be found here: https://smlets.codeplex.com/

Before I start exploring some of the commands, I just wanted to point-out a very neat tool created by Dieter Gasser called SCSM Entity Explorer. This allow you to browse SCSM Classes and Enumerations. Because there is not a Smlets for everything, you can use the very flexible Get-SCSMObject and Get-SCSMClass to retrieve additional information.

SCCM Entity Explorer

Get the Service Requests objects

# Get List of all Service Request
Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$)

Get the Service Requests created in the last 2 days

# Get List of all Service Request modified in the last 2 days
Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -Filter "LastModified -gt $((Get-Date).Adddays(-2))"

Get the Service Requests created in the last 2 days with a status: In Progress

Here you can see how to filter on more than one criteria using the Get-SCSMObject.

# Get List of all Service Request modified in the last 2 days with an InProgress status
$ServiceRequestClass = Get-SCSMClass -Name System.WorkItem.ServiceRequest$
$ServiceRequestInProgressStatus = Get-SCSMEnumeration -Name ServiceRequestStatusEnum.InProgress$
$ServiceRequestInProgressStatusID = $ServiceRequestInProgressStatus.ID
$TwoDaysAgo = $((Get-Date).Adddays(-2))

Get-SCSMObject -Class $ServiceRequestClass -Filter "LastModified > '$TwoDaysAgo' AND Status = '$ServiceRequestInProgressStatusID'"

Get related object(s) of the Service Request

# Related Object of a Service request
$SRTicket = Get-SCSMObject -Class $ServiceRequestClass -Filter "LastModified > '$TwoDaysAgo' AND Status = '$ServiceRequestInProgressStatusID'" | Select-Object -Last 1
Get-SCSMRelatedObject -SMObject $SRTicket

Get relationship object(s) of the Service Request

# Retrieve Relationship Object(s)
Get-SCSMRelationshipObject -BySource $SRTicket

Get relationship object(s) TargetObject and RelationshipID of the Service Request

# Retrieve Relationship Object. Select the property TargetObject and RelationshipID
Get-SCSMRelationshipObject -BySource $SRTicket |
    Select-Object -Property TargetObject,RelationshipID

For the next step we will re-use the Active Directory Object type (ID: d96c8b59-8554-6e77-0aa7-f51448868b43)

Get relationship object(s) and filter on Active Directory objects
Those elements are queried to the CMDB of SCSM, not to ActiveDirectory.

# Retrieve Relationship Objects with a specific relationship (in this case AD objects(Computers, Users and Groups)).
Get-SCSMRelationshipObject -BySource $SRTicket -Filter "RelationshipID -eq 'd96c8b59-8554-6e77-0aa7-f51448868b43'"



See extensive SCSM Glossary (technet)

Configuration Item
ITIL defines a configuration item (CI) as any component that needs to be managed in order to
deliver an IT Service. These could be a piece of hardware, software, documentation, a user
or group, location, or network.

Work Item
Incidents, change requests, and problems are represented as work items and stored in the
Service Manager database.

In Service Manager, a queue is a container that contains work items. When you change
the support group on an incident in Service Manager, you are sending the incident to
another queue.

A named descriptor for a set of objects that share the same attributes, operations, methods, relationships, and behaviors. For example, all logical hard disks are members of the logical disk class.
Properties of the logical disk class include size, file system, and defrag level. Other
attributes members of a class can share are relationships and behaviors.

Service Request
A work item that is used to request an existing IT service that is being offered.

Management Pack
Management packs are eXtensible Markup Language (XML) files containing definitions
that define not only data models but also objects such as views for the Service
Manager console, workflows, groups, queues, tasks, forms, connectors, and so on. All
customizations are stored in MPs. For example, if you want to modify the incident form,
you save your modification from the Authoring Tool in an MP and then import it into
Service Manager.

Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.

No comments:

Post a Comment