Adding a specific license to a Software based on a predefined criteria with Poershell

Robert_OsterbergRobert_Osterberg Customer IT Monkey ✭
So my question is how can i bulk update SWA in ITAM and adding licenses with powershell.
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_WorkmanJustin_Workman Cireson Support Ninja IT Monkey ✭✭✭✭
    Accepted Answer
    @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 -Bulk

Answers

  • Justin_WorkmanJustin_Workman Cireson Support Ninja IT Monkey ✭✭✭✭
    Accepted Answer
    @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 -Bulk
  • Robert_OsterbergRobert_Osterberg Customer IT Monkey ✭
    It was the last bit i was missing thx for yet another quik response @Justin_Workman thx

  • Robert_OsterbergRobert_Osterberg Customer IT Monkey ✭
    Hi again. So all is well with the script and it does what it is suppose to, but some SW items in SCSM appears more than one time and has the same identical status 
    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

  • Roland_KindRoland_Kind Partner Advanced IT Monkey ✭✭✭

    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 ...

Sign In or Register to comment.