After working with Sherry, we got it working! The example below is for adding
driver info from win32_pnpsigneddriver into your own custom class. The user
profile pieces work just as well.
I was missing these two lines:
$newClass.Properties["DeviceName"].Qualifiers.Add("Key", $true)
$newClass.Properties["DeviceID"].Qualifiers.Add("Key", $true)
Full script
## Define new class name and date
$NewClassName = "Win32_PnpSignedDriver_Custom"
$Date = get-date
## Remove class if exists
Get-WmiObject $NewClassName | Remove-WmiObject $NewClassName
# Create new WMI class
$newClass = New-Object System.Management.ManagementClass ("root\cimv2",
[String]::Empty, $null);
$newClass["__CLASS"] = $NewClassName
## Create properties you want inventoried
$newClass.Qualifiers.Add("Static", $true)
$newClass.Properties.Add("DeviceClass", [System.Management.CimType]::String,
$false)
$newClass.Properties.Add("DeviceName", [System.Management.CimType]::String,
$false)
$newClass.Properties.Add("DriverDate", [System.Management.CimType]::DateTime,
$false)
$newClass.Properties.Add("DriverProviderName",
[System.Management.CimType]::String, $false)
$newClass.Properties.Add("DriverVersion", [System.Management.CimType]::String,
$false)
$newClass.Properties.Add("HardwareID", [System.Management.CimType]::String,
$false)
$newClass.Properties.Add("DeviceID", [System.Management.CimType]::String,
$false)
$newClass.Properties.Add("ScriptLastRan", [System.Management.CimType]::String,
$false)
$newClass.Properties["DeviceName"].Qualifiers.Add("Key", $true)
$newClass.Properties["DeviceID"].Qualifiers.Add("Key", $true)
$newClass.Put()
## Gather current driver information
Get-WmiObject win32_pnpsigneddriver -Property DeviceClass,
DeviceName,DriverDate,DriverProviderName,DriverVersion,HardwareID,DeviceID |
where{$_.DeviceClass -ne "VOLUMESNAPSHOT" -and $_.DeviceClass -ne
"LEGACYDRIVER"} |
ForEach-Object {
$_
## Set driver information in new class
Set-WmiInstance -Namespace root\cimv2 -class $NewClassName -argument @{
DeviceClass = $_.DeviceClass;
DeviceName = $_.DeviceName;
DriverDate = $_.DriverDate;
DriverProviderName = $_.DriverProviderName;
DriverVersion = $_.DriverVersion;
HardwareID = $_.HardwareID;
DeviceID = $_.DeviceID;
ScriptLastRan = $Date
}
}
Daniel Ratliff
From: [email protected] [mailto:[email protected]] On
Behalf Of Daniel Ratliff
Sent: Monday, August 31, 2015 3:57 PM
To: [email protected]
Subject: RE: [mssms] Inventory click-once applications?
Been fighting through this. Cant seem to get past the below error.
Set-WmiInstance : Attempt to put an instance with no defined key.
At line:1 char:1
+ Set-WmiInstance -Namespace root\cimv2 -class $NewClassName -argument @{
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WmiInstance],
ManagementException
+ FullyQualifiedErrorId :
SetWMIManagementException,Microsoft.PowerShell.Commands.SetWmiInstance
Found this fix online but doesn’t seem to work either:
http://powershell.org/wp/forums/topic/using-cim-to-create-a-shared-folder/
Still investigating…
Daniel Ratliff
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Daniel Ratliff
Sent: Wednesday, August 12, 2015 3:17 PM
To: [email protected]<mailto:[email protected]>
Subject: RE: [mssms] Inventory click-once applications?
Not sure about blog, but I know you sent it to me earlier this year. I guess
its time to give it a good test!
Thanks Sherry!
Daniel Ratliff
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Sherry Kissinger
Sent: Wednesday, August 12, 2015 3:03 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: [mssms] Inventory click-once applications?
Did I not blog the ConfigItem + Mof edit for per user installs? Maybe not... I
was just playing around. If you want to test it and confirm it works more than
on my 1, lonely, test box in my standalone lab...
Please let me know if it works (or needs work). It might not work as a config
Item.... the script might need to run as a package/program/advert "only when a
user is logged on" "with admin rights". I really didn't play that much with
it...
On Wednesday, August 12, 2015 1:46 PM, Daniel Ratliff
<[email protected]<mailto:[email protected]>> wrote:
Has anyone inventoried click-once applications before?
Looking online I know they usually show up in the uninstall key but in HKCU not
HKLM.
Is that pretty much it? Just inventory the user profile installed software?
Daniel Ratliff
Technology Architect | Client Innovation Technologies
Humana
123 E. Main St. | Louisville, KY, 40202
T 502.476.9976
[email protected]<mailto:[email protected]>
The information transmitted is intended only for the person or entity to which
it is addressed
and may contain CONFIDENTIAL material. If you receive this material/information
in error,
please contact the sender and delete or destroy the material/information.
The information transmitted is intended only for the person or entity to which
it is addressed
and may contain CONFIDENTIAL material. If you receive this material/information
in error,
please contact the sender and delete or destroy the material/information.
The information transmitted is intended only for the person or entity to which
it is addressed
and may contain CONFIDENTIAL material. If you receive this material/information
in error,
please contact the sender and delete or destroy the material/information.
The information transmitted is intended only for the person or entity to which
it is addressed
and may contain CONFIDENTIAL material. If you receive this
material/information in error,
please contact the sender and delete or destroy the material/information.