Working with registry in PowerShell. I export a key using reg export for backup and that works fine and as expected, but when I run reg import to restore from the backup, it returns as an error although it is successful.
I saw this post: https://powershell.org/forums/topic/reg-exe-throws-an-error-on-success-in-remote-session/
But in my case, this is not on a remote machine and I do not want to suppress errors, but capture and handle them.
The key I export and import is in the HKEY_CLASSES_ROOT hive.
The import does work(!), just returns an exception as a result for some reason.
I can do as suggested in the post above and then check $lastexitcode but prefer to do something more elegant.
Any ideas?
PS V5.1 but requires compatibility to V4