banner



How To Get The Vaue Of A Perfection Registering Bank?

The Registry Editor (regedit.exe) and the reg.exe command-line utility aren't the only tools to access and manage the registry in Windows. PowerShell provides a large number of tools for the administrator to interact with the registry. Using PowerShell, you can create, modify, or delete a registry cardinal/parameters, search for the value, and connect to the registry on a remote figurer.

Contents:

  • Navigate the Windows Registry Like a File System with PowerShell
  • Get a Registry Parameter Value via PowerShell
  • Changing Registry Value with PowerShell
  • How to Create a New Register Fundamental or Parameter with PowerShell?
  • Deleting a Registry Key or Parameter
  • How to Rename a Registry Cardinal or a Parameter?
  • Search Registry for Keyword Using PowerShell
  • Setting Registry Central Permissions with PowerShell
  • Getting a Registry Value from a Remote Computer via PowerShell

Navigate the Windows Registry Similar a File Organization with PowerShell

Working with the registry in PowerShell is similar to working with common files on a local disk. The main difference is that in this concept the registry keys are analogous to files, and the registry parameters are the backdrop of these files.

Display the list of available drives on your computer:

get-psdrive

get-psdrive

Annotation that among the drives (with drive letters assigned) there are special devices available through the Registry provider – HKCU (HKEY_CURRENT_USER) and HKLM (HKEY_LOCAL_MACHINE). You can scan the registry tree the aforementioned way you navigate your drives. HKLM:\ and HKCU:\ are used to access a specific registry hive.

cd HKLM:\
Dir -ErrorAction SilentlyContinue

browse windows registry with powershell

Those, you tin access the registry key and their parameters using the aforementioned PowerShell cmdlets that you use to manage files and folders.

To refer to registry keys, use cmdlets with xxx-Item:

  • Become-Item – get a registry cardinal
  • New-Item — create a new registry primal
  • Remove-Detail – delete a registry central

Registry parameters should be considered as properties of the registry key (similar to file/folder properties). The xxx -ItemProperty cmdlets are used to manage registry parameters:

  • Get-ItemProperty – get the value of a registry parameter
  • Fix-ItemProperty – change the value of a registry parameter
  • New-ItemProperty – create registry parameter
  • Rename-ItemProperty – rename parameter
  • Remove-ItemProperty — remove registry parameter

Yous tin can navigate to the specific registry key (for example, to the i responsible for the settings of automatic driver updates) using ane of 2 commands:

cd HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching
or
Fix-Location -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching

Become a Registry Parameter Value via PowerShell

Please note that the parameters stored in the registry key are not nested objects, but a property of a specific registry key. Those whatsoever registry fundamental can have whatever number of parameters.

List the contents of the current registry central using the command:

dir

Or

Go-ChildItem

The command has displayed information most the nested registry keys and their properties. Just didn't display information about the SearchOrderConfig parameter, which is a holding of the current key.

Apply the Get-Item cmdlet to get the parameters of the registry central:

Go-Particular .
Or
Go-Item –Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching

Every bit you can see, DriverSearching key has only one parameter – SearchOrderConfig with a value of 1.

getting registry key properties powershell

To get the value of a registry fundamental parameter, use the Get-ItemProperty cmdlet.

$DriverUpdate = Get-ItemProperty –Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching'
$DriverUpdate.SearchOrderConfig

Get-ItemProperty

Nosotros got that the value of the SearchOrderConfig parameter is 1.

Irresolute Registry Value with PowerShell

To change the value of the SearchOrderConfig reg parameter, use the Set-ItemProperty cmdlet:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching' -Proper name SearchOrderConfig -Value 0

Brand sure that the parameter value has changed:

Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching' -Name SearchOrderConfig

Set-ItemProperty

How to Create a New Register Key or Parameter with PowerShell?

To create a new registry cardinal, utilise the New-Item command. Let's create a new fundamental with the name NewKey:

$HKCU_Desktop= "HKCU:\Control Console\Desktop"
New-Detail –Path $HKCU_Desktop –Proper noun NewKey

Now let's create a new parameter in a new registry key. Suppose nosotros need to create a new string parameter of blazon REG_SZ named SuperParamString and value filetmp1.txt:

New-ItemProperty -Path $HKCU_Desktop\NewKey -Name "SuperParamString" -Value "filetmp1.txt"  -PropertyType "Cord"

You can use the following data types for registry parameters:

  • String (REG_SZ)
  • ExpandString (REG_EXPAND_SZ)
  • MultiString (REG_MULTI_SZ)
  • Binary (REG_BINARY)
  • DWord (REG_DWORD)
  • Qword (REG_QWORD)
  • Unknown (unsupported registry data type)

Make sure that the new key and parameter have appeared in the registry.

powershell create registry parameter

How to check if a registry fundamental exists?

If you need to cheque if a specific registry primal exists, use the Test-Path cmdlet:

Examination-Path 'HKCU:\Control Console\Desktop\NewKey'

The following PowerShell script will check if a specific registry value exists, and if non, create it.

