Identify which parameter is passed when running a script

Question:

I have a simple code that accepts two parameters. The parameters are optional. Below is the code.

when running the script I want to know which parameter is passed. pA or pB.

Answer:


return a ps custom dictionary pair (key/value) with all passed parameter.

this is the content of a.ps1 file:

running this script gives:

then you can check what key is present:

Source:

Identify which parameter is passed when running a script by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply