Adding a specific license to a Software based on a predefined criteria with Poershell
I have a csv file with SWA and i have all the bits for reading it and finding the correct License and the SWA but i need help when it comes to actually updating the SWA with the License item.
Best Answer
-
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭@Robert_Osterberg
This is pretty generic, but hopefully it will get you on the right track:$SAClass = Get-SCSMClass -Name Cireson.assetmanagement.SoftwareAsset$LicClass = Get-SCSMClass -Name Cireson.AssetManagement.Licence$relClass = Get-SCSMRelationshipClass -Name Cireson.AssetManagement.SoftwareAssetHasLicence$asset = Get-SCSMObject -Class $SAClass -Filter "displayname -like '*office*'"$license = Get-SCSMObject -Class $LicClass -Filter "Displayname -like '*office*'"New-SCSMRelationshipObject -Relationship $relClass -Source $asset -Target $license -Bulk2
Answers
This is pretty generic, but hopefully it will get you on the right track:
ObjectStatus : System.ConfigItem.ObjectStatusEnum.Active and the ID is identical
#Id : 21eb082a-057c-17e2-140b-470e3b2d34d0 on both instances of this item. Also some SW items can appear three times.
So my question is how can i get around this from the props on the item i can`t find anything that separates them?
The script trows an exception due to the fact that there are more than one instance and can`t set the correct license to the first item that match.
script for refrence
$SWA = Get-SCClassInstance -DisplayName "WinCVS 2.0"
$SWA
Hi,
not sure about that - but just as an idea - the return value is maybe not a single value - it could be an array so using $swa[0] should select the first one. You can test the variable with $swa.gettype() for array ...