Windows Server 2008 R2:
Table of Contents
Windows Server 2008 R2: Server Management and PowerShell V2 ... 1
Exercise 1 Remote Management Using Server Manager ... 2
Exercise 2 Using the Windows PowerShell Integrated Scripting Environment ... 3
Exercise 3 Using Windows PowerShell V2 ... 6
Windows Server 2008 R2: Server
Management and PowerShell V2
Objectives
After completing this lab, you will be better able to: Use Server Manager to remotely manage a computer
Use Windows PowerShell V2 Integrated Scripting Environment Work with Windows PowerShell background jobs
Work with remote computers using Windows PowerShell Use transactions in Windows PowerShell
Use PowerShell to manage Server Core
Scenario
Woodgrove Bank is an investment bank located in Denver, Colorado, USA. Woodgrove Bank has a main office and many regional and local branch offices. Many of the branch offices are small offices and do not have local IT support, and are connected to the main office by low-bandwidth WAN connections. In addition, many users at Woodgrove Bank travel between offices, as well as to customers’ offices and homes for meetings regarding client accounts. Woodgrove Bank is faced with the following global challenges: Management of many servers in many offices.
The need to reduce the operational cost of each branch office. The need for roaming and remote users to access company resources. Management of a large and complex Active Directory infrastructure. To address some of these challenges, Woodgrove Bank has decided to make use of the new management tools and features included in Windows Server 2008 R2.
Prerequisites
Before working on this lab, you must have: The ability to work in a command line environment An understanding of WMI and .NET concepts An understanding of Windows PowerShell concepts and tasks
Estimated Time to
Complete This Lab
60 MinutesComputers used in this
Lab
BAL-DC-01BAL-CORE-01
BAL-CLI-01
The password for the Administrator account on all computers in this lab is: Passw0rd!
Exercise 1
Remote Management Using Server Manager
Scenario
Server Manger now supports connections to remote servers to review the server’s configuration. In this exercise, you will use Server Manager from a remote computer to manage the role and feature configuration of the server.
Tasks Detailed Steps
Complete the following task on:
BAL-DC-01
1. Enable Remote
Management on BAL-DC-01
Note: Begin this task logged on to BAL-DC-01 as Woodgrovebank\Administrator using the password Passw0rd!
In this task you will enable remote management on both the client and the server. a. On BAL-DC-01, on the Taskbar, click Server Manager.
b. In Server Manager click Server Manager (BAL-DC-01) and then under Server Summary, click Configure Server Manager Remote Management.
c. Click Enable remote management of this server from other computers and then click OK.
Note: Remote management can be enabled by running WinRM QuickConfig from the command prompt or by running Enable-PSRemoting from PowerShell.
d. Close Server Manager. Complete the following
task on:
BAL-CLI-01
2. Enable Remote
Management on BAL-CLI-01
Note: In this task you will enable remote management on a Windows 7 client computer by enabling PowerShell remoting.
Begin this task logged on to BAL-CLI-01 as Woodgrovebank\Administrator using the password Passw0rd!
a. On the Start menu, navigate to All Programs/Accessories/Windows PowerShell and then click Windows PowerShell.
b. In Windows PowerShell, type the following command and then press ENTER:
Enable-PSRemoting
c. Press Y and then press ENTER. d. Close Windows PowerShell.
Exercise 2
Using the Windows PowerShell Integrated Scripting
Environment
Scenario
In this exercise you will use the Windows PowerShell Integrated Scripting Environment (ISE). As a reference, the major components of the ISE are labeled below. Use this diagram as a reference for the instructions in the remainder of this lab.
Tasks Detailed Steps
Complete the following task on:
BAL-CLI-01
1. Exploring Windows
PowerShell ISE
Note: In this task you will explore the user interface of the Windows PowerShell ISE to become familiar with how to execute common tasks.
a. On the Start Menu, navigate to All Programs/Accessories/Windows PowerShell, and then click Windows PowerShell ISE.
b. In the Command Pane, type Get-Process and then press ENTER.
Note: The Command Pane title bar displays your current PS Drive and path. The results of the command are displayed in the output pane.
c. In the Command Pane, type Get-EventLog and then press ENTER. d. In the dialog box, in Logname, type System and then press ENTER.
Note: Cmdlets that require input parameters will prompt for the parameters using dialog boxes.
Tasks Detailed Steps
f. Press the ESCAPE key to cancel the current command.
g. In the Command Pane, type Get-EventLog System and then press ENTER. h. Click the STOP button in the Command Pane to terminate execution of the
command.
i. In the Script Pane, type the following script code:
Note: While typing in the script editor, you may use TAB completion to complete commands such as Write-Output and Get-EventLog.
$Log = “System” $Type = “Warning”
$LogEntries = Get-EventLog $Log $LogEntries | ForEach-Object {
If ($_.EntryType –eq $Type) {
Write-Output “The following was found in the event log” Write-Output $_.TimeGenerated
Write-Output $_.Source Write-Output $_.Message }
}
j. In the Script Pane, click the Play button to execute the script. Note: The script returns one or more event log entries.
k. On the File menu, click Save. l. Save the script as EventScript.ps1.
2. Working With
Breakpoints
Note: In this task you will use breakpoints to modify the execution path of a script. Breakpoints provide a method of stopping a script in mid execution and allowing you to view and change items such as variables, which are stored in the script.
a. In the Command Pane, type the following command and then press ENTER: Set-ExecutionPolicy RemoteSigned
b. In the Execution Policy Change Windows, click Yes. c. In the Script Pane, click anywhere in line 4. d. On the debug menu, click Toggle Breakpoint.
Note: Line 4 will be highlighted indicating a breakpoint has been set. e. In the Script Pane, click the Play button to execute the script. Note: The script stops execution on line 4 because of the breakpoint.
f. In the Command Pane, type the following commands, pressing ENTER after each one:
$Type
$Type = “Information” $Type
Note: These commands will display the value of the $Type variable from the script and then change it while the script is in break mode.
Breakpoints allow you to pause the execution of a script and then display and change the values used by the script.
g. On the Debug menu, click Disable All Breakpoints.
Note: Disabling breakpoints allows them to be skipped, but does not remove them. h. On the Debug menu, click Run/Continue.
Note: The script will complete execution, displaying Warning messages instead of the Error messages defined in the script code.
Tasks Detailed Steps
Exercise 3
Using Windows PowerShell V2
Scenario
In this exercise you will learn how to use three key new features in Windows PowerShell V2. You will begin by working with background jobs, which enable you to start a non-interactive process, and then check its status as it executes. Next you will work with transactions. Finally, you will explore the powerful remoting capabilities of Windows PowerShell V2.
Tasks Detailed Steps
Complete the following task on:
BAL-CLI-01
1. Using Transactions in
Windows PowerShell V2
Note: In this task you will work with transactions in Windows PowerShell V2. Transactions are supported by select providers and allow you to make or undo changes as a group. You will use the registry provider to make changes to the registry that is included in a transaction. You will then perform both undo and commit operations.
a. On the Start Menu, navigate to All Programs/Accessories/Windows PowerShell, and then click Windows PowerShell ISE.
b. To identify which providers support transactions, in the Command Pane, type the following command and then press ENTER:
Get-PSProvider *
Note: Note the Capabilities column indicates that the Registry provider supports transactions.
c. To create a new Registry container, in the Command Pane, type the following commands, pressing ENTER after each one:
CD HKCU:\
New-Item –Name App1 –ItemType Container –Force Set-Location App1
Get-Location
Note: You will use this container to test the transaction features of Windows PowerShell V2.
d. To display the available transaction commands and then start a new transaction, in the Command Pane, type the following commands, pressing ENTER after each one:
Get-Command *Transaction* Start-Transaction
e. To make changes that are captured as part of the transaction, in the Command Pane, type the following commands, pressing ENTER after each one:
Get-ChildItem
New-Item -Name Config -ItemType Container -Force –UseTransaction New-Item -Name Parameters -ItemType Container -Force –UseTransaction Get-ChildItem
Get-ChildItem –UseTransaction
Tasks Detailed Steps transaction.
As you can see from the fourth command, any command that does not include the -UseTransactions switch is performed on the live data.
f. To make the changes permanent by committing the transaction, in the Command Pane, type the following command and then press ENTER:
Complete-Transaction
Note: The Complete-Transaction Cmdlet rolls forward the transaction, making all changes permanent.
g. To start a transaction, and undo the changes, in the Command Pane, type the following commands, pressing ENTER after each one:
Start-Transaction
Remove-Item Config -UseTransaction Get-ChildItem –UseTransaction Get-ChildItem
Undo-Transaction Get-ChildItem
Note: The Undo-Transaction Cmdlet rolls back the transaction, undoing all changes.
2. Using Remoting in
Windows PowerShell V2
Note: In this task you will work with one of the most useful features in Windows PowerShell V2: remoting. Remoting is built on WMI remoting and allows you to both execute commands on, and work interactively with, remote PowerShell sessions. At the end of this task you will combine remoting with background jobs to execute a single command asynchronously across multiple computers.
a. To run a command on a remote computer, in the Command Pane, type the following command and then press ENTER:
Invoke-Command –Computername BAL-DC-01 –Command {get-process}
b. To create two persistent connections, in the Command Pane, type the following commands, pressing ENTER after each one:
$sessions = New-PSSession -ComputerName “localhost”, “BAL-DC-01” $sessions | Format-List
c. To run commands on the remote sessions, in the Command Pane, type the following commands, pressing ENTER after each one:
ICM -session $sessions -command {get-process c*}
ICM -session $sessions -command {get-service | where {$_.Status -eq 'Running'}} Note: ICM is a shortcut keystroke in Windows PowerShell which is short for Invoke-Command.
d. To remove all active sessions, in the Command Pane, type the following command and then press ENTER:
Remove-PSSession *
e. To create an interactive session on a remote computer, in the Command Pane, type the following commands, pressing ENTER after each one:
$session = New-PSSession -ComputerName BAL-DC-01 Enter-PSSession $session Hostname Ipconfig Import-Module ServerManager Get-WindowsFeature Get-WmiObject Win32_ComputerSystem Exit-PSSession
Tasks Detailed Steps
access to the remote computer and are conceptually similar to Telnet sessions. f. To run a command on multiple remote computers using background jobs, in the
Command Pane, type the following commands, pressing ENTER after each one: Note: This example uses multiple instances of localhost for the purpose of this lab. You can replace localhost with the name of actual servers in your environment. There are two commands in this block. The second command wraps over two lines.
$servers = "localhost", "localhost", "localhost"
$servers | foreach-object {start-Job -scriptblock {ICM -computername $_ -command {get-eventlog -log system}} -name Remoteeventquery}
Exercise 4
Managing Server Core using Windows PowerShell
Scenario
In this exercise you will implement Windows PowerShell on Server Core. Server Core includes a customized copy of the Microsoft .NET Framework, sufficient to enable Windows PowerShell to function as a management tool on Server Core. Windows PowerShell includes the same functionality as it does on full installations, including the most important, remoting.
Tasks Detailed Steps
Complete the following task on:
BAL-CORE-01
1. Install Windows
PowerShell on Server Core
Note: In this task you will install Windows PowerShell on Server Core using the OCSETUP command. You will then enter Windows PowerShell to verify that it is working.
Begin this task logged on to BAL-CORE-01 as Woodgrovebank\Administrator using the password Passw0rd!
a. To see the available PowerShell components, type the following command in the command prompt, and then press ENTER:
DISM /Online /Get-Features | Find “PowerShell” Note: The command is case sensitive.
Note that in addition to the core Windows PowerShell components, there are PowerShell components for Active Directoryand WOW64.
b. To install Windows PowerShell, type the following command and then press ENTER:
Note: The command is case sensitive.
DISM /Online /Enable-Feature /Featurename:MicrosoftWindowsPowerShell c. To enter Windows PowerShell, type the following command and then press
ENTER:
C:\windows\system32\windowspowershell\v1.0\PowerShell.exe
d. To enable remoting, in Windows PowerShell type the following command, and press ENTER:
Enable-PSRemoting -force e. Press Y and then press ENTER. f. Press Y and then press ENTER.
Note: Remoting may already be enabled on the VM.
g. To verify that Windows PowerShell is functioning, type the following command and then press ENTER:
Get-WmiObject Win32_ComputerSystem
Note: The command will display basic computer information which verifies that Windows PowerShell is functioning.
Complete the following task on:
Note: In this task you will enable remoting in Windows PowerShell on Server Core and then connect to the instance of Windows PowerShell from a remote computer to view service information.
Tasks Detailed Steps
BAL-CLI-01
2. Perform Remote
Management of Server Core using Windows PowerShell
Begin this task logged on to BAL-CLI-01 as Woodgrovebank\Administrator using the password Passw0rd! and ensure that you have Windows PowerShell Integrated Scripting Environment (ISE) open.
a. To query service information, in the Command Pane, type the following command and press ENTER:
ICM –ComputerName BAL-CORE-01 –Command {Get-Service | Where {$_.Status –eq “Running”}}
Note: This command displays the list of all running services on the BAL-CORE-01 computer using PowerShell remoting.
Windows Server 2008 R2 with SP1 – Free Trial Download