In this post, I want to show you how to use PowerShell to create HTML reports with the Best Practices Analyzer (BPA) results.

Best Practices Analyzer (BPA) is a server management tool that is available in Windows Server. This tool helps administrators apply the best practices by scanning one or more roles that are installed on our server. BPA can be used locally or remotely using the Server Administrator GUI or using the Windows PowerShell cmdlets.

Follow the steps below to generate an HTML report that retrieves information from the BPA results.

First, use the Get-BPAModel PowerShell cmdlet to retrieve the list of compatible models with Best Practices Analyzer (BPA) installed in your server. Use the cmdlet with the following syntax:

get-bpamodel

Next, we define which BPA model will be executed, in this case, I will use the Microsoft DNS server. Then we start a scan with Invoke-BPAModel cmdlet.

invoke-bpamodel

Once we have the scan findings, we can use PowerShell to create HTML reports with the results. To do this, we first define the variables with the characteristics of the HTML report.

and finally, we use the Get-BpaResult cmdlet with the following syntax.

get-bparesult

As you can see in the parameters of the command, I have selected only the results with severity level “Error” or “Warning”, but if you want, you can include the level “Information”

BPA PowerShell

If you want to know more about Best Practices Analyzer, check out this link:  https://docs.microsoft.com/en-us/windows-server/administration/server-manager/run-best-practices-analyzer-scans-and-manage-scan-results