How to update ClosedDate with blank

Oct 20, 2011 at 5:16 PM

Is there any way of removing the value on the ClosedDate property for an incident?

I'm trying to re-activate closed incidents but besides changing the status, I'd like to remove the closeddate. I'm having the same issue with updating a value for an enumeration and leaving is blank?

Any ideas on how to do that?

Thanks!

Developer
Oct 21, 2011 at 12:57 AM

it should be possible to do this. But rather than using the SCSMIncident cmdlet, I'm working against the incident instance directly, but this should still do the trick.

$i = get-scsmclass m.incident$ | Get-SCSMObject
PS# $i|ft displayname,closeddate,status

DisplayName ClosedDate             Status
----------- ----------             ------
CustomIR28                         Active
CustomIR29  8/13/2011 11:11:56 PM  Closed
CustomIR30                         Active
CustomIR31  9/21/2011 2:11:57 AM   Closed
CustomIR32  8/29/2011 6:11:57 PM   Closed
CustomIR33                         Pending
CustomIR34                         Pending
CustomIR35                         Active
CustomIR36                         Resolved
CustomIR37                         Active

PS# $i|?{$_.closeddate}|Set-SCSMObject -PropertyHashtable @{ Status = "Active"; ClosedDate = $null }
PS# $i = get-scsmclass m.incident$ | Get-SCSMObject

PS# $i|ft displayname,closeddate,status -au

DisplayName ClosedDate Status
----------- ---------- ------
CustomIR28             Active
CustomIR29             Active
CustomIR30             Active
CustomIR31             Active
CustomIR32             Active
CustomIR33             Pending
CustomIR34             Pending
CustomIR35             Active
CustomIR36             Resolved
CustomIR37             Active

The way I'm doing this is to set the ClosedDate to $null, don't forget to change the status. The same trick should work for enums as well (except for those enums which are required to have a value).

PS# $i[0]|fl name,Classification


Name           : CustomIR28
Classification : Networking Problems
PS# $i[0]|Set-SCSMObject -PropertyHashtable @{ Classification = $null } PS# $i = get-scsmclass m.incident$ | Get-SCSMObject PS# $i[0]|fl name,Classification Name : CustomIR28 Classification :
You can see that the classification is now null.