Cireson Partners, Customers and Community members share your customizations and examples here to help benefit the community as a whole to earn Kudos and badges.
DISCLAIMER
All files and projects located here are provided and come "as-is" and without any warranty or support. Use at your own risk. Your use of Community Uploads is subject to our Terms of Use.
Cireson does not and will not support or maintain these enhancements, extensions, and scripts.
For Team Cireson uploads click here.
PowerShell - Get parent levels for Enumeration
I put together this recursive function today to help me decode and rename our lists. Maybe it can help someone else. The problem I have is that our lists were mostly populated in console, so they have the default Enum.xxxxxxx names, but no indication of where it is used. Using this function will show each enumeration above the one listed, up to and including the root enumeration.
***Assumes you have SMLets :)***
function Get-SCSMEnumerationParentTree { [CmdletBinding()] PARAM ( [Parameter(Mandatory = $true, ParameterSetName = 'Name')] [string]$Name, [Parameter(Mandatory = $true, ParameterSetName = 'Id')] [string]$Id ) switch ($PSCmdlet.ParameterSetName) { 'Name' { Get-SCSMEnumeration -Name $Name | Tee-Object -Variable Enum break } 'Id' { Get-SCSMEnumeration -Id $Id | Tee-Object -Variable Enum break } default { break } } if ($Enum.Parent -ne $null) { Get-SCSMEnumerationParentTree -Id $Enum.Parent.Id } }
Output:
C:\Temp\SCSM> Get-SCSMEnumerationParentTree -Name Enum.023d427051dd4ed5aa3685d5329b358a ordinal name displayname ------- ---- ----------- 4 Enum.023d427051dd4ed5aa3685d5329b358a Highjump 41.59375 Enum.1ba8c6aba8d8405492f6a0154438d3bd Environment IncidentClassificationEnum Incident Classification
Comments
At the very least, there needs to be some acknowledgement here for the use of Tee-Object 👍️
Wow, all of the acknowledgement. I'm going to go write something with Tee-Object
Geoff