Can anyone help me pull the value of a registry key and place it into a variable in PowerShell? So far I have used
Get-ItemProperty and reg query and although both will pull the value, both also add extra text. I need just the string text from the registry key and ONLY the string text from the key. I'm sure I could create a function to strip off the extra text but if something changes (i.e. reg key name) it might affect this.
Alan AndersonAlan Anderson
8 Answers
I've never liked how this was provider was implemented like this : /
Basically, it makes every registry value a
PSCustomObject object with PsPath , PsParentPath , PsChildname , PSDrive and PSProvider properties and then a property for its actual value. So even though you asked for the item by name, to get its value you have to use the name once more.
Andy ArismendiAndy Arismendi
NONE of these answers work for situations where the value name contains spaces, dots, or other characters that are reserved in PowerShell. In that case you have to wrap the name in double quotes as per http://blog.danskingdom.com/accessing-powershell-variables-with-periods-in-their-name/ - for example:
If you want to access any of the 14.0, 12.0, 11.0, 15.0 values, the solution from the accepted answer will not work - you will get no output:
What does work is quoting the value name, which you should probably be doing anyway for safety:
Thus, the accepted answer should be modified as such:
This works in PowerShell 2.0 through 5.0 (although you should probably be using
Get-ItemPropertyValue in v5).
Ian KempIan Kemp
Note: All solutions below bypass the problem described in Ian Kemp's's answer - the need to use explicit quoting for certain value names when used as property names; e.g.,
.'15.0' - because the value names are passed as parameters and property access happens via a variable; e.g., .$ValueName
Harry Martyrossian mentions in a comment on his own answer that the
Get-ItemPropertyValue cmdlet was introduced in Powershell v5, which solves the problem:
Alternatives for PowerShell v4-:
Here's an attempt to retain the efficiency while eliminating the need for repetition of the value name, which, however, is still a little cumbersome:
By using a script block, the value name can be passed in once as a parameter, and the parameter variable (
$args ) can then simply be used twice inside the block.
Alternatively, a simple helper function can ease the pain:
mklement0mklement0
I'm not sure if this has been changed, or if it has something to do with which version of PS you're using, but using Andy's example, I can remove the -Name parameter and I still get the value of the reg item:
M Jeremy CarterM Jeremy Carter
![]()
Well you need to be specific here. As far as I know, the key in a registry is a 'folder' of properties. So did you mean get the value of a property? If so, try something like this:
First we get an object containing the property we need with
Get-ItemProperty and then we get the value of for the property we need from that object. That will return the value of the property as a string. The example above gives you the PS version for 'legacy'/compatibility-mdoe powershell (1.0 or 2.0).
Frode F.Frode F.
Following code will enumerate all values for a certain Registry key, will sort them and will return value name : value pairs separated by colon (:):
Like this:
DbgJITDebugLaunchSetting : 16
DbgManagedDebugger : 'C:Windowssystem32vsjitdebugger.exe' PID %d APPDOM %d EXTEXT '%s' EVTHDL %d
InstallRoot : C:WindowsMicrosoft.NETFramework
Harry MartyrossianHarry Martyrossian
Given a key
SQL with two properties: Fifa 16 download pc free torrent.
I'd grab the 'MSSQLSERVER' one with the following in-cases where I wasn't sure what the property name was going to be to use dot-notation:
AdamAdam
If you create an object, you get a more readable output and also gain an object with properties you can access:
Sample output:InstallRoot : C:WindowsMicrosoft.NETFramework
And the object: $obj.InstallRoot = C:WindowsMicrosoft.NETFramework
The truth of the matter is this is way more complicated than it needs to be. Here is a much better example, and much simpler:
Windows Registry Location Xp
$objReg is now a custom object where each registry entry is a property name. You can view the formatted list via:
And you have access to the object itself:
Steve FellwockSteve Fellwock
Not the answer you're looking for? Browse other questions tagged variablespowershellregistrykey or ask your own question.
I have legitimate copies of Visual Studio 2008 installed on several computers, each with different license keys. I cannot remember what key was used on each install.
Where in the registry can I find what license key was used for that PC's Visual Studio 2008 installation?
I would imagine that it is in the registry somewhere.
spongspong
5 Answers
just run your computer and then type the word 'regedit'you'll find the four basic HKLM but i thin k just use this :
HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio9.0Registration2000.0x0000PIDKEY on my PC. not sure but just try because some of this working.
If you are using Win7, then try HKLMSoftwareWow6432NodeMicrosoftVisualStudio9.0Registration2000.0x0000PIDKEY
Community♦
Jorenda TabocoJorenda Taboco
A couple of options listed here:
Thea studio crack. Magical Jelly is the best product key finder for Windows. It’s free and portable, hence you can use it without installation or modifying the Windows registry. It can be used to extract the product keys of paid software like Microsoft Office, Microsoft Visual Studio, Adobe Photoshop etc.
and
WinkeyFinder is another great program to find the CD keys of installed software as well as the operating system. You can use this program to
ShevekShevek
Free pokemon ash gray download. You could try ProduKey from NirSoft. Its an app for listing Microsoft licence keys, however I don't think it'll work if your copy of Visual Studio was pre-pidded, i.e. it came from say an MSDN account.
PaukPauk
If you go into
regedit and browse to the following path: HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio9.0Registration .
The Product Key can be found in the
ProductID Registry Key.
Hope that helps!
Onion-KnightOnion-Knight
I've had positive experiences with Belarc Advisor http://www.belarc.com/Programs/advisor.exe. It gives out a neat list of software installed on your pc with Keys and I generally archive this on a secure cloud so even if My pc crashes, I can still get a registered copy of all the software installed.
Today its even possible to have the entire image of your installation archived so that You get a clean PC with the set of licenses refreshed on installed anytime you want one!
DL NarasimhanDL Narasimhan
Not the answer you're looking for? Browse other questions tagged windows-registryvisual-studio-2008license-key or ask your own question.Hi,I'm just in the process of writing an installer. I want the installer to figure out where the users VSTPlugins directory is, and offer that as the default place to install to. I read on the VSTPlugins list that
HKEY_LOCAL_MACHINESoftwareVST is the key. The value is a REG_SZ called VSTPluginsPath,
with the string being the complete path of the folder. Fl Studio Reg Key Location![]() Also, I'm planning to use the opensource installer NSIS http://nsis.sourceforge.net/home/ which looks good. I don't suppose anyone else has used this, and would care to share their installer .nsi file, would they? Thanks Ben Comments are closed.
|