Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the -EA switch represent on Send-MailMessage?

Tags:

powershell

For example:

Send-MailMessage -To $to -From $sender -subject $subject -SmtpServer $mailserver -Attachments $efile -EA Stop

All those switches are documented on http://technet.microsoft.com/en-us/library/dd347693.aspx except the -EA switch.

What does this switch do and where can I find documentation on it (and its arguments)?

like image 871
JBurace Avatar asked Apr 27 '12 22:04

JBurace


2 Answers

-ea is parameter alias for -ErrorAction. See http://ss64.com/ps/common.html . It's listed in the common parameters in the Send-MailMessage documentation.

This shows the options for ErrorAction:

[enum]::getValues([System.Management.Automation.ActionPreference]) | % {"$_ = (" + [int]$_ + ")"}

You can use the string or the number as the parameter value.

SilentlyContinue = (0)
Stop = (1)
Continue = (2)
Inquire = (3)

Send-MailMessage -EA Inquire or Send-MailMessage -EA 3 are both valid.

like image 66
Andy Arismendi Avatar answered Oct 11 '22 13:10

Andy Arismendi


Here's how you can get parameter aliases for a given command:

PS> $cmd = 'Get-ChildItem'
PS> (Get-Command $cmd).Parameters.GetEnumerator() | Select-Object Key,@{n='Aliases';e={$_.Value.Aliases}}

Key             Aliases
---             -------
Path            {}
LiteralPath     PSPath
Filter          {}
Include         {}
Exclude         {}
Recurse         {}
Force           {}
Name            {}
Verbose         vb
Debug           db
ErrorAction     ea
WarningAction   wa
ErrorVariable   ev
WarningVariable wv
OutVariable     ov
OutBuffer       ob
UseTransaction  usetx
like image 31
Shay Levy Avatar answered Oct 11 '22 11:10

Shay Levy