Skip to content

Instantly share code, notes, and snippets.

@fbogner
Created October 30, 2020 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbogner/dfa8439143f696a31d5afb4c409ef753 to your computer and use it in GitHub Desktop.
Save fbogner/dfa8439143f696a31d5afb4c409ef753 to your computer and use it in GitHub Desktop.
$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