PowerShell and AD DS Best Practice Analyzer

This is a short one — I’ve had the honor to mess around with AD DS BPA lately and have a short script I wanted to share to run the AD-BPA and exports its fidings to a CSV file you can consume with Excel or whatever. I tried to indicate a line break here with _ symbols. In fact those are single lines — they just look pretty ugly here in this blog so I had to line-break them.

It goes like:

Import-Module BestPractices
$date = get-date -Format "ddMMyy_HHmmss"
Invoke-BPAModel Microsoft/Windows/DirectoryServices && Get-BPAResult _
 Microsoft/Windows/DirectoryServices  | ConvertTo-CSV | set-content _
 "C:\Reports\AD-BPA-Report_$date.csv"

And if you are into only “Error” and “Warning” messages, you might also want to filter (”where”) those out:

Import-Module BestPractices
$date = get-date -Format "ddMMyy_HHmmss"
Invoke-BPAModel Microsoft/Windows/DirectoryServices && Get-BPAResult _
 Microsoft/Windows/DirectoryServices |Â ?{$_.Severity -eq "Warning" -or _
 $_.Severity -eq “Error” } | ConvertTo-CSV | set-content “C:\Reports\AD-BPA-Report_$date.csv”
 

As for the $date variable, you might want to adjust your favourite format. Germans like it this way :)



 
    

No Comment