Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - do not display "ERRORS" when running script without using $erroractionpreference = "SilentlyContinue"

Reply
 
Old 02-26-2009   #1 (permalink)
IT Staff


 
 

do not display "ERRORS" when running script without using $erroractionpreference = "SilentlyContinue"

In the scripts which i had, i delibrately search for a *non-existent*
registry in the machine which creates an error. Also i want to run the
script in a command prompt and only display msg via "write-host" instead of
*default error messages* displaying when scripts run.

# open a registry hive that does not exist on a machine
-- example, do something here that generates an error
-- however error *immediately* appear

I do not want error message to display.

I can use $erroractionpreference = "SilentlyContinue" in the first line of
the script. However if i comment out this statement, error message will
definitely appear. Is there a way to NOT TO DISPLAY error msg or CAPTURED
MSG without using the $erroractionpreference = "SilentlyContinue" ?











My System SpecsSystem Spec
Old 02-27-2009   #2 (permalink)
Bob Landau


 
 

RE: do not display "ERRORS" when running script without using $errora

Do you really want not to know of any error? Granted some of noise is not
liked in some circumstances.

The two parameters you will need to check out are described in the
about_CommonParmaters helpfile. Specifically you will want to set ErrorAction
to SilentlyContinue and I hope ErrorVariable to <some variable that you will
examine later>.

This will give you the ability to select how errors are propogated on a per
call basis. This will override the global setting ErrorActionPreference.


"IT Staff" wrote:
Quote:

> In the scripts which i had, i delibrately search for a *non-existent*
> registry in the machine which creates an error. Also i want to run the
> script in a command prompt and only display msg via "write-host" instead of
> *default error messages* displaying when scripts run.
>
> # open a registry hive that does not exist on a machine
> -- example, do something here that generates an error
> -- however error *immediately* appear
>
> I do not want error message to display.
>
> I can use $erroractionpreference = "SilentlyContinue" in the first line of
> the script. However if i comment out this statement, error message will
> definitely appear. Is there a way to NOT TO DISPLAY error msg or CAPTURED
> MSG without using the $erroractionpreference = "SilentlyContinue" ?
>
>
>
>
>
>
>
>
>
>
>
My System SpecsSystem Spec
Old 02-27-2009   #3 (permalink)
tojo2000


 
 

Re: do not display "ERRORS" when running script without using$erroractionpreference = "SilentlyContinue"

On Feb 26, 7:32*pm, "IT Staff" <jkk...@xxxxxx> wrote:
Quote:

> In the scripts which i had, i delibrately search for a *non-existent*
> registry in the machine which creates an error. Also i want to run the
> script in a command prompt and only display msg via "write-host" instead of
> *default error messages* displaying when scripts run.
>
> # open a registry hive that does not exist on a machine
> -- example, do something here that generates an error
> -- however error *immediately* appear
>
> I do not want error message to display.
>
> I can use $erroractionpreference = "SilentlyContinue" in the first lineof
> the script. However if i comment out this statement, error message will
> definitely appear. Is there a way to NOT TO DISPLAY error msg or CAPTURED
> MSG without using the $erroractionpreference = "SilentlyContinue" ?
I'm not sure if I understand exactly what you're asking, but if you're
trying to get just that one operation to not display errors, then you
can use the -ea 'SilentlyContinue' switch on the command instead of
editing the preference variable.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Unwanted Multiple contacts in "To","CC","BCC" of email send catago Vista mail
ATI Drivers causing "display driver stopped responding" errors Drivers
Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" Vista General
How can I add the icons "Delete", "Cut", "Copy" and "Paste" in Vis Vista file management
WM5 Sync with Vista "Windows Calender", "Contacts", and "Mail" Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46