Description
In this article, I am going to write Powershell Script examples to read registry value using Powershell Script’s Get-ItemProperty Cmdlet, read registry value by WMI Class StdRegProv in Powershell and read remote registry value by OpenRemoteBaseKey and WMI.
Summary
- Read Registry Value using Get-ItemProperty Cmdlet
- Read Registry Value using WMI Class StdRegProv
- Read Remote Registry Value by OpenRemoteBaseKey
- Read Remote Registry Value by WMI Class StdRegProv
Read Registry Value using Get-ItemProperty Cmdlet in Powershell
You can read registry values from specific registry key by using following Powershell command:
Get-ItemProperty "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstallVLC media player"
Powershell Script to Read Registry Value using WMI Class StdRegProv
You can read registry value using WMI Class StdRegProv in Powershell by following script:
$HKLM = [UInt32] "0x80000002" $registry = [WMIClass] ".rootdefault:StdRegProv" $valueName = "DisplayVersion" $registry.GetStringValue($HKLM, "SOFTWAREMicrosoftWindowsCurrentVersionUninstallVLC media player", $valueName)
Read Remote Registry Value in Powershell by OpenRemoteBaseKey
Use the below script to read registry value from remote machine by using Powershell‘s OpenRemoteBaseKey. Replace the value for variable $computer with your own remote computer name.
$computer = "hp-pc" $w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$computer ) $keypath = 'SOFTWAREMicrosoftWindowsCurrentVersionUninstallVLC media player' $productKey = $w32reg.OpenSubKey($keypath) $productVersion = $productKey.GetValue('DisplayVersion') write-output $productVersion
Read Remote Registry Value in Powershell by WMI Class StdRegProv
Use the below script to read registry value from remote computer by using WMI Class StdRegProv in Powershell. Replace the value for variable $computer with your own remote computer name.
$HKLM = [UInt32] "0x80000002" $computer = "hp-pc" $registry = [WMIClass] "$computerrootdefault:StdRegProv" $valueName = "DisplayVersion" $registry.GetStringValue($HKLM, "SOFTWAREMicrosoftWindowsCurrentVersionUninstallVLC media player", $valueName)
Thanks,
Morgan
Software Developer
Thanks!
Wasted hours on other posts. This was clear, concise and just works. Thank you!
WMI Option not work.
Your WMI option from a remote machine never uses the remote machine name defined.