{"id":66,"date":"2012-09-14T14:22:34","date_gmt":"2012-09-14T19:22:34","guid":{"rendered":"https:\/\/sysadminnightmare.com\/?p=66"},"modified":"2012-09-14T14:22:34","modified_gmt":"2012-09-14T19:22:34","slug":"powershell-to-get-active-directory-managed-bitlocker-enabled-status","status":"publish","type":"post","link":"https:\/\/sysadminnightmare.com\/index.php\/2012\/09\/14\/powershell-to-get-active-directory-managed-bitlocker-enabled-status\/","title":{"rendered":"Powershell to get Active Directory Managed Bitlocker Enabled Status"},"content":{"rendered":"<p>We have been enabling Bitlocker using the MS Script which updates AD with the Key and Owner Information. In an effort to see which machines have been bitlockered I was asked to come up with an process to do this. Being a sys admin ofcourse I looked for an automated way to complete this as we always do (work smarter, not harder I like to say). The below script is mostly riped off another user but modified to work on my environment and add some &#8220;features&#8221; That were asked of me.<\/p>\n<p>First you are going to need to install the Quest Active directory Plugin for Powershell.. google it and install. Ofcourse you are going to need to change the settings to save the file where you want it to, and remove the fields you dont want.<\/p>\n<p>Bitlocker.ps1<\/p>\n<p>[code]<\/p>\n<p># Check if the Quest Snapin is loaded already, and load if not<br \/>\nif ( (Get-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue) -eq $null )<br \/>\n{<br \/>\n\u00a0Add-PSSnapin Quest.ActiveRoles.ADManagement<br \/>\n}<br \/>\n\u00a0<br \/>\n#Custom variables<br \/>\n$CsvFilePath = &#8220;Q:BitLockerComputerReport.csv&#8221;<\/p>\n<p>#Checks if File is already there, if so deleteds. did this just to be clean<br \/>\nif (Test-Path $CsvFilePath)<br \/>\n\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Remove-Item $CsvFilePath -recurse<br \/>\n\u00a0\u00a0\u00a0 }<br \/>\n\u00a0\u00a0\u00a0<br \/>\n#Export computers Bitlocker-enabled status to a CSV-file<br \/>\n$BitLockerEnabled = Get-QADObject -SizeLimit 0 -IncludedProperties Name,ParentContainer | Where-Object {$_.type -eq &#8220;msFVE-RecoveryInformation&#8221;} | Foreach-Object {Split-Path -Path $_.ParentContainer -Leaf} | Select-Object -Unique<br \/>\n$computers = Get-QADComputer -SizeLimit 0 -IncludedProperties Name,OperatingSystem,Location,adminDescription,msTPM-OwnerInformation | Where-Object {$_.operatingsystem -like &#8220;Windows 7*&#8221; -or $_.operatingsystem -like &#8220;Windows Vista*&#8221; -or $_.operatingsystem -like &#8220;Windows XP*&#8221;}\u00a0 | Sort-Object Name<br \/>\n\u00a0<br \/>\n#Create array to hold computer information<br \/>\n$export = @()<br \/>\n\u00a0<br \/>\n\u00a0foreach ($computer in $computers)<br \/>\n\u00a0 \u00a0{<br \/>\n\u00a0\u00a0 \u00a0#Create custom object for each computer<br \/>\n\u00a0$computerobj = New-Object -TypeName psobject<br \/>\n\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0 \u00a0#Add name and operatingsystem, Location and adminValue to custom object<br \/>\n\u00a0\u00a0\u00a0 \u00a0$computerobj | Add-Member -MemberType NoteProperty -Name Name -Value $computer.Name<br \/>\n\u00a0\u00a0\u00a0 \u00a0$computerobj | Add-Member -MemberType NoteProperty -Name OperatingSystem -Value $computer.operatingsystem<br \/>\n\u00a0\u00a0\u00a0 \u00a0$computerobj | Add-Member -MemberType NoteProperty -Name Location -Value $computer.location<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #check if Virtual is in the adminDescription Field<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ($computer.adminDescription -match &#8220;Virtual&#8221;)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $computerobj | Add-Member -MemberType NoteProperty -Name adminDescription -Value $computer.adminDescription<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #If not add physical to CSV file so we can graph it out on sharepoint<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $computerobj | Add-Member -MemberType NoteProperty -Name adminDescription -Value &#8220;physical&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0 \u00a0#Set HasBitlockerRecoveryKey to true or false, based on matching against the computer-collection with BitLocker recovery information<br \/>\n\u00a0\u00a0\u00a0 \u00a0if ($computer.name -match (&#8216;(&#8216; + [string]::Join(&#8216;)|(&#8216;, $bitlockerenabled) + &#8216;)&#8217;))<br \/>\n\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0 \u00a0\u00a0$computerobj | Add-Member -MemberType NoteProperty -Name HasBitlockerRecoveryKey -Value $true<br \/>\n\u00a0\u00a0\u00a0 \u00a0}<br \/>\n\u00a0\u00a0\u00a0 \u00a0else<br \/>\n\u00a0\u00a0\u00a0 \u00a0{<br \/>\n\u00a0\u00a0\u00a0 \u00a0\u00a0$computerobj | Add-Member -MemberType NoteProperty -Name HasBitlockerRecoveryKey -Value $false<br \/>\n\u00a0\u00a0\u00a0 \u00a0}<br \/>\n\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0#Add the computer object to the array with computer information<br \/>\n\u00a0$export += $computerobj<br \/>\n\u00a0<br \/>\n\u00a0 \u00a0}<br \/>\n\u00a0<br \/>\n#Export the array with computerinformation to the user-specified path<br \/>\n$export | Export-Csv -Path $CsvFilePath -NoTypeInformation<\/p>\n<p>[\/code]<\/p>\n<p>&nbsp;<\/p>\n<p>Next post (part 2) I will show how I then took this list and uploaded it to a SharePoint List for using with Fusion Charts, remember the &#8220;working smarter not harder&#8221; saying because the boss wanted sorting done on the above csv, and colors, and graphs so soon after the above was finished i found myself spending many minutes making it pretty.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have been enabling Bitlocker using the MS Script which updates AD with the Key and Owner Information. In an effort to see which machines have been bitlockered I was asked to come up with an process to do this. Being a sys admin ofcourse I looked for an automated&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/sysadminnightmare.com\/index.php\/2012\/09\/14\/powershell-to-get-active-directory-managed-bitlocker-enabled-status\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,7],"tags":[11,14,35,36],"class_list":["post-66","post","type-post","status-publish","format-standard","hentry","category-admin","category-powershell-2","tag-ad","tag-bitlocker","tag-powershell","tag-quest"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bgeE-14","_links":{"self":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":0,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts\/66\/revisions"}],"wp:attachment":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/categories?post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/tags?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}