Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 help and support Forum Windows 8 Forum Vista Tutorials

Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroup Archive > Misc Newsgroups > PowerShell

Vista - Powershell remote registry access via WMI


 
 
07-07-2006   #1 (permalink)
Greg Borota


 

Re: Powershell remote registry access via WMI

I you don't want "legal" problems you should probably change your name
quickly.....



"Microsoft" <> wrote in message
news:OFVRsxgoGHA.4828@TK2MSFTNGP04.phx.gbl...
> I'm having trouble getting to a remote registry via wmi using Powershell
> version v2.0.50727. I tried the example from 'From
> http://www.microsoft.com/technet/scr...mshandwmi.mspx
> and
> get the error below:
>
> PS C:\> $colItems = get-wmiobject -class "StdRegProv" -namespace
> "root\default" -computername "myserver"
> PS C:\> $colItems.EnumValues(0x80000002,"software\microsoft\windows
> nt\currentversion",$Values,$Types)
> You cannot call a method on a null-valued expression.
> At line:1 char:21
> + $colItems.EnumValues( <<<< 0x80000002,"software\microsoft\windows
> nt\currentversion",$Values,$Types)
>
> Using the .Net function [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey
> works well as a work-around but I'm wondering what I'm doing wrong with
> the
> WMI call above.
> f
>
>



My System SpecsSystem Spec
07-07-2006   #2 (permalink)
Microsoft


 

Powershell remote registry access via WMI

I'm having trouble getting to a remote registry via wmi using Powershell
version v2.0.50727. I tried the example from 'From
http://www.microsoft.com/technet/scr...mshandwmi.mspx and
get the error below:

PS C:\> $colItems = get-wmiobject -class "StdRegProv" -namespace
"root\default" -computername "myserver"
PS C:\> $colItems.EnumValues(0x80000002,"software\microsoft\windows
nt\currentversion",$Values,$Types)
You cannot call a method on a null-valued expression.
At line:1 char:21
+ $colItems.EnumValues( <<<< 0x80000002,"software\microsoft\windows
nt\currentversion",$Values,$Types)

Using the .Net function [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey
works well as a work-around but I'm wondering what I'm doing wrong with the
WMI call above.
f


My System SpecsSystem Spec
07-07-2006   #3 (permalink)
Jeffrey Snover [MSFT]


 

Re: Powershell remote registry access via WMI

Use WBEMTEST or WMIC to see if you can see any instances. I don't see any
on my machine.

--
Jeffrey Snover [MSFT]
Windows PowerShell Architect
Microsoft Corporation
This posting is provided "AS IS" with no warranties, no confers rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx

"Microsoft" <benherman@hotmali.com> wrote in message
news:OFVRsxgoGHA.4828@TK2MSFTNGP04.phx.gbl...
> I'm having trouble getting to a remote registry via wmi using Powershell
> version v2.0.50727. I tried the example from 'From
> http://www.microsoft.com/technet/scr...mshandwmi.mspx
> and
> get the error below:
>
> PS C:\> $colItems = get-wmiobject -class "StdRegProv" -namespace
> "root\default" -computername "myserver"
> PS C:\> $colItems.EnumValues(0x80000002,"software\microsoft\windows
> nt\currentversion",$Values,$Types)
> You cannot call a method on a null-valued expression.
> At line:1 char:21
> + $colItems.EnumValues( <<<< 0x80000002,"software\microsoft\windows
> nt\currentversion",$Values,$Types)
>
> Using the .Net function [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey
> works well as a work-around but I'm wondering what I'm doing wrong with
> the
> WMI call above.
> f
>
>



My System SpecsSystem Spec
07-09-2006   #4 (permalink)
Alex K. Angelopoulos [MVP]


 

Re: Powershell remote registry access via WMI

> "Microsoft" <benherman@hotmali.com> wrote in message
> news:OFVRsxgoGHA.4828@TK2MSFTNGP04.phx.gbl...
>> I'm having trouble getting to a remote registry via wmi using Powershell
>> version v2.0.50727. I tried the example from 'From
>> http://www.microsoft.com/technet/scr...mshandwmi.mspx
>> and
>> get the error below:


"Jeffrey Snover [MSFT]" <jsnover@microsoft.com> wrote in message
news:%23ehoS1joGHA.5104@TK2MSFTNGP04.phx.gbl...
> Use WBEMTEST or WMIC to see if you can see any instances. I don't see any
> on my machine.


Yes. Of course, with the -List usage we can access the class itself rather
than instances. Using the local system for demonstration purposes:

$reg = Get-WmiObject -List -Namespace root\default -ComputerName . |
Where-Object {$_.Name -eq "StdRegProv"}

Unfortunately I've had serious issues trying to invoke methods on the
resulting object. :|



My System SpecsSystem Spec
07-09-2006   #5 (permalink)
Jeffrey Snover [MSFT]


 

Re: Powershell remote registry access via WMI

> Unfortunately I've had serious issues trying to invoke methods on the
> resulting object. :|

This improves in RC2:

http://blogs.msdn.com/powershell/arc...26/647038.aspx

PS> $reg = Get-WmiObject -List -Namespace root\default -ComputerName . |
>> Where-Object {$_.Name -eq "StdRegProv"}
>>

PS> $reg.enumkey(2147483650,"software")


__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
sNames : {Adobe, Alps, ALPS Electric Co., Ltd., Apple Computer,
Inc....}

--
Jeffrey Snover [MSFT]
Windows PowerShell Architect
Microsoft Corporation
This posting is provided "AS IS" with no warranties, no confers rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx


My System SpecsSystem Spec
07-10-2006   #6 (permalink)
Alex K. Angelopoulos [MVP]


 

Re: Powershell remote registry access via WMI


"Jeffrey Snover [MSFT]" <> wrote in message
news:u2LIjU3oGHA.4424@TK2MSFTNGP05.phx.gbl...
>> Unfortunately I've had serious issues trying to invoke methods on the
>> resulting object. :|

> This improves in RC2:
>
> http://blogs.msdn.com/powershell/arc...26/647038.aspx


I saw that.

It will definitely help. It's also possible right now to use PSBase and
directly invoke EnumKeys and so on as normal methods; the primary problems
I've had are with the need for uint32-typed values for the hive constant,
and the fact that one of the parameters needs to be a ref array. That's more
of a general WMI "design safety" issue I think...

> PS> $reg = Get-WmiObject -List -Namespace root\default -ComputerName . |
>>> Where-Object {$_.Name -eq "StdRegProv"}
>>>

> PS> $reg.enumkey(2147483650,"software")
>
>
> __GENUS : 2
> __CLASS : __PARAMETERS
> __SUPERCLASS :
> __DYNASTY : __PARAMETERS
> __RELPATH :
> __PROPERTY_COUNT : 2
> __DERIVATION : {}
> __SERVER :
> __NAMESPACE :
> __PATH :
> ReturnValue : 0
> sNames : {Adobe, Alps, ALPS Electric Co., Ltd., Apple Computer,
> Inc....}
>
> --
> Jeffrey Snover [MSFT]
> Windows PowerShell Architect
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, no confers rights.
> Visit the Windows PowerShell Team blog at:
> http://blogs.msdn.com/PowerShell
> Visit the Windows PowerShell ScriptCenter at:
> http://www.microsoft.com/technet/scr.../hubs/msh.mspx
>
>



My System SpecsSystem Spec
07-10-2006   #7 (permalink)
=?Utf-8?B?QmVu?=


 

Re: Powershell remote registry access via WMI

Thank you for the responses. I'll try this as soon as I can get my sweaty
little mits on RC2. (And I'll fix my newsreader to show my name).

Ben Herman

"Alex K. Angelopoulos [MVP]" wrote:

>
> "Jeffrey Snover [MSFT]" <> wrote in message
> news:u2LIjU3oGHA.4424@TK2MSFTNGP05.phx.gbl...
> >> Unfortunately I've had serious issues trying to invoke methods on the
> >> resulting object. :|

> > This improves in RC2:
> >
> > http://blogs.msdn.com/powershell/arc...26/647038.aspx

>
> I saw that.
>
> It will definitely help. It's also possible right now to use PSBase and
> directly invoke EnumKeys and so on as normal methods; the primary problems
> I've had are with the need for uint32-typed values for the hive constant,
> and the fact that one of the parameters needs to be a ref array. That's more
> of a general WMI "design safety" issue I think...
>
> > PS> $reg = Get-WmiObject -List -Namespace root\default -ComputerName . |
> >>> Where-Object {$_.Name -eq "StdRegProv"}
> >>>

> > PS> $reg.enumkey(2147483650,"software")
> >
> >
> > __GENUS : 2
> > __CLASS : __PARAMETERS
> > __SUPERCLASS :
> > __DYNASTY : __PARAMETERS
> > __RELPATH :
> > __PROPERTY_COUNT : 2
> > __DERIVATION : {}
> > __SERVER :
> > __NAMESPACE :
> > __PATH :
> > ReturnValue : 0
> > sNames : {Adobe, Alps, ALPS Electric Co., Ltd., Apple Computer,
> > Inc....}
> >
> > --
> > Jeffrey Snover [MSFT]
> > Windows PowerShell Architect
> > Microsoft Corporation
> > This posting is provided "AS IS" with no warranties, no confers rights.
> > Visit the Windows PowerShell Team blog at:
> > http://blogs.msdn.com/PowerShell
> > Visit the Windows PowerShell ScriptCenter at:
> > http://www.microsoft.com/technet/scr.../hubs/msh.mspx
> >
> >

>
>
>

My System SpecsSystem Spec
 

Powershell remote registry access via WMI problems?



Thread Tools


Similar topics to: Powershell remote registry access via WMI
Thread Forum
Remote registry key recurse in powershell PowerShell
Remote registry access PowerShell
PowerShell and Registry Access Software
Remote Registry Access PowerShell
Remote registry access in Powershell PowerShell


Vista Forums 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 Ltd

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