I want to add C # code or script (what's right?) Through a Powershell command, declaring a variable with the default value stored in a C # variable. For example, in Powershell, I print the following line
$user = 'Admin'
I want to add this line to C # code.
powershell.AddScript(String.Format("$user = \"{0}\"", userName));
or
powershell.AddCommand(String.Format("$user = \"{0}\"", userName));
I am trying to use AddCommand (), but this throws an exception. I am using PS 2.0.
source share