Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, November 19, 2016 9:54 PM
Hi
I was looking to keep my script cleaner and wanted to disable error output
I looked about and seen $ErrorActionPreference = 'SilentlyContinue' I tried this on the top of the script and it worked great.
Now for some reason all the errors are being splattered all over the screen. Ive checked that my script does not contain any other $ErrorActionPreference references
Ive restarted powershell and reloaded the script.
The only change I had made recently was to run the command clear-variable *
This was to remove all stored variables but I dont think that would affect read only variables such as $ErrorActionPreference etc.
I looked about but cant see why the $ErrorActionPreference = 'SilentlyContinue' worked before and does not now ?
Its not remarked out
Thanks
confuseis
All replies (2)
Saturday, November 19, 2016 9:59 PM
Doh
I found why this is so
I had a remove-variable * command in the script that appeared after the $ErrorActionPreference = 'SilentlyContinue' command
The remove-variable command deleted the $ErrorActionPreference contents
confuseis
Monday, November 21, 2016 6:40 AM
Hi,
>>I found why this is so The remove-variable command deleted the $ErrorActionPreference contents
Thanks for sharing the info and glad to hear that you found it.
You could also use -verbose parameter or debugging skills to find out the errors on your script.
Here are some useful links for this:
Best regards,
Andy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.