I've been collaborating with a C#/ASP.NET developer in writing a web
application that invokes Powershell functions which connect to AD, WMI, etc.,
and we've been running into some problems. The developer has no Powershell
experience, and I have no C# experience, so I just write the Powershell code
as parameterized functions and then pass the whole .ps1 for him to invoke
from a webpage.
First, let me say that there are a few examples of invoking Powershell from
C# on the web, such as http://blogs.msdn.com/powershell/arc...25/583250.aspx
and we've been able to get simple things like get-process to work, but when
calling more complex scripts, it always has trouble.
For example, any time I ever set any variable to null, (e.g. $myvar = $null
or $myvar = ""), it works fine from a Powershell command prompt, but crashes
when invoking from C#. Is there any kind of documentation anywhere for
concerns, best practices, gotchas etc. when trying to invoke Powershell from
another .Net language?
Thanks in advance for any help,