In a script, I have a number of reg import
operations. These are all successful, but at the end of my script, I have $Error > C:\Out\Errors.txt
that helps to clean up various errors, but I am always left with 4 or 5 outputs like this in the $Error
output:
reg : The operation completed successfully.
At D:\MySandbox\MySandbox.ps1:1321 char:18
+ ... e-Command { reg import "$env:TEMP\RegistryEditorSettings.reg" *>&1 | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (The operation completed successfully.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
I run the reg import
operations like this (as a result of reading a Stack Overflow that I can't find now that said you have to do it this way to avoid certain problems - but I'm beginning to think that this syntax is the problem):
Invoke-Command { reg import "$env:TEMP\RegistryEditorSettings.reg" *>&1 | Out-Null }
What would be a recommended way to run reg import
operations from my script in such a way that they don't generate output in my $Error
(unless there was an error with the reg import
)?