Skip to content

Instantly share code, notes, and snippets.

@bohops
Forked from NickTyrer/fsharp.fsscript
Created October 22, 2020 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bohops/10afb2e516e9984c2e05ef29a2be3e2b to your computer and use it in GitHub Desktop.
Save bohops/10afb2e516e9984c2e05ef29a2be3e2b to your computer and use it in GitHub Desktop.
fsi.exe inline execution
#r @"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll"
open System.Management.Automation
open System.Management.Automation.Runspaces
open System
let runSpace = RunspaceFactory.CreateRunspace()
runSpace.Open()
let pipeline = runSpace.CreatePipeline()
let getProcess = new Command("Get-Process")
pipeline.Commands.Add(getProcess)
let output = pipeline.Invoke()
for psObject in output do
psObject.Properties.Item("ProcessName").Value.ToString()
|> printfn "%s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment