使用 WMI 类型提供程序
WMI 类型提供程序允许你使用强类型查询 WMI 服务。
要将 WMI 查询的结果输出为 JSON,
open FSharp.Management
open Newtonsoft.Json
// `Local` is based off of the WMI available at localhost.
type Local = WmiProvider<"localhost">
let data =
[for d in Local.GetDataContext().Win32_DiskDrive -> d.Name, d.Size]
printfn "%A" (JsonConvert.SerializeObject data)