Freigeben über


Hyper-V Best Practices Analyzer PowerShell Automation

Hi, Mark here today. As you might know, with the release of Server 2008 R2, Server Manger offered Best Practices Analyzer (BPA) for few roles/features such as Web Server (IIS).

The following screen shot shows the Best Practices Analyzer for IIS on Windows Server 2008 R2

image

Today I’m going to talk about Hyper-V R2 BPA that has been released recently through KB977238

After you install this package (no reboot required), the Hyper-V Best Practices Analyzer will be added to the Hyper- V role page under Server Manager Console. You can now select the Scan This Role option and run the BPA on the server and review the report.

Couple of questions you might ask would be how to run the BPA remotely or on Windows Server 2008 R2 Core?

You can use Server Manager Remotely and connect to another server. If the target server already has Hyper-V BPA package installed, you can scan that machine from inside server manager console and review the report. This applied to both Full and Core editions of Server 2008 R2 as long as Firewall Remote Server Manager connection is already enabled on the target server.

Note: on Server Core R2 please run SCONFIG.EXE

Now, you have another option that is using PowerShell to run the BPA and Save the Results.

For detailed information please see Get-Help about_BestPractices

Here are steps that are needed to be done;

 

1- Start PowerShell as administrator      
2- Load Server Manager module import-module ServerManager
3- Load Best Practices Module import-module BestPractices
4- Run Hyper-V BPA Module  Invoke-BpaModel Microsoft/Windows/Hyper-V
5- Review BPA’s Report  Get-BPAResult Microsoft/Windows/Hyper-v

Output of Get-BPAResult could be exported as HTML or CSV and the Reports could be saved to an alternative path as you wish.

Using this method, you can write your PowerShell Script to run BPA on multiple Hyper-V R2 server (regardless of Core or Full edition) and save the reports on a centralized location.

You may check out the following sample Powershell script I have put together. It runs Hyper-V R2 BPA and saves the report in CSV format;

Hyper-V_BPA_Sample.zip

 

The same concept could be expanded for other roles on Windows Server 2008 R2 that already have BPAs available for them.

In order to check the existing BPA for Windows Server 2008 R2 please refer to the following TechNet page;

TechNet Windows Server 2008 R2 Best Practices Analyzers

https://technet.microsoft.com/en-us/library/dd392255(WS.10).aspx

Hope you enjoyed this post. So long….