Forum Discussion
Import Registry in Intune
# Define the path for the registry file
$RegistryFileName = "SystemCertificates.reg"
# Get the user's TEMP folder
$TempFolder = [System.IO.Path]::GetTempPath()
# Define the full path to copy the .reg file
$RegistryFilePath = Join-Path -Path $TempFolder -ChildPath $RegistryFileName
# Ensure the registry file is copied to the TEMP folder
if (!(Test-Path -Path $RegistryFilePath)) {
try {
Copy-Item -Path "path\to\$RegistryFileName" -Destination $RegistryFilePath -Force
Write-Output "Registry file copied successfully."
} catch {
Write-Output "Failed to copy registry file: $_"
exit 1
}
}
# Import the registry file
try {
reg.exe import $RegistryFilePath
Write-Output "Registry file imported successfully."
} catch {
Write-Output "Failed to import registry file: $_"
exit 1
}
# Optional: Cleanup - Remove the registry file after importing (if needed)
try {
Remove-Item -Path $RegistryFilePath -Force -ErrorAction SilentlyContinue
Write-Output "Temporary registry file removed."
} catch {
Write-Output "Failed to remove registry file: $_"
}