Problem
You want to work with the registry keys and values of a remote computer.
Solution
To work with the registry of a remote computer, use the scripts provided in this chapter: GetRemoteRegistryChildItem, GetRemoteRegistryProperty, and SetRemoteRegistryProperty. These scripts require that the remote computer has the remote registry service enabled and running. Example 185 updates the PowerShell execution policy of a remote machine.
Example 185. Setting the PowerShell execution policy of a remote machine
PS >$registryPath = "HKLM:\Software\Microsoft\PowerShell\1" PS >GetRemoteRegistryChildItem LEEDESK $registryPath
SKC VC Name Property
0 1 1033 {Install} 0 5 PowerShellEngine {ApplicationBase, ConsoleHostAss... 2 0 PowerShellSnapIns {} 1 0 ShellIds {}
PS >GetRemoteRegistryChildItem LEEDESK $registryPath\ShellIds
SKC VC Name Property
0 2 Microsoft.PowerShell {Path, ExecutionPolicy}
PS > PS >$registryPath = "HKLM:\Software\Microsoft\PowerShell\1\" + >> "ShellIds\Microsoft.PowerShell" >>
Example 185. Setting the PowerShell execution policy of a remote machine (continued)
PS >GetRemoteRegistryKeyProperty LEEDESK $registryPath ExecutionPolicy
ExecutionPolicy
Unrestricted
PS >SetRemoteRegistryKeyProperty LEEDESK $registryPath ` >> "ExecutionPolicy" "RemoteSigned" >> PS >GetRemoteRegistryKeyProperty LEEDESK $registryPath ExecutionPolicy
ExecutionPolicy
RemoteSigned
Discussion
Although this specific task is perhaps better solved through PowerShell’s Group Policy support, it demonstrates a useful scenario that includes both remote registry exploration and modification.
For more information about the GetRemoteRegistryChildItem, GetRemoteRegistryProperty, and SetRemoteRegistryProperty scripts.
Manage and configure the registry of remote Windows computers efficiently on a United Kingdom Dedicated Server, providing dedicated resources, reliable performance, and full administrative control for centralized system administration and remote server management.