locked
Multiple params in cmdlet RRS feed

  • Question

  • Hi,

    Im in powershell for couple years now, but still I have doubts how to manage multiple params in custom c# cmdlet's. I don't like having multiple if's. 

    Do you have some solution on this, maybe some pattern?

    regards.

    pw.

    Sunday, May 24, 2015 6:45 PM

Answers

  • What C# CmdLets.  C# does not have CmdLets.

    What are you asking.

    You can have many Params in CmdLets.  It all depends on what you need them for.

    Look at the Advanced Functions created by other users to see how they use params. If statements have nothing to do with params. THey are a programming construct used to build decision logic.  That decision logic may or may not include parameters.


    \_(ツ)_/

    • Proposed as answer by AnnaWY Wednesday, June 3, 2015 7:03 AM
    • Marked as answer by AnnaWY Friday, June 12, 2015 9:26 AM
    Sunday, May 24, 2015 8:30 PM
  • Hi PW,

    Please post your current powershell script and the issue for more efficient support.

    If you want to build param in powershell function, please refer to these articles:

    Windows PowerShell: Defining Parameters

    about_Functions_Advanced_Parameters

    Use PowerShell to Make Mandatory Parameters

    If there is anything else regarding this issue, please feel free to post back.

    Best Regards,

    Anna Wang


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

    • Proposed as answer by AnnaWY Wednesday, June 3, 2015 7:03 AM
    • Marked as answer by AnnaWY Friday, June 12, 2015 9:26 AM
    Monday, May 25, 2015 8:05 AM

All replies

  • What C# CmdLets.  C# does not have CmdLets.

    What are you asking.

    You can have many Params in CmdLets.  It all depends on what you need them for.

    Look at the Advanced Functions created by other users to see how they use params. If statements have nothing to do with params. THey are a programming construct used to build decision logic.  That decision logic may or may not include parameters.


    \_(ツ)_/

    • Proposed as answer by AnnaWY Wednesday, June 3, 2015 7:03 AM
    • Marked as answer by AnnaWY Friday, June 12, 2015 9:26 AM
    Sunday, May 24, 2015 8:30 PM
  • Hi PW,

    Please post your current powershell script and the issue for more efficient support.

    If you want to build param in powershell function, please refer to these articles:

    Windows PowerShell: Defining Parameters

    about_Functions_Advanced_Parameters

    Use PowerShell to Make Mandatory Parameters

    If there is anything else regarding this issue, please feel free to post back.

    Best Regards,

    Anna Wang


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

    • Proposed as answer by AnnaWY Wednesday, June 3, 2015 7:03 AM
    • Marked as answer by AnnaWY Friday, June 12, 2015 9:26 AM
    Monday, May 25, 2015 8:05 AM