A Registry entry can be easily modified using Registry Editor. However, in a case where your work involves a lot of scripting and you ever need to modify the registry using PowerShell, then this article should help you.
Use PowerShell to change Registry values
In this article, we’ll see how to modify the registry using two well-known PowerShell cmdlets. The first cmdlet is New-Item while the second is Set-ItemProperty. You can use either of these cmdlets to modify an existing registry key or add a new registry value.
1] Modify registry using New-Item PowerShell cmdlet
In this example, I’ll be creating AllowIndexingEncryptedStoresOrItems registry DWORD at
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Windows Search and set it to 1.
Usually, this registry DWORD is created to allow Windows 10 to index encrypted files. The Windows Search registry key doesn’t exist by default. So I’ll be creating that first, and then I’ll create the registry DWORD and set it to 1. You can replace the registry key location and values in your case. Here are the steps involved.
Open Windows PowerShell as an Administrator.
Type following and press Enter key to go to registry location:
Set-Location -Path 'HKLM:\Software\Policies\Microsoft\Windows'
Then execute the following cmdlet to create the new registry sub-key named Windows Search. I’m using -Force parameter here to override if the registry items exist already.
Get-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows' | New-Item -Name 'Windows Search' -Force
Now as the registry sub-key is created, I’ll now create registry DWORD and execute the following code for this:
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\Windows Search' -Name 'AllowIndexingEncryptedStoresOrItems' -Value "1" -PropertyType DWORD -Force
Note: If you’re creating string, you have to use the -PropertyType as a string.
You can execute pop-location to go back to normal PowerShell where you can execute other cmdlets.
2] Modify registry using Set-ItemProperty PowerShell cmdlet
For this example, I’ll be setting HideSCAVolume registry DWORD at
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies to 0.
Setting this DWORD to 0 restores the Volume icon if it is missing from the taskbar. Here are the steps for this:
Open Windows PowerShell (Admin).
Then simply copy-paste this cmdlet to perform registry manipulation. Of course, you need to modify the registry location and value with your own, in the below-mentioned code:
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAVolume -Value 0 -Force
With this method, you don’t need to execute pop-location to go back to normal PowerShell as the registry change is directly made here.
I trust this guide helps you modify the registry using Windows Powershell.
You can also take a look at how to use PowerShell to restart a remote Windows computer.