Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
giobatcodo
Engaged Sweeper

Hi

I would like to run this PS command in Lansweeper to retrive details of our HP docking stations (first of all the firmware version)

Get-WmiObject -Class HP_DockAccessory -Namespace root/HP/InstrumentedServices/v1

It works on my pc (I have installed HP WMI agent in prior - HPAccessoryWMIProvider.exe) but I don't know how to use on every pc on our network and manage results in Lansweeper.

Thanks

1 REPLY 1
Jacob_H
Lansweeper Employee
Lansweeper Employee

I gave away my HP dock for a christmas gift (really) but you could make a script and run it as a logon script (gpo/etc) or run it in the deployment section of lansweeper on-premise - and write values to registry keys so you can scan them and report on them (I'm guessing as to the values returned so you'll need to edit that).  (add the keys in on-prem https://community.lansweeper.com/t5/scanning-your-network/scan-registry-values-with-custom-registry-...) and learn about on-prem deployment https://community.lansweeper.com/t5/deploying-software-other-changes/create-a-deployment-package/ta-... ) 

 

# Define registry path
$regPath = "HKLM:\SOFTWARE\lansweeper\scripts\hp_dock"

# Ensure the script runs with administrator privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Write-Host "This script must be run as Administrator. Exiting."
    exit 1
}

# Retrieve HP Dock Accessory information
try {
    $dockInfo = Get-WmiObject -Class HP_DockAccessory -Namespace root/HP/InstrumentedServices/v1 -ErrorAction Stop
    
    if ($dockInfo) {
        # Ensure the registry path exists
        if (-not (Test-Path $regPath)) {
            New-Item -Path $regPath -Force | Out-Null
        }
        
        # Write each property to the registry separately
        Set-ItemProperty -Path $regPath -Name "InstanceID" -Value $dockInfo.InstanceID -Force
        Set-ItemProperty -Path $regPath -Name "Model" -Value $dockInfo.Model -Force
        Set-ItemProperty -Path $regPath -Name "Manufacturer" -Value $dockInfo.Manufacturer -Force
        Set-ItemProperty -Path $regPath -Name "FirmwareVersion" -Value $dockInfo.FirmwareVersion -Force
        Set-ItemProperty -Path $regPath -Name "SerialNumber" -Value $dockInfo.SerialNumber -Force
        Set-ItemProperty -Path $regPath -Name "Status" -Value $dockInfo.Status -Force
        Set-ItemProperty -Path $regPath -Name "PowerState" -Value $dockInfo.PowerState -Force
        Set-ItemProperty -Path $regPath -Name "DockType" -Value $dockInfo.DockType -Force

        Write-Host "HP DockAccessory information successfully written to the registry."
    } else {
        Write-Host "No dock accessory detected."
    }
} catch {
    Write-Host "Error retrieving HP DockAccessory information: $_"
}

 

 

Reports & Analytics

Ask about reports you're interested in and share reports you've created. Subscribe to receive daily updates of reports shared in the Community.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now