Creating New Software Asset in Powershell
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:
$param=@{ 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
-
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭You need to give it a SoftwareAssetId. Try this in your hashtable:
SoftwareassetId = [guid]::NewGuid();
5
Answers
SoftwareassetId = [guid]::NewGuid();
$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