You are on page 1of 34

Module 9

Automating
Windows Server 2008
Administration

Module Overview
After completing this module, you will be able to:
List the modules included with Windows Server 2008 R2

Add and remove Windows features from the command-line


Manage Group Policy objects from the command-line
Use Troubleshooting Packs from the command-line

Run and review Best Practices Analyzer reports from the

command-line

Manage IIS features and configuration

from the command-line

Lesson 1: Windows Server 2008 R2 Modules


Overview
After completing this lesson, you will be able to:
List and describe the modules provided with Windows

Server 2008 R2

Import Windows Server 2008 R2 modules into the shell


List the cmdlets and functions included in a given module

Modules Overview
Windows Server 2008 R2s modules are installed in the

PowerShell systemwide module folder. View the contents


of this folder with:
Cd $pshome\modules

PowerShell defines an environment variable with the

search paths for locating modules. View the contents of


this environment variable with:
Get-Content env:psmodulepath

Generate a list of installed modules with:


Get-Module -list
Generate a list of installed snap-ins with:
Get-PSSnapin registered

Included Modules
The following modules and snap-ins are included with

Windows Server 2008 R2:

Active Directory Domain Services (AD DS)


Active Directory Rights Management Services (AD RMS)
AppLocker (Application ID Policy Management)
Best Practices Analyzer
Background Intelligent Transfer Service (BITS)
Group Policy and Group Policy objects (GPOs)
Network Load Balancing
Windows PowerShell Diagnostics (PSDiagnostics)
Remote Desktop Services
Server Manager
Server Migration
Troubleshooting Packs
Web Administration (Internet Information Services)
Web Services for Management (WS-MAN)
Windows Cluster Service (Failover Clusters)
Windows Server Backup

Working with Modules and Snap-ins


Modules must be added into the shell to use their

functionality. Modules remain for the duration of the shell


session, unless they are specifically removed.
Import-Module ActiveDirectory

Once loaded, use Get-Command to list the cmdlets that

are now available through the module.

Get-Command module ActiveDirectory


Some Windows Server 2008 R2 extensions are not

provided as modules. Instead they are snap-ins.

Snap-ins require a slightly different syntax to load and list

their contents.

Add-PSSnapin windows.serverbackup
Get-Command pssnapin windows.serverbackup

About the Lessons in This Module


This module includes five additional lessons:

Server Manager Cmdlets

Group Policy Cmdlets

Troubleshooting Pack Cmdlets

Best Practices Analyzer Cmdlets

IIS Cmdlets

Each of the following lessons will briefly introduce the

module being covered, and the details about the modules


operation

You will complete a lab where you use the module in practice

The goal is for you to use the techniques here to identify the
module, load it, list its cmdlets, and read help

Discover how to use the cmdlets in completing the labs

Lesson 2: Server Manager Cmdlets Overview


Use Server Manager cmdlets to add roles, remove roles,

and list roles

Use Server manager cmdlets, along with Compare-Object,

to provide a change configuration report for role changes


on a server

Server Manager Cmdlets


The Server Manager module includes only three cmdlets:

Get-WindowsFeature

Add-WindowsFeature

Remove-WindowsFeature

Import-Module servermanager

Lab A: Using the Server Manager Cmdlets


Exercise 1: Listing All Currently Installed Features
Exercise 2: Comparing Objects

Exercise 3: Installing a New Server Feature


Exercise 4: Exporting Current Configuration to XML

Logon information
Virtual machine

LON-DC1

LON-SVR1

Logon user name

Contoso\Administrator

Contoso\Administrator

Password

Pa$$w0rd

Pa$$w0rd

Estimated time: 20 minutes

Lab Scenario
You work as a systems administrator, focusing on servers.
You are configuring a new Windows Server 2008 R2 file

server. The server must meet a standard configuration and


you must provide an audit trail of the final configuration in
the form of an XML file.

Lab Review
What module do you need to import to manage server

features?

What cmdlets are used to manage server features?


What type of object does Get-WindowsFeature write to the

pipeline?

What are some of its properties?

Does the cmdlet support configuring a remote server?

Lesson 3: Group Policy Cmdlets Overview


Use Group Policy cmdlets to review Group Policy objects,

create HTML reports, back up a Group Policy object, and


more

Use Group Policy cmdlets to create, link, and change

settings within a GPO

Group Policy Cmdlets


The Group Policy module includes 25 cmdlets

Backup-GPO
Copy-GPO
Get-GPInheritance
Get-GPO
Get-GPOReport
Get-GPPermissions
Get-GPPrefRegistryValue
Get-GPRegistryValue
Get-GPResultantSetOfPolicy
Get-GPStarterGPO
Import-GPO
New-GPLink
New-GPO

New-GPStarterGPO
Remove-GPLink
Remove-GPO
Remove-GPPrefRegistryValue
Remove-GPRegistryValue
Rename-GPO
Restore-GPO
Set-GPInheritance
Set-GPLink
Set-GPPermissions
Set-GPPrefRegistryValue
Set-GPRegistryValue

Lab B: Using the Group Policy Cmdlets


Exercise 1: Listing All the Group Policy Objects in the

Domain

Exercise 2: Creating a Text-Based Report


Exercise 3: Creating HTML Reports
Exercise 4: Backing Up All Group Policy Objects

Logon information
Virtual machine

LON-DC1

LON-SVR1

Logon user name

Contoso\Administrator

Contoso\Administrator

Password

Pa$$w0rd

