ADD zls_check.py

This commit is contained in:
2023-09-13 16:44:00 +02:00
parent fb335df2a1
commit f60bae26bb
15 changed files with 141 additions and 111 deletions
+19 -7
View File
@@ -9,17 +9,29 @@ def get_netvolume():
"Select-Object DeviceID,ProviderName | "
"ConvertTo-Json"
)
volume_count = ("(Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object -Property DriveType -EQ 4).Count")
# 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)
volume_count_result = subprocess.run (
["powershell", "-Command", volume_count],
capture_output=True,
text=True
)
volumes = []
for i in net_drives:
volumes.append(f"{i['DeviceID']};{i['ProviderName']}")
return volumes
if result.stdout != '':
net_drives = json.loads(result.stdout)
else:
return None
if volume_count_result.stdout != '':
for i in net_drives:
volumes.append(f"{i['DeviceID']};{i['ProviderName']}")
return volumes
else:
volumes.append(f"{net_drives['DeviceID'][0]};{net_drives['ProviderName']}")
return volumes
# Die Ausgabe alvolumess JSON interpretieren und in ein Python-Array laden
print(get_netvolume())