You have setup an application package and want to initiate a hardware inventory immediately after the software is installed. Here is a powershell script that will initiate the hardware inventory, verify it was initiated and return an error code 0 if initiated back to SCCM. This allows the hardware inventory to become an application with a return value to look for by injecting the script in as a custom script as the detection method.
You can download the script from here to inject into SCCM.
You can download the script from here to inject into SCCM.
Clear-Host
Set-Variable -Name a -Scope Global -Force
Set-Variable -Name SMSCli -Scope Global -Force
$SMSCli = [wmiclass] "root\ccm:SMS_Client"
$a = $SMSCli.TriggerSchedule("{00000000-0000-0000-0000-000000000001}")
If ($a.__PROPERTY_COUNT -eq 1) {
$SMSCli.Dispose
Remove-Variable -Name a -Scope Global -Force
Remove-Variable -Name SMSCli -Scope Global -Force
exit 0
} else {
$SMSCli.Dispose
Remove-Variable -Name a -Scope Global -Force
Remove-Variable -Name SMSCli -Scope Global -Force
exit 1
}
0 comments:
Post a Comment