PowerShell for Windows Admins

May 12 2010   3:06PM GMT

WMI and the Registry

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

We can use WMI to access the registry on local and remote machines – if you remember back to VBScript it was the way to access the registry.

In PowerShell we have a couple of PowerShell drives available  through the provider

Name           Used (GB)     Free (GB) Provider      Root
—-           ———     ——— ——–      —-
HKCU                                   Registry      HKEY_CURRENT_USER
HKLM                                   Registry      HKEY_LOCAL_MACHINE

These only work with the local machine.  We can use PowerShell remoting to access the registry but if PowerShell isn’t installed we are back to WMI.

The class we need to use is StdRegprov

In Windows XP\2003 and earlier it is only found in the root\default namespace. In Windows Vista\2008 and above it is also found in the root\cimv2 namespace (which is the default namespace PowerShell uses). In order to access most machines we will work with the root\default instance. We need to use the [wmiclass] type accelerator

$reg = [wmiclass]\\.\root\default:StdRegprov

looking at $reg though get-member we see a lot of methods

CheckAccess
CreateKey
DeleteKey
DeleteValue
EnumKey
EnumValues
GetBinaryValue
GetDWORDValue
GetExpandedStringValue
GetMultiStringValue
GetQWORDValue
GetSecurityDescriptor
GetStringValue
SetBinaryValue
SetDWORDValue
SetExpandedStringValue
SetMultiStringValue
SetQWORDValue
SetSecurityDescriptor
SetStringValue

We will start looking at these next time

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: