PowerShell and StdRegProv

i have never used the class stdregprov, however when i do get-wmiobject
-list , on my computer there is no class by that name, so maybe for
some reason its not installed also on your computer..
if you do get-wmiobject -list , you'll see a number of registry classes
as you are using . as the computername, and just using your own
computer, you can use the powershell registry provider i.,e

dir HKLM:\SOFTWARE

or

CD HKCU:\
dir

and interact with the registry in a similar manner you do with a
filesystem.

T wrote:
> Any idea why this returns an empty collection:
> $colItems = get-wmiobject -class "StdRegProv" -namespace "root\default"
> -computername "."
>
> This is from:
> http://www.microsoft.com/technet/scriptcenter/topics/msh/mshandwmi.mspx
>
> I'm going to assume what was posted is wrong. Can you please post the
> correct command.
>
> Thanks
>
> T
 

My Computer

from that help, the computer you are connecting to see the registry has
to be a server as per:


Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000
Server, or Windows NT Server 4.0 SP4 and later.
 

My Computer

B

Brian McDermott

You can find the StdRegProv on all Windows systems desktop or not. (As long
as they have WMI).


<[email protected]> wrote in message
news:[email protected]
> from that help, the computer you are connecting to see the registry has
> to be a server as per:
>
>
> Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000
> Server, or Windows NT Server 4.0 SP4 and later.
>
 

My Computer

B

Brian McDermott

If you would like one of these object use the following command.

$Reg = [WMIClass]"root\default:StdRegProv"

It is worth pointing out though, that this class has no instances. In fact
WMI does NOT represent registry keys or values as WMI objetcs. The way that
WMI accesses the registry is via the many methods associated with the
StdProv object. To see the many objects available try

$Reg | gm

after you have run the first line of course or there will be no $Reg to look
at.

As you can then see, there are methods for retrieving all the different data
types in the registry and can check registry permissions and also enumerate
key contents.

So yes, while the code on the web page is not syntactically incorrect, it
isn't useful in that context.

Yours,

BrianMcD


"T" <[email protected]> wrote in message
news:[email protected]
> Any idea why this returns an empty collection:
> $colItems = get-wmiobject -class "StdRegProv" -namespace "root\default"
> -computername "."
>
> This is from:
> http://www.microsoft.com/technet/scriptcenter/topics/msh/mshandwmi.mspx
>
> I'm going to assume what was posted is wrong. Can you please post the
> correct command.
>
> Thanks
>
> T
 

My Computer

D

dreeschkind

"[email protected]" wrote:

> >You can find the StdRegProv on all Windows systems desktop or not. (As long

> as they have WMI).
>
> interesting,
> hmm,
> i wonder why it doesn't show up in get-wmiobject -list
>


The default namespace of Get-WmiObject is "Root/cimv2", but StdRegProv is
located in the namespace "Root\default". Therefore, it won't be included in
the list.

PS> Get-WmiObject -namespace "Root\default" -list | ? {$_.name -match
"StdRegProv"}

--
greetings
dreeschkind
 

My Computer

A

Alex K. Angelopoulos [MVP]

Sorry about not looking through this yesterday; I ran into the problem
myself earlier and used another approach that works:

$Reg = Get-WmiObject -Namespace Root\Default -List | Where-Object
{$_.Name -eq "StdRegProv"}

That was prior to RC 2 release; quite obviously, using [WMIClass] as you do
is both more compact and more efficient. :)


"Brian McDermott" <[email protected]> wrote in message
news:[email protected]
> If you would like one of these object use the following command.
>
> $Reg = [WMIClass]"root\default:StdRegProv"
>
> It is worth pointing out though, that this class has no instances. In fact
> WMI does NOT represent registry keys or values as WMI objetcs. The way
> that WMI accesses the registry is via the many methods associated with the
> StdProv object. To see the many objects available try
 

My Computer

Here's a question for you...
I run this in powershell on my computer:
$regobj = [wmiclass]"root/default:stdregprov"
$regobj now contains a class instance of StdRegProv. Now I need to
pull keys for it. I tried this:
$regkeys = $regobj.enumKey(2147483649, "software/microsoft")
According to everything I can figure out, that should pull an array of
all the subkeys in HKLM/Software/Microsoft into $regkeys. But this is
what I get instead:
PS > $regkeys | foreach { write-output $_ }


__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 2
sNames :

Thoughts?

Alex K. Angelopoulos [MVP] wrote:
> Sorry about not looking through this yesterday; I ran into the problem
> myself earlier and used another approach that works:
>
> $Reg = Get-WmiObject -Namespace Root\Default -List | Where-Object
> {$_.Name -eq "StdRegProv"}
>
> That was prior to RC 2 release; quite obviously, using [WMIClass] as you do
> is both more compact and more efficient. :)
>
>
> "Brian McDermott" <[email protected]> wrote in message
> news:[email protected]
> > If you would like one of these object use the following command.
> >
> > $Reg = [WMIClass]"root\default:StdRegProv"
> >
> > It is worth pointing out though, that this class has no instances. In fact
> > WMI does NOT represent registry keys or values as WMI objetcs. The way
> > that WMI accesses the registry is via the many methods associated with the
> > StdProv object. To see the many objects available try
 

