I've been trying to call a Powershell script with multi params from an C# ASP.NET file in the following way.
string exe = @"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Powershell.exe";
string template = @"-File {0} -macList{1} -version {2} -server {3}";
string file = @" E:\TestmanagerFor3.7.ps1";
string maclist = "MAC1,MAC2";
string version = "4.0";
string server = "xxx.xxx.xxx.xx";
string parameters = String.Format(template, file, macList, version, server);
Process.Start(exe, parameters);
(Please note that here I have two inputs for the macList)
But while running, this is taking MAC1,MAC2 as a single param only. Here's the parameter list of Testman.ps1:
Param
(
[Parameter(Mandatory=$True,Position=1)]
[String[]]$macList,
[Parameter(Mandatory=$True,Position=2)]
[String]$version,
[Parameter(Mandatory=$True,Position=3)]
[String]$server
)
Please help me fixing this issue.
Thanks in advance,
/Aravind