In this blog post, we’ll use the Win32 app deployment method to deploy the registry key and its entries within the HKLM registry node. Also, you can deploy registry keys and entries under the HKCU node by deploying the application within the User Context.
HKCU is a short form of HKEY_CURRENT_USER. It contains the configuration information for the user who is currently logged on. The user’s folders, screen colors, and Control Panel settings are stored here. This information is associated with the user’s profile. To deploy registry keys and entries using Intune Device remediations, refer to this step-by-step guide: How to create HKCU registry keys using Intune remediations
HKLM is an abbreviation for HKEY_LOCAL_MACHINE, which stores information related to the operating system and application configuration settings. In this blog post, I’ve utilized the Win32 app deployment method to deploy HKLM registry keys and entries. You can achieve identical outcomes by using the Intune Remediations method.
If you need to back up and remove a registry key, refer to my other blog post, which offers guidance on addressing the CVE-2022-30190 vulnerability. It also outlines the steps for backing up and deleting a registry key using Intune. It utilizes the Powershell script deployment method.
Step-by-step guide
Numerous use cases exist for deploying registry keys on Windows devices using Intune. While I can’t cover every scenario here, I can highlight a few examples:
- Post-deployment application configuration: After installing software, you can use registry keys to configure and customize the application settings to suit your specific needs.
- License configuration or activation: Registry keys can manage software licenses and activation for various installed applications.
- Operating system configuration settings: You can deploy registry keys to adjust and fine-tune operating system settings to align with your requirements.
- Enabling or disabling application features: Registry keys can enable or disable specific features within applications, allowing you to tailor the software’s functionality to your preferences.
Table of Contents
STEP 1 – Export Registry Key
- On any Windows 10/11 device, Open Registry Editor.
- Create the registry keys that match your desired configuration on the target devices
Example:
- For demonstration purposes, I’ve created a registry key named ATestKey-Cloudinfra.net within the HKEY_LOCAL_MACHINE\SOFTWARE path and added a few DWORD and String-type registry entries.
- To export the registry key, right-click on it and then choose the Export option.
- Please provide the file’s name and Save it. It will be saved with the file extension .reg.
- The screenshot below shows the .reg file we exported.
STEP 2 – Create an IntuneWin file
The next step is to create an Intunewin file. Follow the below steps:
- Create a PowerShell script using the provided code, and replace the .reg file name with your exported .reg file name. For example, CloudInfraregImport.ps1 is the name of our Powershell script.
CloudInfraregImport.ps1
reg import .\AtestkeyCloudInfra.reg
- You can create an empty folder anywhere on your device and place the registry export file (.reg file) and the PowerShell script file into that folder.
- Download the Microsoft Win32 Content Prep Tool. It’s a zip file; therefore, extract its contents into a folder.
- Create an empty folder, for example, C:\output or anywhere else.
- Use the below command to create a .intunewin file. (For detailed guidance on .Intunewin file, refer to this link: How to create an Intunewin file)
.\IntuneWinAppUtil.exe -c "D:\RegImportv6" -s CloudInfraRegImport.ps1 -o C:\output
- Now, check “C:\output” folder to confirm whether .Intunewin file has been successfully created.
STEP 3 – Create Win32 App Deployment
Please follow the steps below to create an Intune Windows app (Win32) using the .Intunewin file.
- Sign in to the Intune admin center.
- Click on Apps and then click on All Apps.
- Click on + Add and Select Windows app (Win32) from the app type.
App Information Tab
- Browse to .Intunewin file we created in previous steps.
Provide Name, Description and Publisher Information
- Name: CloudInfraReg Import
- Description: Keep the default, or to change it, click Edit Description.
- Publisher: Cloudinfra.net
Program Tab
Provide the install command, uninstall command, install behavior, and device restart behavior. Then click “Next” to proceed.
- Install command: %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -Executionpolicy Bypass .\CloudInfraregImport.ps1
- Uninstall command: %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command “Remove-Item -Path ‘HKLM:\SOFTWARE\ATestKey-Cloudinfra.net’ -Force”
- Installation time required (mins): Specify how long your application would take to complete the Installation. If it takes longer than the specified time, the Installation will fail. The default time is 60 minutes; the maximum time you can specify is 1 day (1440 minutes).
- Install behavior: System
- Device restart behavior: No specific Action
Requirements Tab
You can specify the requirements that devices must meet to deploy the app. If your devices mix 32-bit and 64-bit types, check the boxes for 32-bit and 64-bit in the Operating system architecture drop-down. Else, go with 64-bit.
- Operating System Architecture: 64-bit
- Minimum operating system: Select the minimum OS requirement for this deployment.
Detection Rules
Select Manually configure detection rules and click on +Add to add a detection rule.
- Rules Format: Select Manually configure detection rules
- Rule Type: Registry
- Key path: HKEY_LOCAL_MACHINE\SOFTWARE\ATestKey-Cloudinfra.net
- Detection method: Key exists
- Associated with 32-bit app on 64-bit clients: No
Assignments Tab
Click Add groups and select the Entra security group containing Windows 10/11 test devices. Once testing proves successful, you can expand the deployment by including additional devices in the group.
Review + Create
Review the deployment and click on Create to start the deployment process.
Sync Intune Policies
The device check-in process might not begin immediately. If you’re testing this policy on a test device, you can manually kickstart Intune sync from the device itself or remotely through the Intune admin center.
Alternatively, you can use PowerShell to force the Intune sync on Windows devices. Restarting the device is another way to trigger the Intune device check-in process.
STEP 4 – Monitoring the Deployment Progress
To check the Installation status of the app, You can follow the below steps:
- From the Intune admin center, Click on Apps on the left-hand side.
- Click on All apps.
- Please search for the app CloudInfraReg Import and click on it.
From the application’s Overview page, you can check the status of Installation and Failures. To find more details on which devices the app is pushed successfully, click on Device Install or User Install status.
End-user Experience
To confirm the successful import of the registry key and its entries, please restart the target device and wait a few minutes for the PowerShell script to download and execute. You can then verify it by following these steps:
- Press Win Key + R to open the Run dialog box.
- Type regedit and press enter.
- Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ to find the registry key ATestKey-Cloudinfra.net and registry entries created.
Conclusion
In this blog post, we learned how to create registry keys using the Intune Win32 App method. We deployed a registry key under the HKLM (HKEY_LOCAL_MACHINE) registry node. You can also use the Win32 App method to deploy registry keys under the HKCU (HKEY_CURRENT_USER) registry node.
You can also deploy a simple Powershell script to Deploy registry keys. Go to Devices > Scripts and remediations > Platform scripts on the Intune admin center for more information. Refer to this step-by-step guide: How to deploy Powershell script using Intune for more details.
Thx a lot. It was very helpful