using System.Management.Automation;
using System.Collections.ObjectModel;
using System.Collections;
public static void Main()
var powerShell = PowerShell.Create();
powerShell.AddCommand("Get-PSProvider");
Collection<PSObject> results = powerShell.Invoke();
foreach (var result in results)
var drives = result.Properties["Drives"]?.Value == null ? new string[] { } : result.Properties["Drives"].Value as string[];
Console.WriteLine(drives.First());