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

New Post: Affected user is not anymore an employee

$
0
0

first, you should use a different projection. The System.WorkItem.Incident.ProjectionType carries a lot more than you need, and with all those additional relationships, the amount of data that will be returned could be massive. You also need the script I wrote some time ago for building a projection criteria which didn't seem to make it into the smlets module (http://jtruher3.wordpress.com/2011/05/13/retrieving-projection-data-with-criteria/). You'll need to save that script and use it:

here's an example:

 

PS# $projection = get-scsmtypeprojection System.WorkItem.Incident.View.ProjectionType|select -first 1
PS# $projection

ProjectionType: System.WorkItem.Incident.View.ProjectionType
ProjectionSeed: System.WorkItem.Incident
Components:
   Alias                          TargetType         TargetEndPoint
   -----                          ----------         ---------------
   AffectedUser                   System.User        RequestedWorkItem
   AssignedUser                   System.User        AssignedWorkItem

PS# get-scsmobjectprojection -Projection $projection

Id          Title                                           AssignedTo        Status  Priority AffectedUser         LastModified
--          -----                                           ----------        ------  -------- ------------         ------------
CustomIR276 Nihil iriure sanctus gubergren invidunt commodo Luptatum Sanctus  Closed         2 Id Amet              3/24/2012 11:14:23 PM
CustomIR274 At laoreet vulputate voluptua vel accumsan      Velit Sea         Pending        9 Vero Enim            3/24/2012 11:14:23 PM
CustomIR277 Aliquam invidunt stet nonumy dolores duo        Velit Sea         Pending        1 Id Amet              3/24/2012 11:14:23 PM
CustomIR279 Voluptua gubergren eos in accusam elitr         Invidunt Sea      Active         1 Stet Sit             3/24/2012 11:14:23 PM
CustomIR273 Esse erat facilisis kasd id consequat           Aliquyam Volutpat Closed         6 In Eum               3/24/2012 11:14:23 PM
CustomIR282 Ut rebum gubergren diam diam duo                Stet Sit          Pending        2 Stet Sit             3/24/2012 11:14:23 PM
CustomIR281 Dolor clita voluptua wisi elitr aliquam         Vero Enim         Pending        2 JWT-D4.Administrator 3/24/2012 11:14:23 PM
CustomIR280 Illum ut minim velit no sit                     Accusam Justo     Pending        2 Velit Sea            3/24/2012 11:14:23 PM
CustomIR275 Eos dignissim congue imperdiet dolore ea        In Eum            Active         2 Luptatum Sanctus     3/24/2012 11:14:23 PM
CustomIR278 Clita sed accusam accusam dolor labore          Velit Sea         Closed         3 Invidunt Sea         3/24/2012 11:14:23 PM
PS# $criteria = new-scsmProjectionCriteria.ps1 -projection $projection -filter "AffectedUser.DisplayName -eq 'Stet Sit'"
PS# Get-SCSMObjectProjection -Criteria $criteria
Id          Title                                   AssignedTo   Status  Priority AffectedUser LastModified
-- ----- ---------- ------ -------- ------------ ------------
CustomIR279 Voluptua gubergren eos in accusam elitr Invidunt Sea Active 1 Stet Sit 3/24/2012 11:14:23 PM
CustomIR282 Ut rebum gubergren diam diam duo Stet Sit Pending 2 Stet Sit 3/24/2012 11:14:23 PM

 

 


 

Then, once you've got to this point, you can set the closed state:

PS# Get-SCSMObjectProjection -Criteria $criteria | %{$_.object}|set-scsmobject -PropertyHashtable @{ Status = "Closed" }
(which sets the status, and below is the proof :^)
PS# Get-SCSMObjectProjection -Criteria $criteria

Id          Title                                   AssignedTo   Status Priority AffectedUser LastModified
--          -----                                   ----------   ------ -------- ------------ ------------
CustomIR279 Voluptua gubergren eos in accusam elitr Invidunt Sea Closed        1 Stet Sit     4/24/2012 11:31:17 PM
CustomIR282 Ut rebum gubergren diam diam duo        Stet Sit     Closed        2 Stet Sit     4/24/2012 11:31:16 PM

Also, you should be able to provide a two part criteria:

$criteria = new-scsmProjectionCriteria -projection $projection -filter "AffectedUser.DisplayName -eq 'Stet Sit' -and Status -ne 'Closed'"

which will further reduce the amount of retrieved data

 

jim


Viewing all articles
Browse latest Browse all 306

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>