About Enumeration

Nov 16, 2010 at 5:18 PM
Edited Nov 16, 2010 at 5:22 PM

Hi again

Now question about Enumeration

I create own class and Enumeration list ($list = Get-SCSMEnumeration -Name ListOfRequestStatus.Resolved).
When try update this list using smlets

$list = Get-SCSMEnumeration -Name ListOfRequestStatus.Resolved
#My enum item

$class = Get-SCSMClass -name Fozzy.Request$
$SMObject = Get-SCSMObject -Class $class -Filter "ID -eq 6179"
$SMObject.RequestStatus
>>>>>>>>>>>>>> output
>>> Name                         Status    DisplayName
>>> ----                         ------    -----------
>>> ListOfRequestStatus.Sent     Unchanged Направлено

$list
>>>>>>>>>>>>>> output
>>> Name                         Status    DisplayName
>>> ----                         ------    -----------
>>> ListOfRequestStatus.Resolved Unchanged Решено    


$parameters = @{title="New Title";RequestStatus=$list}

Set-SCSMObject -SMObject $SMObject -PropertyHashtable $parameters

EnumerationNotFound
At :line:11 char:14

I try different variant $List.name, $list.ID, but error the same.
Can you explain me how to update this enum list

Thanks

regard

Alex

Developer
Nov 16, 2010 at 6:37 PM

you should be able to use $list.DisplayName

did you try that?

 

jim

Nov 17, 2010 at 9:23 AM

Yes, I tried.
Didn't work

Example with standart object
$class = Get-SCSMClass -name System.WorkItem.Incident$
$SMObject = Get-SCSMObject -Class $class -Filter "ID -eq IR6285"
#$SMObject.Classification
$list = (Get-SCSMEnumeration -Name IncidentClassificationEnum.Printing)
$list.displayname #Проблемы печати -> Printing Problems
[object]$parameters = @{title="New Title";Classification=$list.displayname}
Set-SCSMObject -SMObject $SMObject -PropertyHashtable $parameters
Not work

Set-SCSMObject -SMObject $SMObject -Property Classification -Value $list.DisplayName
Not work

error

EnumerationNotFound
At :line:19 char:14
+ Set-SCSMObject <<<<  -SMObject $SMObject -PropertyHashtable $parameters

EnumerationNotFound
At :line:20 char:14
+ Set-SCSMObject <<<<  -SMObject $SMObject -Property Classification -Value $list.DisplayName



Developer
Apr 4, 2011 at 10:08 PM

that cmdlet use this aproach to find enum:

 string fullEnumName = p.EnumType.GetElement().Name + "." + newValue.ToString();

where:
p is ManagementPackProperty
newValue is object

 


Coordinator
Jun 8, 2011 at 9:52 PM

Try $list.Id as the property value.

Coordinator
Jun 9, 2011 at 2:44 PM

Update from Jim based on an email discussion we had about this:

 

Oh – in this case it’s because of the way the cmdlet is being called. In this case, the Value property is a string, so the enum gets converted to a string at parameter binding. However, even when a hash table is used, it doesn’t work:

 

$incident | set-scsmobject –propertyha @{ Status = $Resolved }

 

I would have expected this to work, but it’s not – I’m not sure why, my intuition tells me it’s a PSObject wrapping problem.

It’s a bug, for sure (or maybe two, value should probably be “object” rather than “string”).

 

Coordinator
Jun 9, 2011 at 2:45 PM

We'll fix this in the next release of SMLets but for now the best approach is to always pass the ID GUID by getting the enumeration object using Get-SCSMEnumeration and then passing it as $enum.Id to the -Value parameter or in the property hashtable.