Skip to content

Instantly share code, notes, and snippets.

@kayasax
Last active December 19, 2016 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayasax/18c0669589c6f2bfd90e to your computer and use it in GitHub Desktop.
Save kayasax/18c0669589c6f2bfd90e to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment