如何将Get-HPWarrantyEntitlement信息导出至自定义注册表并导入SCCM?
I’ve worked through similar SCCM and HP device management tasks before, so here’s a tested, step-by-step workflow to make this happen:
Step 1: Install the Required HP PowerShell Module
First, you need the HPEScriptingTools module to run Get-HPWarrantyEntitlement. Fire up an elevated PowerShell session and run this:
# Install the module (accept prompts for repository access if needed) Install-Module -Name HPEScriptingTools -Force -AllowClobber
If deploying this across multiple devices, add error handling to the script to skip installation if the module is already present.
Step 2: PowerShell Script to Fetch Warranty & Write to Registry
This script pulls key warranty details and writes them to a machine-wide registry path (SCCM prioritizes HKLM keys for inventory collection):
# Require elevated privileges to write to HKLM #Requires -RunAsAdministrator # Import HP module with error handling try { Import-Module HPEScriptingTools -ErrorAction Stop } catch { Write-Error "HPEScriptingTools module missing. Install it first with Install-Module HPEScriptingTools." exit 1 } # Retrieve warranty data (uses the device's serial number automatically) try { $warranty = Get-HPWarrantyEntitlement -ErrorAction Stop } catch { Write-Error "Failed to fetch warranty info: $_" exit 1 } # Create custom registry path if it doesn't exist $registryPath = "HKLM:\Software\YourOrg\DeviceInventory\HPWarranty" if (-not (Test-Path $registryPath)) { New-Item -Path $registryPath -Force | Out-Null } # Write critical warranty values to registry Set-ItemProperty -Path $registryPath -Name "SerialNumber" -Value $warranty.SerialNumber -Type String Set-ItemProperty -Path $registryPath -Name "WarrantyStatus" -Value $warranty.Status -Type String Set-ItemProperty -Path $registryPath -Name "EndDate" -Value $warranty.EndDate.ToString("yyyy-MM-dd") -Type String Set-ItemProperty -Path $registryPath -Name "ProductNumber" -Value $warranty.ProductNumber -Type String Set-ItemProperty -Path $registryPath -Name "EntitlementType" -Value $warranty.EntitlementType -Type String Write-Host "Warranty data saved to registry: $registryPath"
Adjust the $registryPath to match your organization’s naming standards, and add/remove properties based on which warranty details you need to collect.
Step 3: Configure SCCM to Collect the Registry Data
Once the registry values are on devices, set up SCCM hardware inventory to capture them:
- Open the SCCM Console, go to Administration > Client Settings (use Default Client Settings or create a custom policy)
- Edit the settings, navigate to Hardware Inventory > Set Classes
- Click Add > Connect, select a device that already has the registry keys populated, then browse to your custom
HKLMpath - Import the registry values as a new inventory class (name it something like
HP_Device_Warranty) - Deploy the updated client settings to your device collections, then trigger a hardware inventory cycle on target devices
Key Tips to Avoid Issues
- Permissions: Deploy the script via SCCM Package/Program or Script Deployment with elevated rights (required to write to
HKLMand install modules) - Offline Devices:
Get-HPWarrantyEntitlementneeds internet access to pull data from HP’s servers. Add retry logic in the script to handle offline scenarios. - Model Compatibility: Test the module on different HP device models to ensure consistent results.
内容的提问来源于stack exchange,提问作者ThatGuy

