Deploying Registry Keys

Registry keys can be deployed with PDQ Connect using a PowerShell step. 

Importing Registry Keys from a File

The simplest method for deploying registry keys is to export an existing key from the registry and then import it on the target device. Below we have a registry key called "RegistryKey.reg" that contains a registry value called "Deployed by Connect." 

PDQ Connect can deploy this key on any number of devices by calling the Registry Console Tool in a PowerShell Step. To do this: 

1. Create a new custom package and add a PowerShell Step. 

2. Click the "Upload files" button and then attach the registry key you wish to import. The key in this case is "RegistryKey.reg." 

3. Enter the following syntax in the scripting pane, making sure to change "RegistryKey.reg" to match the name of the registry key you uploaded in as an attachment. 

$process = Start-Process reg -ArgumentList "import .\RegistryKey.reg" -PassThru -Wait 
exit $process.ExitCode

The finished package can be seen in the screenshot below. 

Creating Registry Keys Using PowerShell

PowerShell can be used entirely to create the key, without the need to export an existing registry entry first. When using this method, we will need to specify in our PowerShell command the registry key and the registry value(s) that should exist under that key. We previously imported a registry DWORD (32-bit) value called "Deployed by Connect" with a data value of 1. The following script replicates the creation of that key.

$path = "HKLM:\SOFTWARE\PDQ.com\RegistryKey"
$name = "Deployed by Connect"

# Create Registry Key
If (-not($Path)) {New-Item -Path $path}

# Create Registry Value
New-ItemProperty -Path $path -Name $name -Value 1 -PropertyType DWORD -Force

In the above script, If (-not($Path)) {New-Item -Path $path} will create the registry key if it does not already exist. The New-ItemProperty cmdlet on the bottom line will create the registry value "Deployed by Connect" and give it a value of 1. It's important to note that the -PropertyType parameter is used to create the value as a 32-bit DWORD. If you need to specify a different type of property, we recommend reviewing the -PropertyType section of our article on the New-ItemProperty cmdlet

Was this article helpful?
Still have a question or want to share what you have learned? Visit our Community Discord to get help and collaborate with others.