Home General Discussion

Export\import many enumerations in scsm by powershell

pavel3pavel3 Member IT Monkey ✭

Hi

I need to export\import to many enumeration in new scsm install.

I find same script to export but all of it do not works (\ru' locate etc).

Import script i cant find.

1 export script

$SCSMServer = "localhost"
$EnumName = "IncidentClassificationEnum$"
#######
$SCSM = @{ComputerName = $SCSMServer}
$Enum = Get-SCSMEnumeration -Name $EnumName @SCSM
$i = -1
Write-Host "`n"
Write-Host "List Values for $EnumName"
(0..("List Values for $EnumName".Length - 1)) | % {Write-Host "-" -NoNewline}
Write-Host "`n`n" -NoNewline
Function Get-Enums ($ParentEnum) {
  $Enums = Get-SCSMChildEnumeration -Enumeration $ParentEnum -Depth OneLevel @SCSM | Sort-Object -Property Ordinal
  $i++
  ForEach ($Enum in $Enums) {
    (0..$i) | % {Write-Host "`t" -NoNewline}
    Write-Host $Enum.DisplayName -NoNewline
    Write-Host "`n" -NoNewline
    Get-Enums -ParentEnum $Enum
  }
}

2 export script

$EMG = New-Object Microsoft.EnterpriseManagement.EnterpriseManagementGroup "localhost"
$Enums = $EMG.EntityTypes.GetEnumerations()
 
function getChildren([Microsoft.EnterpriseManagement.Configuration.ManagementPackEnumeration]$parent)
{
  $outPut = "$outPut - " + $parent.DisplayName
  Write-host $outPut
  Foreach ($child in $EMG.EntityTypes.GetEnumerations() |?{$_.Parent -eq $parent})
  {
    getChildren -parent $child -child $true
  }
}
 
$list = 'IncidentClassificationEnum'
$parent = $Enums |?{$_.Name -eq $list}
 
 
getChildren $parent

Some link is 'out of service'.

Can you help me.

Thanks

Answers

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    @pavel3 - You can use something like this:


    $values = Import-Csv $csvPath

    $mp = Get-SCSMManagementPack -Name $mpName

    $parentEnum = Get-SCSMEnumeration -Name IncidentResolutionCategoryEnum$


    $ordinal = 0

    foreach ($value in $values) {

      Add-SCSMEnumeration -Parent $parentEnum -Name $value.Name -DisplayName $value.Displayname -Ordinal $ordinal -ManagementPack $mp

      $ordinal++

    }

    This assumes your exported values are in a CSV in the format Name=<internal shortname>, DisplayName=<visible enum value>. $mpName is the name of the MP you want to store the new list values in.

Sign In or Register to comment.