Using SMLets practically

Posted: May 17, 2011 in Technology
Tags: , ,

In my previous post, SCSM And Powershell, I mentioned that I am now starting to play with get-scsmobject. In this post I also created a script. That script has now been evolved into a proper get-scsmobject script.

Import-Module smlets

$Now = (get-date).AddDays(-7)

$CId = (Get-SCSMEnumeration -ComputerName "ms-ec-hdm01" IncidentStatusEnum.Closed$).id

$RId = (Get-SCSMEnumeration -ComputerName "ms-ec-hdm01" IncidentStatusEnum.Resolved$).id

$Class = Get-SCSMClass -ComputerName "ms-ec-hdm01" System.WorkItem.Incident$

$cType = "Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria"

#$cString = "Status != '$CId' and Status != '$RId' and TargetResolutionTime < '$Now' and TargetResolutionTime Is Not Null"
$cStringClosed = "Status = '$CId'and CreatedDate >'$Now'"
$cStringResolved = "Status = '$RId'and CreatedDate >'$Now'"
$cStringAll = "CreatedDate >'$Now'"

$critClosed = new-object $cType $cStringClosed,$Class
$critResolved = new-object $cType $cStringResolved,$Class
$critAll = new-object $cType $cStringOther,$Class

$closed = Get-SCSMObject -ComputerName "ms-ec-hdm01" -Criteria $critClosed 

$resolved = Get-SCSMObject -ComputerName "ms-ec-hdm01" -Criteria $critResolved 

$all = Get-SCSMObject -ComputerName "ms-ec-hdm01" -Criteria $critAll 

#$all = Get-SCSMObject -ComputerName "ms-ec-hdm01" -Class (Get-SCSMClass -ComputerName "ms-ec-hdm01" System.WorkItem.Incident$)

$closedcount = $closed.count
$resolvedcount = $resolved.count
$allcount = $all.count
$othercount = $allcount - $closedcount - $resolvedcount
write-host "all calls:"  $allcount
Write-host "closed calls:" $closedcount
write-host "resolved calls:" $resolvedcount
write-host "other calls:" $othercount

The updated file can also be found here E-Mail breakdown of calls using get-scsmobject, this makes the execution far quicker.

Some handy Active Directory powershell scripts to follow


Leave a Reply

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

You are commenting using your 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