Pa$$w0rd

Estimated time: 20 minutes

Lab Scenario
You are a Windows administrator responsible for managing

Group Policy objects in your domain

Your manager has asked for report of all your Group Policy

Objects

You manager also wants to make sure that all Group Policy

Objects are being backed up

Lab Review
What module do you need to import to manage Group

Policy?

What cmdlet is used to get Group Policy information?


What type of Group Policy reports can you create?
Can you back up individual Group Policy objects?

Lesson 4: Troubleshooting Pack Overview


Execute Troubleshooting Packs on a local or remote

computer by using one-to-one interactive remote shell or


implicit remoting

Troubleshooting Pack Cmdlets


The Troubleshooting Pack module includes two cmdlets

Get-TroubleshootingPack

Invoke-TroubleshootingPack

These cmdlets require Troubleshooting Packs, most of

which are installed by default to


\Windows\Diagnostics\System

Get-TroubleshootingPack
C:\windows\diagnostics\systems\aero
Many Troubleshooting Packs are interactive at the shell,

presenting a command-line menu for selecting specific


problems or diagnostics

Lab C: Using the Troubleshooting Pack Cmdlets


Exercise 1: Importing the Troubleshooting Pack Module
Exercise 2: Solving an End-User Problem Interactively

Exercise 3: Solving a Problem Using Answer Files

Logon information
Virtual machine

LON-DC1

LON-SVR1

Logon user name

Contoso\Administrator Contoso\Administrator Contoso\Administrator

Password

Pa$$w0rd

Pa$$w0rd

Estimated time: 20 minutes

LON-CLI1

Pa$$w0rd

Lab Scenario
You work as a systems technician, troubleshooting

problems with individual desktops.

The help desk manager has asked for your assistance in

troubleshooting a desktop problem. She has heard you can


solve problems with Windows PowerShell and has asked
for your assistance in learning more.

Lab Review
What cmdlet do you use to load the Troubleshooting Pack?
What are the cmdlets in the Troubleshooting Pack?

Can you resolve a problem without using an answer file?

Lesson 5: Best Practices Analyzer Cmdlets


Overview
Generate Best Practices Analyzer reports by using the BPA

cmdlets

BPA Cmdlets
The Best Practice Analyzer module includes four cmdlets:

Get-BpaModel

Get-BpaResult

Invoke-BpaModel

Set-BpaResult

BPA cmdlets work with BPA Models. Each model is a set of

best practices that are related to a role or feature

Models must be retrieved and then invoked before their results


can be retrieved

Get-BpaModel | Invoke-BpaModel

Lab D: Using the Best Practice Analyzer Cmdlets


Exercise 1: Importing the Best Practice Module
Exercise 2: Viewing Existing Models

Exercise 3: Running a Best Practices Scan

Logon information
Virtual machine

LON-DC1

Logon user name

Contoso\Administrator

Password

Pa$$w0rd

Estimated time: 15 minutes

Lab Scenario
You work as a systems administrator, and you are

responsible for a group of servers running Windows Server


2008 R2

As part of your automated audit process you want to

prepare a series of best practice reports depending on


what server roles are installed

Lab Review
What module do you need to import to run Best Practices

scans?

What are some of the items that you can view in a scan

result?

What are some of the Best Practice models available?

Lesson 6: IIS Cmdlets Overview


Use IIS cmdlets to manage IIS features and Web sites
Use the IIS: drive to manage IIS settings

IIS Cmdlets
The IIS module includes 74 cmdlets, which are intended to

represent the core set of administrative actions that one


would use with an IIS server and websites

Creating Web sites

Creating FTP sites

Creating Application pools

Start, stop, restart sites

Start, stop, restart pools

The cmdlets in the IIS module contain excellent help files

and usage examples

Import-Module Webadministration

The IIS: Drive


Due to the vast differences between IIS instances, IIS

cmdlets are not comprehensive.

Much of the IIS PowerShell administration occurs using the

IIS: drive. This drive looks and behaves in similar ways to


other PS drives (such as disk, Active Directory).

Each drive is actually a configuration repository for an area of


the server/website.

Exposed in a hierarchical fashion.

Navigated and manipulated using the Item and ChildItem


cmdlets.

PS IIS:\> cd apppools
PS IIS:\apppools> ls
Name
---Classic .NET AppPool
DefaultAppPool

State
----Started
Started

Applications
-----------Default Web Site

Demonstration: IIS Examples


Learn how to use the IIS: drive to review and manage IIS

configuration settings from within the shell

Lab E: Using the IIS Cmdlets


Exercise 1: Importing the IIS Module
Exercise 2: Creating a New Web Site

Exercise 3: Backing Up IIS


Exercise 4: Modifying Web Site Bindings
Exercise 5: Using the IIS PSDrive

Exercise 6: Restoring an IIS Configuration

Logon information
Virtual machine

LON-DC1

Logon user name

Contoso\Administrator

Password

Pa$$w0rd

Estimated time: 30 minutes

Lab Scenario
You are a Windows Administrator tasked with managing a

small Web server used for internal purposes.

Your job includes creating and managing Web sites.

Because your company charges for internal IT services,


you need to automate Web site management so that it can
be done in the most efficient manner possible.

Lab Review
What module do you need to import to manage IIS?
What cmdlet do you use to create a new web site?

What cmdlet do you use to stop a web site?


What cmdlets do you use to modify web site bindings?
What do you see in the Sites folder of the IIS PSDrive?

You might also like