November 2nd, 2010
I have to gather some information like serialnumber, installed office 2007 productkey from remote machines.
The serialnumber is no problem. All remote-machines are Dell-computers and the serialnumber is accessible like this:
(Get-WmiObject -class Win32_SystemEnclosure -Computer $remotecomputer -credential $cred).SerialNumber
But the Office-Key was a bigger problem. I found a very good script at powershell.com but there’s one problem:
When I use the type-accelerator [WMIClass] it’s not possible to provide credentials for the remote-machine.
Then I thought “ok, I’ll take Get-WmiObject to receive this object”, but [WMIClass]“\\$computername\root\default:StdRegProv” doesn’t return a Wmi-Object but a Wmi-Class! For example, I created a Variable which contains the result of the [wmiclass]-command and one which contains the result from gwmi querying “win32_systemenclosure”:

I started a long google-journey in order to find a solution for this (to be honest: I haven’t worked in the registry with PowerShell and WMI yet and didn’t want to re-write the script from powershell.com).
I finally (and luckily) found a hint here. The Microsoft-Team improved WMI-Support in PowerShell V2.
To get the same result like [wmiclass]“\\$computer\root\default:stdregprov” but with explicit given credentials it’s now possible to do this:
$wmi = get-wmiobject -list -namespace root\default -computername $computer -credential domain\user | where-object { $_.name -eq "StdRegProv" }
That return’s the WMI-class StdRegProv in namespace root\default like the WMI-type-accellerator-command.
Now I only have to replace the line which contains [wmiclass]“\\$computer\root\default:stdregprov” with this solution and I can use the script without further changes.
I have to gather some information like serialnumber, installed office 2007 productkey from remote machines.
The serialnumber is no problem. All remote-machines are Dell-computers and the serialnumber is accessible like this:
(Get-WmiObject -class Win32_SystemEnclosure -Computer $remotecomputer -credential $cred).SerialNumber
But the Office-Key was a bigger problem. I found a very good script at powershell.com but there's one problem:
When ...
Tags: credential, Powershell, registry, remote, type-accelerator, wmi