Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all articles
Browse latest Browse all 306

Commented Unassigned: All Unassigned Service Requests script needed [11252]

$
0
0
Hello, I would like to write a script to pull all the unassigned service requests that were created 12hrs prior to current date. I need to be able to filter on specific support groups. It appears easier to do this for incidents but because there is no get-scsmservicerequest cmdlet, I am at a loss. Thanks
Comments: ** Comment from web user: bobske **

Hi Pat,

You can use the get-scsmobject -Class <someclass> instead to retrieve any object based on a specific class.

So in your case this could be a solution (if I undestood your request correct):

```
Import-Module smlets

#Get Date 12 hours ago
$Date12HoursAgo = (Get-Date).AddHours(-400)

#Get Assigned To relationship class
$RelAssignedTo = Get-SCSMRelationshipClass -Name system.workitemAssignedTo

#Get Service Request Class
$srClass = Get-SCSMClass -Name system.workitem.servicerequest$

#Get all SRs made from 12 hours ago to now.
$SRs = Get-SCSMObject -Class $srClass -Filter "CreatedDate -gt $Date12HoursAgo"
"No Assigned User on the following Service Requests:`n`n"
foreach ($SR in $SRs)
{

if(!(Get-SCSMRelatedObject -SMObject $SR -Relationship $RelAssignedTo))
{
$SR | ft Displayname, CreatedDate -HideTableHeaders
}
}
```


Viewing all articles
Browse latest Browse all 306

Trending Articles