Just the rambling of a tech geek and cloud engineer

Using SMLets practically

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

One response to “Using SMLets practically”

  1. sign printing Avatar
    sign printing

    nice post.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.