VOLUME_MOUNT/volume.py

25 lines
770 B
Python

import subprocess
import json
def get_netvolume():
# PowerShell-Befehl als Zeichenkette
powershell_command = (
"Get-CimInstance -ClassName Win32_LogicalDisk | "
"Where-Object -Property DriveType -EQ 4 | "
"Select-Object DeviceID,ProviderName | "
"ConvertTo-Json"
)
# PowerShell-Befehl ausführen und das Ergebnis in eine Python-Variable laden
result = subprocess.run(
["powershell", "-Command", powershell_command],
capture_output=True,
text=True
)
# Die Ausgabe als JSON interpretieren und in ein Python-Array laden
net_drives = json.loads(result.stdout)
volumes = []
for i in net_drives:
volumes.append(f"{i['DeviceID']};{i['ProviderName']}")
return volumes