Creating New Software Asset in Powershell

James_JohnsonJames_Johnson Customer IT Monkey ✭
Hello,

I'm trying to use SMLets to create some Software Assets from a csv. For some reason when I try to create the new object I get this error 
InvalidOperation: (Cireson.AssetManagement.SoftwareAsset:CreatableEnterpriseManagementObject) [New-SCSMObject], InvalidSimpleObjectValueException


This is the code for actually creating the object:
    [email protected]{
        Name = "Adobe Creative Cloud";
        Manufacturer = "Adobe";
        Version = "Named User License";
        ReceivedDate = [DateTime]"8/1/2018 7:00:00 AM"
        ExpectedDate = [DateTime]"8/1/2019 7:00:00 AM"
        Cost = "45";
        SoftwareLibraryLocation = "Web:`nDropbox:`nSoftware Center:  Software download is available on Software Center";
        DisplayName = "Adobe Creative Cloud"
        SoftwareAssetStatus = "Active";
    }
    $newSoftware = New-SCSMObject -Verbose -Class (Get-SCSMClass -Name Cireson.AssetManagement.SoftwareAsset) -PropertyHashtable $param

Any ideas what I'm doing wrong? I've tried with the only value in the hashtable being Name as well and it still throws the same error. 

Thanks!
James

Best Answer

Answers

  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭
    While Justin beat me to the ID field, you also need to hit the enum's correctly.
    Here is an example

    if ( !(Get-Module -Name smlets -ErrorAction SilentlyContinue) ) {Import-module smlets}
    $SoftwareAssetClass = Get-SCSMClass -name Cireson.AssetManagement.SoftwareAsset

    $SoftwareAssetApprovedEnum = Get-SCSMEnumeration -Name Cireson.AssetManagement.SoftwareAssetStatusEnum.Approved


    $param=@{
            SoftwareassetId = [guid]::NewGuid();
            Name = "Testing";
            SoftwareAssetStatus = $SoftwareAssetApprovedEnum;
        }
    $newSoftware = New-SCSMObject -Class $SoftwareAssetClass -PropertyHashtable $param

    (This is a great tool for looking up proper names the PS uses for look ups. https://gallery.technet.microsoft.com/SCSM-Entity-Explorer-68b86bd2)

  • James_JohnsonJames_Johnson Customer IT Monkey ✭
    It actually converts the string into the enum just fine on it's own as long it matches the value exactly. 
Sign In or Register to comment.