My Computer

A

Alex K. Angelopoulos [MVP]

Sure; here's what's happening. You want to take a look at the docs for
StdRegProv's EnumKey method, by the way:
http://msdn2.microsoft.com/en-us/library/aa390387.aspx

The variable you call $regkeys would be better named $resultcode. It's
non-zero, which indicates that your call failed. The problem is that you
didn't call EnumKey with the 3 parameters it requires.

<[email protected]> wrote in message
news:[email protected]
> Here's a question for you...
> I run this in powershell on my computer:
> $regobj = [wmiclass]"root/default:stdregprov"
> $regobj now contains a class instance of StdRegProv. Now I need to
> pull keys for it. I tried this:
> $regkeys = $regobj.enumKey(2147483649, "software/microsoft")
> According to everything I can figure out, that should pull an array of
> all the subkeys in HKLM/Software/Microsoft into $regkeys. But this is
> what I get instead:
> PS > $regkeys | foreach { write-output $_ }
>
>
> __GENUS : 2
> __CLASS : __PARAMETERS
> __SUPERCLASS :
> __DYNASTY : __PARAMETERS
> __RELPATH :
> __PROPERTY_COUNT : 2
> __DERIVATION : {}
> __SERVER :
> __NAMESPACE :
> __PATH :
> ReturnValue : 2
> sNames :
>
> Thoughts?
>
> Alex K. Angelopoulos [MVP] wrote:
>> Sorry about not looking through this yesterday; I ran into the problem
>> myself earlier and used another approach that works:
>>
>> $Reg = Get-WmiObject -Namespace Root\Default -List | Where-Object
>> {$_.Name -eq "StdRegProv"}
>>
>> That was prior to RC 2 release; quite obviously, using [WMIClass] as you
>> do
>> is both more compact and more efficient. :)
>>
>>
>> "Brian McDermott" <[email protected]> wrote in message
>> news:[email protected]
>> > If you would like one of these object use the following command.
>> >
>> > $Reg = [WMIClass]"root\default:StdRegProv"
>> >
>> > It is worth pointing out though, that this class has no instances. In
>> > fact
>> > WMI does NOT represent registry keys or values as WMI objetcs. The way
>> > that WMI accesses the registry is via the many methods associated with
>> > the
>> > StdProv object. To see the many objects available try

>
 

My Computer

G

gaurhoth

First of all, "software/microsoft" should be "software\microsoft" (back-slash).
Secondly, on your last line try:

PS > $regkeys | foreach { write-output $_.sNames }

<[email protected]> wrote in message news:[email protected]
> Here's a question for you...
> I run this in powershell on my computer:
> $regobj = [wmiclass]"root/default:stdregprov"
> $regobj now contains a class instance of StdRegProv. Now I need to
> pull keys for it. I tried this:
> $regkeys = $regobj.enumKey(2147483649, "software/microsoft")
> According to everything I can figure out, that should pull an array of
> all the subkeys in HKLM/Software/Microsoft into $regkeys. But this is
> what I get instead:
> PS > $regkeys | foreach { write-output $_ }
>
>
> __GENUS : 2
> __CLASS : __PARAMETERS
> __SUPERCLASS :
> __DYNASTY : __PARAMETERS
> __RELPATH :
> __PROPERTY_COUNT : 2
> __DERIVATION : {}
> __SERVER :
> __NAMESPACE :
> __PATH :
> ReturnValue : 2
> sNames :
>
> Thoughts?
>
> Alex K. Angelopoulos [MVP] wrote:
>> Sorry about not looking through this yesterday; I ran into the problem
>> myself earlier and used another approach that works:
>>
>> $Reg = Get-WmiObject -Namespace Root\Default -List | Where-Object
>> {$_.Name -eq "StdRegProv"}
>>
>> That was prior to RC 2 release; quite obviously, using [WMIClass] as you do
>> is both more compact and more efficient. :)
>>
>>
>> "Brian McDermott" <[email protected]> wrote in message
>> news:[email protected]
>> > If you would like one of these object use the following command.
>> >
>> > $Reg = [WMIClass]"root\default:StdRegProv"
>> >
>> > It is worth pointing out though, that this class has no instances. In fact
>> > WMI does NOT represent registry keys or values as WMI objetcs. The way
>> > that WMI accesses the registry is via the many methods associated with the
>> > StdProv object. To see the many objects available try

>
 

My Computer

Top