Your example code has an EXE file. I am assuming you have access to the source-code from which the EXE was generated.
The -i -x -o
are all input parameters. Somewhere within that EXE, there's some code that handles these parameters and stores them into variables.
-i dir_1\dir_2\blah.xml -x dir_x\dir_y\something.xslt -o path1\path2\result.html
Thus, dir_1\dir_2\blah.xml
would (probably) get stored into some variable for further processing, and so on.
While reading this answer, read this as well. Keep the Microsoft TechNet and MSDN websites handy - it helps :)
To be able to launch a Powershell script with "-x -y"parameters, you need to define the following at the top of your script.
Basic Usage
Param(
[string]$x,
[string]$y
)
Here you'd call the script as script -x -y
This will accept two arguments -x and -y. Whatever you feed in is stored as a string (in this example), in variables $x $y
.
If you want any other datatype simply change the [string]
value.
Advanced Usage
- You can also make a parameter have aliases using the
[alias("myalias")]
construct. This helps if you have a long variable name, but need a shorter alias for the commandline usage. - You can make parameters optional using the
[parameter(Mandatory = $false)]
construct.
e.g.
Param(
[parameter(Mandatory = $true)]
[alias("myalias1")]
[string]$mylongvariablename1,
[parameter(Mandatory = $false)]
[alias("myalias2")]
[string]$mylongvariablename2,
....
In this above example, you would call the script as script -myalias1 -myalias2
(myalias2 is of course, an optional param).