Created
October 30, 2020 09:50
-
-
Save fbogner/dfa8439143f696a31d5afb4c409ef753 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference= 'silentlycontinue' | |
$ping = New-Object System.Net.NetworkInformation.Ping; | |
# Für alle Rechnernamen in der Textdatei rechner.txt | |
foreach($line in Get-Content .\rechner.txt) { | |
# Konvertiere Hostnamen in IP | |
$pc=$line.Trim() | |
$ip = "" | |
$ip = [System.Net.Dns]::GetHostAddresses($pc) | |
# Output | |
write-output "$pc (IP: $ip)" | |
# Wenn wir eine IP bekommen haben.... | |
if ($ip -ne "") { | |
# ... testen wir ob der Rechner auch aktiv antwortet (Ping). | |
$ip = ($ip -Split " ")[0] | |
$ping_Result = $ping.Send($ip,1000) | |
# Wenn dem so ist, fragen wir den BitLocker Status der C Platte ab. | |
if ($ping_Result.Status -eq "Success") { | |
$out = wmic /failfast:1 /node:$ip /Namespace:\\root\cimv2\Security\MicrosoftVolumeEncryption path Win32_EncryptableVolume where "Driveletter like 'C:'" get ProtectionStatus /value | |
# Konvertiere den Multiline Output in ein String Objekt und entferne alle Leerzeilen | |
$out=$out|Out-String | |
$out=$out -replace "`n","" -replace "`r","" | |
# Output | |
write-output $out | |
} | |
else { | |
write-output "Host not alive" | |
} | |
} | |
else { | |
write-output "Not in DNS" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment