SCCM – How to force Full Hardware Inventory on SCCM Clients using Powershell

Using the SCCM Console to do a Hardware Inventory will only result in a delta change being uploaded. To do a full inventory, you need to reset the Inventory Agent and then invoke a Hardware Cycle using powershell . The function below, does just that.

<#
.Synopsis
   Resets the Hardware Inventory Agent and initiates a full hardware inventory for CM Client
.DESCRIPTION
    Initiates a full hardware inventory for CM Client by removing the current information and initiating a  hardware inventory. 
    As the Hardware Inventory Agent has been reset there is no existing Hardware Information, a full inventory will be run
.EXAMPLE
   Invoke-FullHardwareInventory -ComputerName PC1
.EXAMPLE
   Invoke-FullHardwareInventory
   This will prompt you for ComputerName to check
.AUTHOR
   www.britv8.com
#>
Function Invoke-FullHarwareInventory
{
    Param
    (
        # Pass the computername name 
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        $ComputerName
        
    )

    Begin
        {

        }
    Process
        {
        if (Test-Connection $Computername -count 1)
            {
            $HardwareInventoryID = '{00000000-0000-0000-0000-000000000001}'
            Get-CimInstance -ComputerName $Computername -Namespace   'Root\CCM\INVAGT' -Class 'InventoryActionStatus' -Filter "InventoryActionID='$HardwareInventoryID'" -OperationTimeoutSec 30 | Remove-CimInstance
            Start-Sleep -s 5
            #Following errors, so using invoke-command instead
            #Invoke-cimmethod -ComputerName $Computername -Namespace 'root\CCM' -ClassName 'SMS_Client' -MethodName 'TriggerSchedule' -Arguments @{sScheduleID=$HardwareInventoryID}
            Invoke-command -ComputerName $Computername { Invoke-cimmethod  -Namespace 'root\CCM' -ClassName 'SMS_Client' -MethodName 'TriggerSchedule' -Arguments @{sScheduleID=$using:HardwareInventoryID} -OperationTimeoutSec 30 }
            }
        }
    End
        {
        }

}

You will note, all it is doing is removing an existing CIMInstance , effectively , the reset, sleeping for 5 secs then invoking the usual hardware inventory cycle.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.