Home Asset Management
Options

Creating Cireson CI Standard with PowerShell

Steve_XiongSteve_Xiong Customer IT Monkey ✭

I'm creating Cireson Standard CI objects via PowerShell. Below is my code. I am able to create a Cireson Standard CI object with the code below. However, a non-terminating error is thrown saying the 'property 'Notes' has already been added to collection'. So I checked the Cireson Standard class and it has TWO Notes properties. One of the properties takes in a [richtext] value and the other takes a [string] value.

My question was this intended and how do I create my hashtable that does not throw a non-terminating error. 

Also in my other tests, it appears the non-terminating error stops 'New-SCSMObject -PassThru' from returning the CI object. Another thing, other Cireson CI classes that I've looked at does not have two Notes properties.

BTW, below my variable $ComputerName is correctly assigned to the SCSM MP.

$CiresonStandardClass = Get-SCSMClass -Name Cireson.AssetManagement.Standard$ -ComputerName $ComputerName

$hashproperties = @{ Id = ([guid]::NewGuid()).ToString(); DisplayName = "Test Standard"; Name = "Test Standard"; Notes = "Test notes" }
New-SCSMObject -Class $CiresonStandardClass -PropertyHashtable $hashproperties -ComputerName $ComputerName

New-SCSMObject : Item has already been added. Key in dictionary: 'Notes' Key being added: 'Notes'
At line:9 char:1
+ New-SCSMObject -Class $CiresonStandardClass -PropertyHashtable $hashproperties - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Notes:ManagementPackProperty) [New-SCSMObject], ArgumentException + FullyQualifiedErrorId : property 'Notes' has already been added to collection,SMLets.NewSMObjectCommand

Sign In or Register to comment.