none
Is -ea a parameter? RRS feed

  • Question

  • Hello,

        I tried to understand what -ea is ? For example, I have

    Get-Process $proc -EA 0 

        I know that $proc is a variable and its value is being passed to the Get-process.

       I try to find what -EA is ? I thought it may be an alias but it is not there when I tried to look for alias named EA in Get-help alias. So I try to ask the forum if someone can help me to figure out -ea. 


    Student at Georgia Tech

    Friday, November 22, 2019 9:12 PM

Answers

  • Yes, I jumped to a conclusion too quickly. I don't use -ErrorAction much, but when I do I spell it out for clarity. And most important, I would avoid using 0, or any of the enumerations. Yes, the link JS2010 provided documents that the 0 means SilentlyContinue, but that is a bit unclear. I would recommend using -ErrorAction SilentlyContinue, especially in a forum or code published for others to use.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by Tom Tra Monday, November 25, 2019 3:32 PM
    Saturday, November 23, 2019 9:01 PM

All replies

  • More likely, the intended operator is -eq, meaning "is equal to" (in this case, equal to 0).

    Edit: Comparison operators documented here. There is no -ea operator:

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-6

    Also check the docs for Get-Process. There is no Filter parameter, so any operator would only be used after the cmdlet is piped to a Where-Object clause.

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-process?view=powershell-6


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)



    Friday, November 22, 2019 9:17 PM
  • -ea 0 is an alias for common parameter -ErrorAction SilentlyContinue.

    You may read more about common parameter here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''


    Friday, November 22, 2019 9:19 PM
  • This is why I constantly rant about new users actually learning basic PowerShell. The first chapter of almost any book will fill in most of the required blanks and help users avoid silly questions

    The first step here is for all to look up the CmdLet in help and read how it works and what the parameters are.

    help get-process -ShowWindow

    Look at ALL of the parameters.  If you don't understand the parameter syntax then look it up.

    help about_parameters

    These are some of the things you must know to even open a PowerShell prompt.

    Here is a good free book on PS.  It is very good and highly rated: PowerShell TFM Fourth Edition 

    I should probably note that the book is task oriented and starts with a full explanation of what PowerShell is and what facilities it provides. Something that most newer users of PowerShell don't seem to know.  Knowing this is like getting an inside track on a well guarded secret.

    The technical level of the book is targeted at Windows admins and techs and is not programmer tech speak.  The authors are/were admins.


    \_(ツ)_/




    Friday, November 22, 2019 9:24 PM
    Moderator
  • It's not so simple.  The common parameters and aliases are listed here, like -ErrorAction (ea):  https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1

    -ErrorAction is of type [System.Management.Automation.ActionPreference].  Try "-erroraction 1000" and you'll see the type in the error message.  It's an enum, with the names and their corresponding numbers listed here: https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.actionpreference?view=powershellsdk-1.1.0  So [System.Management.Automation.ActionPreference]'silentlycontinue' is equal to 0 (after coercing).

    • Edited by JS2010 Saturday, November 23, 2019 4:39 PM
    Saturday, November 23, 2019 4:28 PM
  • The question is not that answer - the question is "what is -ea 0".

    The answer is - learn PowerShell and don't guess or ask others for personal instruction.

    It is never helpful to answer questions t5hat ca be answered by learning basic PowerShell,  It only keeps the person asking these kinds of questions blind to the answer and forces them to accept bad answers and bad code.

    I recommend that anyone who is an advanced skilled coder and who has actually stud9ied the basic to help others to learn by pointing them at the base learning documentation.

    I am surprised that Richard Mueller gave such a wrong answer.  It show why even experienced people need to read the base training.

    Here is one free book that is both a good initial manual and a good refresher.

    PowerShell TFM Fourth Edition


    \_(ツ)_/

    Saturday, November 23, 2019 7:32 PM
    Moderator
  • Yes, I jumped to a conclusion too quickly. I don't use -ErrorAction much, but when I do I spell it out for clarity. And most important, I would avoid using 0, or any of the enumerations. Yes, the link JS2010 provided documents that the 0 means SilentlyContinue, but that is a bit unclear. I would recommend using -ErrorAction SilentlyContinue, especially in a forum or code published for others to use.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by Tom Tra Monday, November 25, 2019 3:32 PM
    Saturday, November 23, 2019 9:01 PM
  • Yes, I jumped to a conclusion too quickly. I don't use -ErrorAction much, but when I do I spell it out for clarity. And most important, I would avoid using 0, or any of the enumerations. Yes, the link JS2010 provided documents that the 0 means SilentlyContinue, but that is a bit unclear. I would recommend using -ErrorAction SilentlyContinue, especially in a forum or code published for others to use.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    I agree and that will become clear to new users if they actually take the time to learn the basics correctly.

    The following is also helpful for new users and anyone else who wants to communicate clearly with technology and PowerShell

    The PowerShell Best Practices and Style Guide


    \_(ツ)_/

    Saturday, November 23, 2019 9:04 PM
    Moderator
  • Powershell is weird.  The documentation could be improved.  For example, we don't know the types of the parameters under "about common parameters".  It wouldn't hurt to link to the "about common parameters" page from the other help pages either.
    • Edited by JS2010 Sunday, November 24, 2019 3:03 PM
    Sunday, November 24, 2019 3:02 PM
  • Powershell is weird.  The documentation could be improved.  For example, we don't know the types of the parameters under "about common parameters".  It wouldn't hurt to link to the "about common parameters" page from the other help pages either.

    Work in progress. The tools are built into PS but the doc people have not caught up yet.

    If you post on UserVoice with suggestions they may get implemented.

    Some docs do reference the common parameters help and others don't.  A simple embedded link would solve this.  If the help adds [<CommonParameters>] then the link to the doc should be automatic.


    \_(ツ)_/

    Sunday, November 24, 2019 6:18 PM
    Moderator
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, November 25, 2019 7:40 AM
    Moderator