Retrieve value from computer via powershell ans put it in inventory

Comments

1 comment

  • Colby Bouma

    We are planning on adding a PowerShell scanner to PDQ Inventory that would allow you to do things like this, but I have no ETA on when it will be ready. In the meantime, one thing you can try is to write a PowerShell script that stores your converted data in WMI, run that script with Deploy, and set the Scan Profile on that package to a WMI scanner.

    Here's a rough proof-of-concept script I found in my notes for storing data in WMI:

    # https://social.technet.microsoft.com/Forums/exchange/en-US/183b8b56-131c-4de7-80bc-08650daf7333/wmi-custom-class-with-powershell?forum=ITCG

    param (
    [string]$ClassName,
    [array]$Properties,
    [string]$Namespace = "root\CIMV2"
    )

    $NewClass = New-Object System.Management.ManagementClass("$Namespace", [String]::Empty, $null)

    $NewClass["__CLASS"] = "$ClassName"
    $NewClass.Qualifiers.Add("Static", $true)

    ForEach ( $Property in $Properties ) {

    $NewClass.Properties.Add("$Property", [System.Management.CimType]::String, $false)
    $NewClass.Properties["$Property"].Qualifiers.Add("Key", $true)

    }

    $NewClass.Put()
    1
    Comment actions Permalink

Please sign in to leave a comment.