如何在powershell v4中执行“-NoNewWindow”参数

我已经使用以下命令来执行自动化任务。 但是像下面这样抛出exception,

参数集无法parsing

我用的命令是:

Start-Process -FilePath powershell.exe -NoNewWindow -ArgumentList $code -verb RunAs 

如何在相同的命令提示符下运行powershell命令? 以及如何跟踪日志。

每个-Verb-NoNewWindow参数属于Start-Process cmdlet的不同参数集。 有关参数集的更多信息,请阅读

 Get-Help about_Functions_Advanced_Parameters 

并参阅Cmdlet 参数 MSDN文章中的Cmdlet参数集

观察下面的自我解释结果:

 PS D:\PShell> $y=(Get-Command Start-Process).ParameterSets PS D:\PShell> $y.Count 2 PS D:\PShell> $y.Name Default UseShellExecute PS D:\PShell> Compare-Object $y[0].Name $y[1].Name InputObject SideIndicator ----------- ------------- UseShellExecute => Default <= PS D:\PShell> Compare-Object $y[0].Parameters.Name $y[1].Parameters.Name InputObject SideIndicator ----------- ------------- Verb => Credential <= LoadUserProfile <= NoNewWindow <= RedirectStandardError <= RedirectStandardInput <= RedirectStandardOutput <= UseNewEnvironment <= PS D:\PShell>