I created a powershell object via .net to invoke commands. When I invoke normal commands like Get-Process I had no problems:
ps.AddCommand("Get-Process").AddParameter(...).Invoke()
但是,我无法以“名称:方法”为代号,仅举一个援引[System.IO.File]的例子:Exists(“c:oo.txt”)。
我在审判中
ps.AddCommand("[System.IO.File]::Exists("c:\boo.txt")").Invoke()
ps.AddCommand("[System.IO.File]::Exists").AddArgument("c:\boo.txt").Invoke()
and some others. It always throws an exception which says that the command specified is not recognized.
There is a way to invoke that type of command? Thanks