Change status by SMLets
I have a question
I want to change the Resolved status TO Closed Status for all IRs with status "resolved"
For this , I will use the SMLets commands
Import-Module SMLets |
$IncidentClass = Get-SCSMClass -Name System.WorkItem.Incident$ |
$StatusResolved = (Get-SCSMEnumeration IncidentStatusEnum.Resolved) |
$date=(get-date).adddays(-3) |
$Close_sc=Get-SCSMObject -Class $IncidentClass | where{($_.status -eq $StatusResolved) -and ($_.lastmodified -lt $date) } |
$Close_sc | Set-SCSMIncident -Status Closed This script is working correctly but ı do not know that will be there a problem with the cireson portal after executing this script ? |
Best Answers
-
Morten_Meisler Premier Partner Advanced IT Monkey ✭✭✭You might want to take a look at the autoclose app from Cireson (free community tool):
http://cireson.com/apps/auto-close/
But no, I don't see a problem with this. It's a common practice for many. The "grace" period for closing the Incident after it's resolved is of course a different discussion
edit:
A code tip is to change the where to a filter, that will go much faster as you are then making a direct WHERE in sql instead of pulling all data to the client first and then doing a powershell where.Get-SCSMObject -Class $IncidentClass -Filter "Status -eq '$($StatusResolved.Id)' AND LastModified -lt '$date'"
5 -
Geoff_Ross Cireson Consultant O.G.Ozgur,
You'll be fine. That script will update the ServiceManager database and then the next time the CacheBuilder runs its work item sync (default is every minute) the Portal will update too.
Geoff5
Answers
http://cireson.com/apps/auto-close/
But no, I don't see a problem with this. It's a common practice for many. The "grace" period for closing the Incident after it's resolved is of course a different discussion
edit:
A code tip is to change the where to a filter, that will go much faster as you are then making a direct WHERE in sql instead of pulling all data to the client first and then doing a powershell where.
You'll be fine. That script will update the ServiceManager database and then the next time the CacheBuilder runs its work item sync (default is every minute) the Portal will update too.
Geoff
we have that App
but I don't why, the IRs which were resolved with status "Canceled by Level 1" , The status hasn't changed to CLOSE automatically
And ı have another question, I thing , maybe there will be problems with the Cireson cache after SMlets scritp.
for clearing the cache
there is a command "TRUNCATE TABLE LastModified"
can I use this command for only clearing the cache ?
or how you to clear the cache ?