Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Windows Server 2008 R2 : Analyze Server Roles (part 2) - Use PowerShell with the Best Practices Analyzer

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/17/2011 11:50:21 AM

3. Use PowerShell with the Best Practices Analyzer

The BPA tools also have full PowerShell cmdlet support. You can accomplish the BPA tasks in PowerShell as well. The BPA PowerShell cmdlets are also built in to the server and do not require any additional tools or packages to be installed to use them. The PowerShell tools also provide you with the additional capability to run BPA scans of multiple roles at one time.

To be able to run the BPA PowerShell commands, you need to load both the Server Manager PowerShell module and the Best Practices Analyzer module. You can either load them separately or run Windows PowerShell modules.

  1. Load the Windows PowerShell modules by selecting Start => Administrative Tools and clicking Windows PowerShell Modules.

  2. To load the modules separately, after you have opened an administrative PowerShell session, run the following procedure below. If you do not run the BPA commands from an administrative window, you may see a message similar to Figure 6 reminding you to run the command in an administrative window.

Figure 6. BPA administrator required

Follow these actions, referenced previously in Step 2:

  1. Open administrative PowerShell by selecting Start => All Programs => Accessories => Windows PowerShell.

  2. Right-click Windows PowerShell, and select Run As Administrator.

  3. If prompted by User Account Control, click Yes.

  4. From the PowerShell prompt, type the following, and then hit Enter:

    Import-Module ServerManager

  5. From the PowerShell prompt, type the following, and then hit Enter:

    Import-Module BestPractices

There are really four commands you will need to learn, as shown in Table 2.

Table 2. BPA PowerShell Commands
CommandUsage
Get-BPAModelThis command will allow you to view the roles installed on the server where you can run BPA scans; this tool will also show you when the last scan on a particular role was created.
Get-BPAResultThis command will allow you to view the results for any given BPA scan you have performed.
Invoke-BPAModelThis command will allow you to run a BPA scan on your server for a particular role you want to scan.
Set-BPAResultThis command allows you to filter the BPA report from the Get-BPAResult command to allow you to see only the information you want to view in the report.

3.1. BPA PowerShell Examples

To determine which roles are currently installed on the server that you can run a BPA scan against, or to see if a BPA scan has been run, you can use the following command:

Get-BPAModel

You will see results similar to Figure 7.

Figure 7. Get-BPAModel sample results

The important part of the Get-BPAModel command are the model IDs displayed in the results. The model IDs are used in the other BPA commands to perform designated tasks. Currently there are only five IDs you can use to support the five roles currently leveraging the BPA; they're listed in Table 3.

Table 3. BPA Role IDS
BPA Role IDRole
Microsoft/Windows/CertificateServicesActive Directory Certification Services (AD CS)
Microsoft/Windows/DirectoryServicesActive Directory Domain Services (AD DS)
Microsoft/Windows/DNSServerDNS
Microsoft/Windows/TerminalServicesRemote Desktop Services (RDS)
Microsoft/Windows/WebServerInternet Information Services (IIS)

To scan the Internet Information Services role on your server, run the following command:

Invoke-BPAModel -id Microsoft/Windows/WebServer

To scan all the roles currently supported by the BPA tool, you could run the following command on your Windows Server 2008 R2 server:

Get-BPAModel | Invoke-BPAModel

To view the BPA report for the Internet Information Services BPA scan, run the following command, and you will see results similar to Figure 8:

Get-BPAResult -id Microsoft/Windows/WebServer

Figure 8. Get-BPAResult sample results

Although you can view the results in the PowerShell window, remember that you can always view the results in the Server Manager interface regardless of where you ran the scan from (the GUI or PowerShell). So if you want to view the full report, we recommend using the Server Manager interface. If you want to filter results, you can do this in PowerShell with the Set-BPAResult command or with the Where clause.

If you want to view a BPA report for Internet Information Services but only with the rules in the Security category, you could run the following command:

Get-BPAResult -id Microsoft/Windows/WebServer
| Where { $_.Category -eq "Security" }
Other -----------------
- Windows Server 2008 R2 : Maintaining Your Web Server - Work with Websites
- SQL Server 2008 : Creating Indexes via T-SQL (part 2) - Creating Filtered Indexes & Creating XML Indexes
- SQL Server 2008 : Creating Indexes via T-SQL (part 1) - Creating Clustered and Nonclustered Indexes & Creating Unique and Primary Key Indexes
- SQL Server 2008 : Index Vocabulary, Structure, and Concepts
- BizTalk 2009 : The Enterprise Service Bus Toolkit 2.0 - The Architecture (part 2) - Adapter Providers & Mediation Policies
- BizTalk 2009 : The Enterprise Service Bus Toolkit 2.0 - The Architecture (part 1) - Mediation Components & Resolvers
- BizTalk 2009 : The Enterprise Service Bus Toolkit 2.0 - BizTalk and the ESB Concept
- SQL Server 2008 High Availability : Log Shipping (part 2) - SharePoint and Log Shipping
- SQL Server 2008 High Availability : Log Shipping (part 1) - How to Configure Log Shipping
- Windows Server 2008 R2 : Manage Internet Information Services (part 2) - Remotely Manage IIS Servers & Manage IIS with PowerShell
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server