Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

WMI access to registry

Closed Thread
 
Thread Tools Display Modes
Old 11-09-2006   #1 (permalink)
Jonathan P
Guest


 

WMI access to registry

I'm having a lot of trouble figuring out how to use WMI to access the Windows
Registry. The only command I can see that does it is something like this...
(get-wmiobject StdRegProv -namespace
"root/default").Enumkey("HKEY_Local_machine", "Software/Microsoft", $regobj)
But this command returns the following error:
You cannot call a method on a null-valued expression.
At line:1 char:61
+ (get-wmiobject stdregprov -namespace "root/default").EnumKey( <<<<
"HKEY_LOCAL_MACHINE", "software\microsoft", $regobj)
Any ideas?
Old 11-11-2006   #2 (permalink)
gaurhoth
Guest


 

Re: WMI access to registry

I am not sure about using the get-wmiobject cmdlet, but you can use [WMICLASS]/ManagementClass as shown below:

[long]$HKLM = 2147483650
$c = [WMICLASS]"root\default:stdregprov"
$g = $c.enumkey($HKLM,"software\microsoft")
$g | % { $_.sNames }

Even easier... use the builtin Powershell Provider to navigate the registry of a local PC:

PS HKLM:\> cd HKLM:\software\microsoft
PS HKLM:\software\microsoft> ls


Hive: Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\microsoft

SKC VC Name Property
--- -- ---- --------
4 0 .NETCompactFramework {}
4 4 .NETFramework {InstallRoot, sdkInstallRootv2.0, DbgManagedDebugger, DbgJITDebugLaunchSetting}
6 2 Active Setup {DisableRepair, JITSetupPage}
1 0 ActiveSync {}
3 0 AD7Metrics {}
1 0 ADs {}
8 0 Advanced INF Setup {}



"Jonathan P" <JonathanP@discussions.microsoft.com> wrote in message news:F45E9B64-0D1A-455D-B1EE-33A96DB51E37@microsoft.com...
> I'm having a lot of trouble figuring out how to use WMI to access the Windows
> Registry. The only command I can see that does it is something like this...
> (get-wmiobject StdRegProv -namespace
> "root/default").Enumkey("HKEY_Local_machine", "Software/Microsoft", $regobj)
> But this command returns the following error:
> You cannot call a method on a null-valued expression.
> At line:1 char:61
> + (get-wmiobject stdregprov -namespace "root/default").EnumKey( <<<<
> "HKEY_LOCAL_MACHINE", "software\microsoft", $regobj)
> Any ideas?

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access the method of a registry key Seeker PowerShell 1 4 Weeks Ago 12:41 PM
Access to Registry pgwolfe Windows Updates 0 06-20-2008 09:11 AM
When standard users access Vista registry remotely, Access Denied Gayle Vista account administration 1 10-10-2007 11:48 AM
Registry Access Wayne Vista General 0 01-29-2007 10:43 AM
Registry Access Tim Gee Vista security 6 11-27-2006 06:10 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50