Home Asset Management

Add hardwareasset to softwareasset with powershell as relatedAsset

Robert_OsterbergRobert_Osterberg Customer Adept IT Monkey ✭✭
Hi
So i am trying to relate a HWA to A SWA with PowerShell but i get this Error and i am trying to understand it.
"New-SCSMRelationshipObject : The object with ID bb65e826-bca7-f8c9-acfc-e835286814ac is not of a valid class for insertion."
 
The GUID in this Case is pointing to the $CiresonHardwareAsset


My code so far is as follows
$CiresonSoftwareAssetClass = Get-SCSMClass -Name Cireson.AssetManagement.SoftwareAsset
        $CiresonHardwareAssetClass = Get-SCSMClass -Name Cireson.AssetManagement.HardwareAsset
        $CiresonSoftwareAssetHasRelComputerREL = Get-SCSMRelationshipClass -Name Cireson.AssetManagement.SoftwareAssetHasRelatedComputer
        $CiresonSoftwareAsset = Get-SCSMObject -Class $CiresonSoftwareAssetClass -Filter "Name -eq "<SWANAME>"
        $CiresonHardwareAsset = Get-SCSMObject -Class $CiresonHardwareAssetClass -filter "Name -eq "<ComputerName"

New-SCSMRelationshipObject -Source $CiresonHardwareAsset -Relationship $CiresonSoftwareAssetHasRelComputerREL -Target $CiresonSoftwareAsset -Bulk

I have trid to change the -Source and -Target around but it is the same,
Any one have an Idea??

Best Answer

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    Answer ✓
    That relationship class is relating Software Items to Computer CIs not Hardware Assets.  You might try System.ConfigItemRelatesToConfigItem

Answers

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    Answer ✓
    That relationship class is relating Software Items to Computer CIs not Hardware Assets.  You might try System.ConfigItemRelatesToConfigItem
  • Robert_OsterbergRobert_Osterberg Customer Adept IT Monkey ✭✭
    Thx for the response @Justin_Workman
    So if i understand correctly i have to add SCCM CI instead of the HWA?
  • Robert_OsterbergRobert_Osterberg Customer Adept IT Monkey ✭✭
    @Justin_Workman
    That worked like a charm thx but how can i get the ASSET to RelatedComputers on the SWA. is that yet another Class?


Sign In or Register to comment.