KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The method for getting a value in a registry key from PowerShell is: Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir However, that command returns some extra properties I don't usually want: CommonFilesDir : C:\Program Files\Common Files PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows PSChildName : CurrentVersion PSDrive : HKLM PSProvider : Microsoft.PowerShell.Core\Registry I just want the actual value, a string in this case. To do that I have to use the more verbose: $commonFilesDir = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir).CommonFilesDir Other than writing my own alias, is there a way of not writing the property name twice and getting a string ? I could run the following command, but it returns a PSObject: Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion | Select CommonFilesDir
Tags (comma-separated)
Save Edits
Cancel