Get windows registry value from remote computer

If you manage a large domain network. Your manager may ask you for information about the applications that are installed on the systems at certain intervals. This program can be more important for this company if it is an expensive application.

In the following example, we try to determine which machines have visual studio by collecting registry key information

Goal: Read registry value from remote machine

Source: Read remote machine names from .txt file

Result: Get results in .csv format

# Script start here

# get machinenames from .txt file makine isimlerini txt belgesinden al

$computername = Get-Content -path “c:\scripts\pclists.txt”


# test machines / makineyi kontrol et

if (test-connection -computername $computername -Count 2)



foreach ($pc in $computername)


# reset variables / değişkenleri sıfırla

$loggedon = “”

$reg = “”

$LMPS = “”

$LMPS2 = “”

$LMPS3 = “”

$regkey = “”

$regkey2 = “”

$regkey3 = “”

$MakineDurumu = “”


# test machine / makineyi kontrol et

$MakineDurumu=Test-Connection -computername $pc -Count 2 -Quiet

if ($MakineDurumu -eq $False) {

Write-Host $pc “Can not access the machine”

# if there is no access to the machine, write “Can not access the machine” in the first serial column / makineye erişim yok ise ilk serial kolonuna “Makineye erişilemiyor” yaz

$LMPS = “Can not access the machine”




# If accessed to the machine, write “machine accessed” and continue / makineye erişilerse $pc “Makinesine erişildi” yaz ve devam et

Write-Host $pc “machine accessed”

# check the machine name / makine adını sorgula

$loggedon =@(Get-WmiObject -ComputerName $pc -Namespace root\cimv2 -Class Win32_ComputerSystem)[0].UserName;

# Check for Visual Studio 2010 reg key / Visual Studio 2010 reg key var mı kontrol et


$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $pc)

$regkey = $reg.OpenSubkey(‘SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Registration\2000.0×0000’)

$LMPS = $regkey.GetValue(‘PIDKEY’)


# Check for Visual Studio 2012 reg key / Visual Studio 2012 reg key var mı kontrol et


$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $pc)

$regkey2 = $reg.OpenSubkey(‘SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\Registration\2000.0×0000’)

$LMPS2 = $regkey2.GetValue(‘PIDKEY’)


# Check for Visual Studio 2013 reg key / Visual Studio 2013 reg key var mı kontrol et


$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’, $pc)

$regkey3 = $reg.OpenSubkey(‘SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\Registration\2000.0×0000’)

$LMPS3 = $regkey3.GetValue(‘PIDKEY’)



# add all incoming data to .csv file / gelen tüm veriyi .csv dosyasına ekle

Add-Content “c:\scripts\VS_20141105.csv” “$pc;$LMPS;$LMPS2;$LMPS3”



# Script end here



Comment here