Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Hey PowerShell Guy !, How Can I Retrieve All the Values in a Registry Key?

Today's Hey Scripting Guy ! column , How Can I Retrieve All the Values in a Registry Key? , Shows a 38 line VbScript to get the Values in a registry key.

In a PowerShell console it just takes this simple line to do the same :

 get-ItemProperty 'hkcu:\Software\Microsoft\Internet Explorer\Main'

The big difference in this case is that in the VbScript version the script has to handle all the parsing itself, as with the PowerShell command shown above , the parser does all the hard work for us, you can see below as we look at some array Properties in more detail, that the Parser did "understand" them and converted them to for us on-the-fly :

PoSH> (get-ItemProperty 'hkcu:\Software\Microsoft\Internet Explorer\Main').Do404Search
1
0
0
0
PoSH > (get-ItemProperty 'hkcu:\Software\Microsoft\Internet Explorer\Main').Window_Placement | get-member


   TypeName: System.Byte

Name        MemberType Definition
----        ---------- ----------
CompareTo   Method     System.Int32 CompareTo(Object value), System.Int32 CompareTo(Byte value)
Equals      Method     System.Boolean Equals(Object obj), System.Boolean Equals(Byte obj)
GetHashCode Method     System.Int32 GetHashCode()
GetType     Method     System.Type GetType()
GetTypeCode Method     System.TypeCode GetTypeCode()
ToString    Method     System.String ToString(), System.String ToString(String format), System.String ToString(IForm...
    

 And when you are in the right location you can replace the complete Vbscript by 3 Characters in the PowerShell console ;-)

PS HKCU:\Software\Microsoft\Internet Explorer\Main> gp .


Disable Script Debugger            : no
Anchor Underline                   : yes
Cache_Update_Frequency             : Once_Per_Session
Display Inline Images              : yes
Do404Search                        : {1, 0, 0, 0}
Local Page                         : C:\Windows\system32\blank.htm
 

... ...

 

So also when you don't want no stinkin' scripts, PowerShell is the Shell for you ;-)   

Enjoy,

Greetings /\/\o\/\/

 

Published Tuesday, April 08, 2008 1:10 PM by MoW
Filed under: ,

Comments

# re: Hey PowerShell Guy !, How Can I Retrieve All the Values in a Registry Key?

Marc, you should send these to Greg and Jean, and they'll be happy to publish them. I was providing the PowerShell version of their VB scripts for a while and got too busy. Let me know if you need contact info.

Thanks,

June

Thursday, April 17, 2008 1:46 AM by JuneB

# re: Hey PowerShell Guy !, How Can I Retrieve All the Values in a Registry Key?

Hi June,

Thanks for the comment, I have there contact info and will meet them next week at the MMS, and actualy we talked about that in Barcelona,( see http://thepowershellguy.com/blogs/posh/archive/2007/12/14/hey-powershell-guy-how-can-i-retrieve-time-zone-information-for-a-computer.aspx )

I started again after that ;-)

keep up the good work on the PowerShell documentation

Greetings /\/\o\/\/

Thursday, April 17, 2008 8:50 PM by MoW

# It’s Not About Backup, It’s About Sync

In the last year or so, there has been a wave of activity in the storage service space.  Companies

Friday, May 09, 2008 10:10 AM by HaveYouSeenMyStapler.NET - Viral Tarpara's Blog
Anonymous comments are disabled