Home Service Manager

Bulk import of catalog model and manufacturer into SM lists

Robert_CarusoRobert_Caruso Customer IT Monkey ✭
Has anyone found an easy way to import catalog item model and catalog item manufacturer. I have over 1000 models and 500 manufacturers. The GUI way is painful!
Thanks to anyone who can help.
Rob

Answers

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Hi @Robert_Caruso

    I agree with you, doing 1000 models in the GUI would very painful. Try the below script. It takes the list of values (could be easily adapted to read them in from a file) adds them as list items and then reads the whole list back in and reorders them alphabetically. It takes a while (for 1000 it will take ages) and please remember to export and backup your MP before hand just in case.

    $ListItems = @(
        'Precision 7720',
        'Precision 7730',
        'Precision 7740'
    )
    
    $List = "Cireson.AssetManagement.CatalogItemModelEnum"
    
    $MPName  = "AssetManagement_Lists"
    
    ###
    
    $ParentEnum = Get-SCSMEnumeration $List
    
    $MP = Get-SCManagementPack $MPName
    
    $ListItems | % {
        Add-SCSMEnumeration -ManagementPack $MP -Name "Enum.$(([string]([Guid]::NewGuid()).Guid).Replace('-',''))" -Ordinal 0 -Parent $ParentEnum -DisplayName $_
        "Added $_"
    }
    
    $i = 0
    
    $ParentEnum | Get-SCSMChildEnumeration | Sort-Object -Property DisplayName | % {
        Add-SCSMEnumeration -ManagementPack $MP -Name $_.Name -Ordinal $i -Parent $ParentEnum -DisplayName $_.DisplayName
        "Sorted $($_.DisplayName)"
        $i++
    }
    
    $ParentEnum | Get-SCSMChildEnumeration | Sort-Object Ordinal
    Hope it works.

    Geoff
Sign In or Register to comment.