简体   繁体   English

以假冒的方式执行Powershell脚本

[英]Executing a Powershell Script in Fake

What is the best way to go about executing a Powershell script in the Fake build automation tool ? 在Fake构建自动化工具中执行Powershell脚本的最佳方法是什么?

I feel that there should be an obvious answer to this question, but have not been able to find anything by searching. 我觉得这个问题应该有一个明显的答案,但是通过搜索找不到任何东西。

As you mention in your comment, using the PowerShell class makes this very easy. 正如您在评论中提到的那样,使用PowerShell类可以非常轻松。

#r "FakeLib.dll"
#r "System.Management.Automation"

open Fake
open System.Management.Automation

Target "RunSomePowerShell" <| fun _ ->
    PowerShell.Create()
      .AddScript("(Get-Process | ? ProcessName -eq 'chrome' | measure WorkingSet -Average).Average")
      .Invoke()
      |> Seq.iter (printfn "%O")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM