O uso de "reg export" não é o que você deseja usar para exportar uma seção de registro. Eu não sabia, mas a opção "reg save" permite que você realmente salve um arquivo do Registro Hive, como o NTUSER.DAT.
Encontrou um artigo da Microsoft sobre opções reg.exe e testou usando "reg save": link
Código do PowerShell com reg save sendo usado:
Write-Host "Attempting to load the User Roaming Profile Registry HIVE (NTUSER.DAT)."
#Write-Host $strRemoteLocation
reg load "HKU\$strKeyName" "$strRemoteHiveSourcePath\NTUSER.DAT"
Write-Host $strLine
Write-Host "Attempting to clean the Registry HIVE of Samsung SSPrint Keys."
Clean_Key $strKeyName "spd__"
Clean_Key $strKeyName "spe__"
Clean_Key $strKeyName "ssp6m"
Write-Host $strLine
# Export Registry HIVE to NTUSER_Clean.DAT
Write-Host "Attempt to save a new version of the Registry Hive."
reg save "HKU\$strKeyName" "$strRemoteHiveSourcePath\NTUSER_Clean.DAT"
Write-Host $strLine
# Unload the Registry HIVE
Write-Host "Attempting to unload the Registry HIVE."
[gc]::collect()
start-sleep -s 3
reg unload "HKU\$strKeyName"
Write-Host $strLine
# Verify that the NTUSER_Clean.DAT is found.
# If found rename NTUSER.DAT to NTUSER_OLD.DAT and then rename NTUSER_Clean.DAT to NTUSER.DAT
# Clean up NTUSER_OLD.DAT once verified that the new NTUSER.DAT is in place.
if (Test-Path "$strRemoteHiveSourcePath\NTUSER_Clean.DAT") {
Write-Host "The Exported Registry Hive (NTUSER_Clean.DAT) was found."
Write-Host $strLine
Write-Host "Renaming the compacted NTUSER.DAT file to NTUSER_OLD.DAT."
Rename-Item "$strRemoteHiveSourcePath\NTUSER.DAT" "NTUSER_OLD.DAT"
Write-Host "Renaming the compacted NTUSER_Clean.DAT file to NTUSER.DAT."
Rename-Item "$strRemoteHiveSourcePath\NTUSER_Clean.DAT" "NTUSER.DAT"
# Verify we actually have a NTUSER.DAT file before removing the OLD version.
if (Test-Path "$strRemoteHiveSourcePath\NTUSER.DAT") {
Write-Host "Deleting the original NTUSER_OLD.DAT"
Remove-Item "$strRemoteHiveSourcePath\NTUSER_OLD.DAT"
}
}else {
Write-Host "The Exported Registry Hive was NOT found."
Write-Host "The NTUSER.DAT was NOT compacted."
}
Write-Host $strLine