regkey='HKCU:\Command Panel\Desktop\NewKey'
$regparam='testparameter'
if (Go-ItemProperty -Path $regkey -Name $regparam -ErrorAction Ignore)
{ write-host 'The registry entry already exist' }
else
{ New-ItemProperty -Path $regkey -Name $regparam -Value "woshub_test"  -PropertyType "String"  }

Using the Copy-Item cmdlet, yous tin can copy entries from ane registry fundamental to some other:

$source='HKLM:\SOFTWARE\seven-zilch\'
$dest = 'HKLM:\SOFTWARE\fill-in'
Re-create-Particular -Path $source -Destination $dest -Recurse

If y'all want to re-create everything, including subkeys, add together the –Recurse switch.

Deleting a Registry Cardinal or Parameter

The Remove-ItemProperty command is used to remove a parameter in the registry key. Allow'south remove the parameter SuperParamString created earlier:

$HKCU_Desktop= "HKCU:\Control Panel\Desktop"
Remove-ItemProperty –Path $HKCU_Desktop\NewKey –Name "SuperParamString"

You can delete the entire registry fundamental with all its contents:

Remove-Particular –Path $HKCU_Desktop\NewKey –Recurse

Note. –Recurse switch indicates that all subkeys have to be removed recursively.

To remove all items in the reg key (but not the key itself):

Remove-Particular –Path $HKCU_Desktop\NewKey\* –Recurse

How to Rename a Registry Cardinal or a Parameter?

Yous can rename the registry parameter with the command:

Rename-ItemProperty –path 'HKCU:\Control Panel\Desktop\NewKey' –name "SuperParamString" –newname "OldParamString"

In the same way, you lot can rename the registry key:

Rename-Item -path 'HKCU:\Control Panel\Desktop\NewKey' OldKey

Search Registry for Keyword Using PowerShell

PowerShell allows you lot to search the registry. The next following searches the HKCU:\Control Panel\Desktop for parameters, whose names contain the *dpi* key.

$Path = (Get-ItemProperty 'HKCU:\Command Panel\Desktop')
$Path.PSObject.Properties | ForEach-Object {
If($_.Name -like '*dpi*'){
Write-Host $_.Name ' = ' $_.Value
}
}

To notice a registry key with a specific name:

Get-ChildItem -path HKLM:\ -recurse -ErrorAction SilentlyContinue | Where-Object {$_.Name -similar "*woshub*"}

Setting Registry Primal Permissions with PowerShell

You can become the electric current registry key permissions using the Go-ACL cmdlet (the Become-ACL cmdlet besides allows yous to manage NTFS permissions on files and folders).

$rights = Get-Acl -Path 'HKCU:\Control Console\Desktop\NewKey'
$rights.Admission.IdentityReference

get registry key permissions with powershell

In the following case, we will alter the ACL in this registry primal to grant write access to the built-in Users group.

Get current permissions:

$rights = Get-Acl -Path 'HKCU:\Control Panel\Desktop\NewKey'

Specify the user or group you want to grant admission to:

$idRef = [System.Security.Main.NTAccount]"BuiltIn\Users"

Select access level:

$regRights = [Organization.Security.AccessControl.RegistryRights]::WriteKey
Set permissions inheritance settings :

$inhFlags = [System.Security.AccessControl.InheritanceFlags]::None
$prFlags = [System.Security.AccessControl.PropagationFlags]::None

Admission type (Allow/Deny):

$acType = [Arrangement.Security.AccessControl.AccessControlType]::Let
Create an access dominion:

$rule = New-Object System.Security.AccessControl.RegistryAccessRule ($idRef, $regRights, $inhFlags, $prFlags, $acType)

Add a new rule to the current ACL:

$rights.AddAccessRule($rule)

Use new permissions to the registry fundamental:

$rights | Set-Acl -Path 'HKCU:\Control Console\Desktop\NewKey'

Brand sure the new grouping appears in the ACL of the registry cardinal.

change registry key permissions with powershell

Getting a Registry Value from a Remote Computer via PowerShell

PowerShell allows you to access the registry of a remote figurer. You lot tin connect to a remote computer either using WinRM (Invoke-Control or Enter-PSSession). To go the value of a registry parameter from a remote computer:

Invoke-Command –ComputerName srv-fs1 –ScriptBlock {Become-ItemProperty -Path 'HKLM:\System\Setup' -Name WorkingDirectory}

Or using a remote registry connectedness (the RemoteRegistry service must be enabled)

$Server = "lon-fs1"
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Server)
$RegKey= $Reg.OpenSubKey("Arrangement\Setup")
$RegValue = $RegKey.GetValue("WorkingDirectory")

Tip. If you have to create/change a certain registry parameter on a number of domain computers, it is easier to utilize GPO features.

And so nosotros've covered typical examples of using PowerShell to admission and manage Windows registry entries. Y'all can use them in your automation scripts.

Source: http://woshub.com/how-to-access-and-manage-windows-registry-with-powershell/

Posted by: marrowabeatice.blogspot.com

0 Response to "How To Get The Vaue Of A Perfection Registering Bank?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel