import subprocess, json cmd = ["powershell", "-NoProfile", "-Command", "Get-Partition | Select-Object DiskNumber, PartitionNumber, DriveLetter, Size, Type | ConvertTo-Json"] res = subprocess.run(cmd, capture_output=True, text=True) print(res.stdout)