kayasax
9/17/2015 - 1:05 PM

Working in the registry with powershell. Link : https://technet.microsoft.com/fr-fr/library/dd315394.aspx

Working in the registry with powershell. Link : https://technet.microsoft.com/fr-fr/library/dd315394.aspx

# for remote access use this
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer1)
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Veritas\\NetBackup\\CurrentVersion")
$NetbackupVersion1 = $RegKey.GetValue("PackageVersion")
#If you want to set a value, use 
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Veritas\\NetBackup\\CurrentVersio‌​n",$true) 
then regkey.setvalue("Name","Myvalue")

# to access a registry path without a psdrive (hklm: etc.) use the registry provider :
cd registry::\HKEY_USERS

#view values of a registry key
Get-ItemProperty 'registry::\hkey_users\<userSID>\Software\Microsoft\Windows\CurrentVersion\Internet Settings\' 

#get details for a specific value 
$regpath='registry::\hkey_users\<userSID>\Software\Microsoft\Windows\CurrentVersion\Internet Settings\' 
get-itemproperty $regpath -name proxyserver

#or just get the value
get-itemproperty $regpath | select -expand proxyserver 

#create a new value
New-ItemProperty -Path $regpath -Name PowerShellPath -PropertyType String -Value $PSHome

<#propertytype enumeration :
Binary (Données binaires)
DWord (Nombre UInt32 valide)
ExpandString (Chaîne pouvant contenir des variables d'environnement qui sont développées de manière dynamique)
MultiString (Chaîne multiligne)
String (Valeur de chaîne quelconque)
QWord (8 octets de données binaires)
#>

#remove a value
Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name PSHome