header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Read Remote Registry Question
Last Post 03 Nov 2007 11:19 PM by RosarioM. 4 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
RosarioMUser is Offline
New Member
New Member
Posts:15
Avatar

--
31 Oct 2007 04:01 AM  

Why do we need to do this to use the Remote Registry object..

[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,MachineName)

And not something like this:

new-object Microsoft.win32.RegistryKey...

Similar to what we can do with system.windows.forms?

I believe it has to do with the fact that PowerShell does not have a provider for this object, but how can we tell which objects do and which do not?

Or am I doing something wrong?

Thanks!

bsonposhUser is Offline
Basic Member
Basic Member
Posts:393
Avatar

--
31 Oct 2007 05:29 AM  
It has nothing to do with powershell... its a .NET thing.

To do an open a remote key you need use the static method OpenRemoteBaseKey.

I dont know if you have the MSDN Library installed I would strongly recommend it.

If you look at Microsoft.win32.RegistryKey you will notice it does not have a constructor and therefore cannot be created directly. I found this to be common. Some classes are returned from methods on other objects.

In this specific case.. you must call a static method to create the object.

Understand? I don't know your background, but for admins this is a little foreign (it was for me.) If this doesnt help let me know.

More Info
http://msdn2.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx

I also wrote this a long time ago and it needs a rewrite, but it may be helpful
http://bsonposh.com/modules/wordpress/?p=10
Brandon Shell
----------------
Microsoft Powershell MVP
https://mvp.support.microsoft.com/profile/Brandon
Blog: http://www.bsonposh.com
RosarioMUser is Offline
New Member
New Member
Posts:15
Avatar

--
03 Nov 2007 03:55 PM  
Looking at the MSDN info, how do I tell that this particular class does not have a constructor?
bsonposhUser is Offline
Basic Member
Basic Member
Posts:393
Avatar

--
03 Nov 2007 04:55 PM  
Look at members... you will notice it does not have a contructor.

Here is an Example
http://msdn2.microsoft.com/en-us/library/system.directoryservices.directoryentry_members.aspx
Brandon Shell
----------------
Microsoft Powershell MVP
https://mvp.support.microsoft.com/profile/Brandon
Blog: http://www.bsonposh.com
RosarioMUser is Offline
New Member
New Member
Posts:15
Avatar

--
03 Nov 2007 11:19 PM  
Oh yeah, I see.. thanks for the info!



You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer