Created
July 10, 2015 18:45
-
-
Save yradunchev/b4eea15fe94dfac497e3 to your computer and use it in GitHub Desktop.
Check Bitlocker status of OS Disks
This file contains hidden or 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
| #Check Bitlocker status of OS Disks | |
| $laptops = (Get-ADComputer -SearchBase 'OU=Laptops,OU=EMEA,dc=contoso,dc=com' -Filter '*' | Select -Exp Name) | |
| $Table = @() | |
| $Row = @{ | |
| "LaptopName" = "" | |
| "OSdisk" = "" | |
| } | |
| Foreach($CN in $laptops) | |
| { | |
| $result = Invoke-expression "manage-bde -cn $CN -status c:" | |
| if(($result[13]) -and ($result[13].contains("On"))) { | |
| $Row.LaptopName=$CN | |
| $Row.OSdisk="Protected" | |
| $objRecord = New-Object PSObject -property $Row | |
| $Table += $objRecord | |
| } | |
| elseif(($result[13]) -and ($result[13].contains("Off"))) { | |
| $Row.LaptopName=$CN | |
| $Row.OSdisk="Not protected" | |
| $objRecord = New-Object PSObject -property $Row | |
| $Table += $objRecord | |
| } | |
| elseif(!$result[13]){ | |
| if(Test-Connection -BufferSize 32 -Count 1 -ComputerName $CN -Quiet) { | |
| $Row.LaptopName=$CN | |
| $Row.OSdisk="Not isntalled" | |
| $objRecord = New-Object PSObject -property $Row | |
| $Table += $objRecord | |
| } | |
| else{ | |
| $Row.LaptopName=$CN | |
| $Row.OSdisk="Machine off" | |
| $objRecord = New-Object PSObject -property $Row | |
| $Table += $objRecord | |
| } | |
| } | |
| } | |
| $Table | export-csv "C:\scripts\MBAMStatus.csv" -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment