0% found this document useful (0 votes)
24 views33 pages

Module 2 PowerShell v4 Lab

Uploaded by

bigd3580
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views33 pages

Module 2 PowerShell v4 Lab

Uploaded by

bigd3580
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

WorkshopPLUS – Windows

Server 2012 R2 Capabilities,


Administration and Support
Module 2: PowerShell v4

Student Lab Manual

Version 1.4

© 2013 Microsoft Corporation

Microsoft Confidential
Conditions and Terms of Use
Microsoft Confidential - For Internal Use Only

This training package is proprietary and confidential, and is intended only for uses described in the training materials. Content
and software is provided to you under a Non-Disclosure Agreement and cannot be distributed. Copying or disclosing all or any
portion of the content and/or software included in such packages is strictly prohibited.

The contents of this package are for informational and training purposes only and are provided "as is" without warranty of any
kind, whether express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular
purpose, and non-infringement.

Training package content, including URLs and other Internet Web site references, is subject to change without notice. Because
Microsoft must respond to changing market conditions, the content should not be interpreted to be a commitment on the part
of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. Unless
otherwise noted, the companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events
depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place, or event is intended or should be inferred.

© 2013 Microsoft Corporation. All rights reserved.

© 2013 Microsoft Corporation

Microsoft Confidential
Copyright and Trademarks

© 2013 Microsoft Corporation. All rights reserved.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject
matter in this document. Except as expressly provided in written license agreement from Microsoft, the furnishing of this
document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part
of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means
(electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of
Microsoft Corporation.

For more information, see Use of Microsoft Copyrighted Content at


http://www.microsoft.com/about/legal/permissions/

Microsoft®, Internet Explorer®, and Windows® are either registered trademarks or trademarks of Microsoft Corporation in the
United States and/or other countries. Other Microsoft products mentioned herein may be either registered trademarks or
trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are property of their
respective owners.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 5

Contents
MODULE 2: POWERSHELL V4 ................................................................................................................... 1
CONTENTS .................................................................................................................................................... 5
LAB 1: POWERSHELL V4 INTRODUCTION ............................................................................................. 6
EXERCISE 1: POWERSHELL BASICS .................................................................................................................. 8
Task 1: Review the available help within Windows PowerShell ...................................................... 8
Task 2: List the commands available in Windows PowerShell........................................................10
Task 3: Format and filter output using Windows PowerShell .........................................................11
EXERCISE 2: INTRODUCING WINDOWS POWERSHELL ISE ...............................................................................13
Task 1: Exploring the Windows PowerShell ISE ................................................................................13
Task 2: Running a script file ...............................................................................................................17
LAB 2: ADVANCED POWERSHELL V4 ................................................................................................... 18
EXERCISE 1: DESIRED STATE CONFIGURATION................................................................................................19
Task 1: Change the Computer Name and IP Address using DSC ...................................................19
Task 2: Promote the first DC in the Contoso Domain using DSC ...................................................23
Task 3: Join WINSRV-WEB1 to the Contoso Domain ......................................................................25
EXERCISE 2: USING POWERSHELL WORKFLOWS .............................................................................................28
Task 1: Prepare WINSRV-2008 Server...............................................................................................28
Task 2: Installing Windows Management Framework 4.0 (PowerShell v4) ...................................29
Task 3: Promote WINSRV-2008 as a Domain Controller ................................................................30
EXERCISE 3: USING POWERSHELL WEB ACCESS .............................................................................................31
Task 1: Installing PowerShell Web Access using PowerShell ..........................................................31

© 2013 Microsoft Corporation

Microsoft Confidential
6 PowerShell v4 Introduction

Lab 1: PowerShell v4 Introduction


Introduction
In this lab, you will explore the Windows PowerShell v4 environment, learn basic
PowerShell commands, learn how to use the help files, and learn the basics of Windows
PowerShell ISE.

Objectives
After completing this lab, you will be able to:
 Use Windows PowerShell Help features.
 List all PowerShell Cmdlets.
 Explore the PowerShell Integrated Scripting Environment (ISE).
 Create and execute a PowerShell script.

Prerequisites
 Student Logged into their “Host Machine” (This is the server that you logged in to
for example : SVVMASP## Server)
 WINSRV-AD1, WINSERV-WEB1, and WINSRV-2008 are running, (This will be
completed in the lab)

Estimated time to complete this lab


15 minutes

Scenario
There is a requirement to provide information about the hotfixes and software updates
installed for all of your servers. You need to find the software update ID number, install
date, and the support webpage. The deadline for the task is next week and is required
monthly. We have decided that PowerShell is the best option. In order to complete the
task we need to explore the PowerShell features.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 7

Network & Server Layout for Lab

Contoso.com Domain

Windows Server 2008 Server


IP 192.168.1.222
Subnet: 255.255.255.0
WINSRV-2008 DNS: 192.168.1.103

Windows Server 2012 R2


Windows Web Server
IP 192.168.1.220
Subnet: 255.255.255.0
WINSRV-Web1 DNS: 192.168.1.103

Windows Server 2012 R2


Windows Domain Controller
IP 192.168.1.103
Subnet: 255.255.255.0
WINSRV-AD1 DNS: 192.168.1.103

SVVMASP##

RDS Gateway

Your Login
From your location
Msftonlinerepro\loginID

© 2013 Microsoft Corporation

Microsoft Confidential
8 PowerShell v4 Introduction

Exercise 1: PowerShell Basics


Objectives
In this exercise, you will:
 Review the different levels of help content available for a cmdlet
 Learn the basics of running Windows PowerShell cmdlets
 List all available commands in Windows PowerShell v4
 Learn how to use command parameters to filter data and format the output
of cmdlets

Task 1: Review the available help within Windows PowerShell


For this task, we will use two Virtual Machines (VMs) that have been imported into
Hyper-V. We will go into more detail of the Hyper-V Manager later in the class.
1. From Server Manager, choose Tools (upper right-hand corner) and select
Hyper-V Manager.
2. On the left hand menu, ensure your Server name is selected.
3. Select WINSRV-AD1. Right Click and Select Start.
4. Select WINSRV-WEB1. Right Click and Select Start.
5. Select WINSRV-2008. Right Click and Select Start.

6. Log into the Virtual Machines:


Click the Ctrl-Alt-Delete button on the upper left hand corner.

Alternatively, press Ctrl-Alt-End on the keyboard.


Logon with the following credentials:
Username: Administrator Password: LS1setup!

7. On WINSRV-AD1, open the PowerShell window by clicking the Windows


PowerShell icon on the taskbar.

8. Enter the following at the Windows PowerShell command prompt to see a list of
available help topics:

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 9

Help *
Be sure to place a space between Help and *
The command will fill an entire screen and then pause. Press the Enter key to
show the next output line, or press the Space Bar key to advance to the next
page.
9. Press the space bar until the command prompt returns. Alternatively, you can
type the letter ‘Q’ to cancel the output.
10. Enter the following command to see a graphical list of all cmdlets available. Note
that this command is NOT available in Server Core:
Show-Command
11. Type “Get-Process” in the Name field of the “Commands” window and select
“Get-Proccess”, then click “Run” to display all the processes running on your
machine.
12. Enter the following at the Windows PowerShell command prompt to view help
information about the Get-Command cmdlet:
Help Get-Command
The help contains the syntax for the command as well as a brief description
13. Enter the following at the Windows PowerShell command prompt to see detailed
help for the Get-Command cmdlet:
Help Get-Command -Detailed
The output includes details about the parameters for the cmdlet, as well as
some examples.
Note: Every command has three different levels of help available:
 The default view shows the command description and syntax.
 The detailed view adds usage examples and complete documentation.
 The full view adds command’s technical details including parameter
and return value data types.
14. Update the Powerhe following command:
Update-Help -SourcePath “C:\Labfiles\PSHelp”

Notice the installation progress of the command.

© 2013 Microsoft Corporation

Microsoft Confidential
10 PowerShell v4 Introduction

If the server has Internet access, the command is Update-Help. To download the
Note: help files for servers without Internet access, use this command: Save-Help -
DestinationPath “PathGetG”. The Update-Help command may error on the ISE
Modules but the Get-Help command should work as expected.

Help Files can be downloaded using the following link:


http://www.microsoft.com/en-au/download/details.aspx?id=36475

15. Hit the up arrow twice to come back to "Help Get-Command" and press Enter to
review the difference after the Help is updated.

Task 2: List the commands available in Windows PowerShell


1. To list all of the commands that are available in Windows PowerShell, enter the
following command:
Get-Command
This will list all of the cmdlets.
2. Enter the following text at the command prompt but do not press ENTER:
Get-C <TAB>
That should be get-c followed by the tab key. This will complete the cmdlet and
should show get-certificate.
3. Press the Tab key again. Windows PowerShell expands the command to Get-
CertificateAutoEnrollmentPolicy. Press Tab again to cycle through all of the
possiblilities until you get to Get-ChildItem.
4. Press the Enter key to execute the expanded Windows PowerShell command.
This illustrates the feature known as tab complete. The PowerShell user does
not need to know the exact command or the correct spelling. As long as they
can remember the first part, tab complete will help finish the command.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 11

Task 3: Format and filter output using Windows PowerShell


1. Enter the following and press enter at the Windows PowerShell command
prompt to view a list of services installed on the machine:
Get-Service
A list of services is displayed.

Windows PowerShell provides a complete set of verbs to query and manipulate


Note: services including: Get, New, Restart, Resume, Set, Start, Stop and Suspend. To
view a list of service related command, type Get-Command –Noun Service.

2. Enter the following and press enter to view the status of the Spooler service:
Get-Service -Name Spooler
3. Enter the following and press enter to view a list of all services that begin with M.
Get-Service M*
The status of all the services beginning with M display.
4. Enter the following and press enter to see the same list of services. This time, the
output is in list format.
Get-Srvice M* | Format-List

In this example there are two commands separated by a pipe (|) character. This
Note: means that the output of the first command is sent as the second command’s input.

5. Enter the following to see the same output, this time shown in a custom format:
Get-Service M* | Format-Custom
The status of all services beginning with M is shown in the custom format

Windows PowerShell includes several defined format commands,


Note: each one with many configuration options. This provides a great
deal of flexibility in output formatting. Developers can also create
additional format commands.

6. Enter the following to view a list of all services ordered by their status:
Get-Service | Sort-Object Status
7. Enter the following to view a list of services that the Spooler service requires to
start.
Get-Service Spooler | Select-Object ServicesDependedOn
A list of services that the spooler service depends on is shown.

© 2013 Microsoft Corporation

Microsoft Confidential
12 PowerShell v4 Introduction

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 13

Exercise 2: Introducing Windows PowerShell ISE


Objectives
In this exercise, you will:
 Explore the different features of Windows PowerShell ISE
 Learn the basics of running Windows PowerShell scripts
Prerequisites
 WINSRV-AD1 virtual machine started
 WINSRV-WEB1 virtual machine started.

Task 1: Exploring the Windows PowerShell ISE


1. From WINSRV-AD1, launch Server Manager, in the top right corner, click Tools
and click Windows PowerShell ISE

2. In the Windows PowerShell ISE window click View | Show Script Pane

© 2013 Microsoft Corporation

Microsoft Confidential
14 PowerShell v4 Introduction

3. Type Get- and a list of Cmdlets is shown in a drop down menu.

4. If you click (or navigate via keyboard) to Get-EventLog for example, a tooltip
displays the syntax of the cmdlet.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 15

PowerShell 3.0 and greater, Windows PowerShell Integrated Scripting Environment


Note: (ISE) has many new features, including Intellisense.

5. Type the following line in the script pane of Windows PowerShell ISE:

$InstalledHotfix = Get-HotFix

This line creates a variable called $InstalledHotfix. It then finds all of the Hotfixes
Note:
installed on the computer and stores them in the variable.

6. In the next line, use the Snippets feature by right clicking in the script pane and
choose Start Snippets.
7. In the pop up window, double click the foreach option.

8. Change the $item to $Hotfix


Change the $collection to $InstalledHotFix
These lines will perform the action within the “{ }” for every hotfix in the variable
$InstalledHotFix

9.

10. Run the script by clicking the green triangle in the toolbar

© 2013 Microsoft Corporation

Microsoft Confidential
16 PowerShell v4 Introduction

This puts actual data into the variables. Once this occurs, we can choose
properties that are stored in the HotFix object more easily.
11. Between the two { } type the following commands:
$HotFixIDNumber = $Hotfix.

Notice the popup that allows you to choose the property of the HotFix object. Choose HotFixID.

Write the remaining lines below:


$HotFixInstallDate = $Hotfix.InstalledOn
$SupportWebpage = $Hotfix.Caption

Write-host -ForegroundColor red -BackgroundColor white -Separator ", "


$HotFixIDNumber $HotFixInstallDate $SupportWebpage

The write-host command should be on one line.


The Result should look like this:

12. Save script in your documents folder as Get-InstalledUpdates.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 17

Task 2: Running a script file

Script files store PowerShell commands in a file, providing an easy way to run a list of
commands. You only need to tell PowerShell to run the script file. A little knowledge on
execution policies is necessary for you to understand the reasons behind the security
features of Windows PowerShell. The execution policy enables you to determine which
Windows PowerShell scripts (if any) can execute on your computer. Windows PowerShell
has four different execution policies:

Restricted - No scripts are allowed to run. Windows PowerShell can only be used in
interactive mode.
AllSigned - Only scripts signed by a trusted publisher can be run.
RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they
can be run.
Unrestricted - No restrictions; all Windows PowerShell scripts can be run.

1. Open the standard PowerShell window by clicking the icon near the start button.
2. Type the following command:
Get-ExecutionPolicy
The default in Windows Server 2012 R2 is remote signed.
3. Execute the script saved in previous exercise by navigating to Documents folder
(cd Documents) and running the script (.\Get-InstalledUpdates.ps1)
Unlike command line scripts, to launch powershell scripts located in the current folder
a .\ prefix is required (indicating script is located in current folder)
4. The script will run and display all updates installed on the server.
5. This script illustrated the PowerShell ISE scripting environment. An easier way to
pull the same data is below.

Get-HotFix | select Hotfixid,Installedby,Installedon,Caption | ft -AutoSize

This command gets all of the hotfixes and selects the properties we are interested in,
then it formats the results in a table (ft) with each column autosized appropriately.

© 2013 Microsoft Corporation

Microsoft Confidential
18 PowerShell v4 Introduction

Lab 2: Advanced PowerShell v4


Introduction
In this lab, you will use PowerShell Desired State Configuration (DSC) and PowerShell
Workflow to change computer names, change IP addresses, create an Active Directory
Forest, join a computer to a domain, and add a replica DC. You will install PowerShell
Web Access to allow any device with a web browser to utilize PowerShell functionality.

Objectives
After completing this lab, you will be able to:
 Understand and create PowerShell DSC scripts
 Install PowerShell v4 on Windows Server 2008 R2
 Understand and create PowerShell Workflow scripts
 Install and use PowerShell Web Access

Prerequisites
 Student Logged into their “Host Machine” or SVVMASP## Server
 WINSRV-AD1, WINSERV-WEB1, and WINSRV-2008 are running,

Estimated time to complete this lab


30 minutes

Scenario
You are required to build a repeatable process to deploy a new Windows Server 2012 R2
Forest. This process needs to verify that all settings are correct. If not, the process will
need to fix all settings that are out of compliance.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 19

Exercise 1: Desired State Configuration


Objectives
In this exercise, you will:
 Use PowerShell DSC to configure a server with the correct Name and IP
Address.
 Use PowerShell DSC and the DSC Resource Kit to build a new AD Forest.

Scenario (if applicable)


You are asked to deploy a new 2012 R2 AD Forest for a test domain. You will need to
quickly deploy and re-deploy this environment. You will use PowerShell DSC to configure
the environment.

Task 1: Change the Computer Name and IP Address using DSC


1. Make sure you are on WINSRV-AD1 and logged on as Administrator.

2. Open Windows Explorer by clicking the yellow folder


on the taskbar.

3. Navigate to C:\labfiles\scripts directory.

4. Right click WINSRV-AD1ChangeNameAndIP choose Edit.

5. The PowerShell ISE window will open. In the bottom blue command window type
Hostname and press enter.

6. Type Ipconfig and press enter

© 2013 Microsoft Corporation

Microsoft Confidential
20 PowerShell v4 Introduction

Notice the current Name and IP Address of the computer. We will be running a
DSC script that will change the name to WINSRV-AD1 and the IP address to
192.168.1.103

7. Review the script in the script view pane. The first line of the script is very important.
It starts the DSC configuration settings by using a new keyword in PowerShell v4,
called Configuration. It is followed by the name of the configuration. In our script
it is named ChangeComputerNameAndIP

8. The following lines are required to import the DSC resource kit modules.

The next section uses the Node keyword to determine which computer(s) will apply the
changes, in this case it is the localhost.

9. These two sections are assigning the IP address for the computer and configuring
the DNS server.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 21

The boxes shaded with blue indicate the resource that will be performing the
action. The boxes shaded in red are friendly type names. These names can be
anything the Admin choses to describe the desired setting.

10. The next section will change the name of the computer to WINSRV-AD1.

11. We are done with the changes that we would like to make using this DSC script,
so we need to close the Node section and the configuration section with two
Brackets " } "

12. MOF files are used test or modify the settings on the computer. Create these files
by calling the name of the Configuration at the top of the script. The files are
stored in a folder with the same name.

13. Finally, we will call the DSC script to do the testing and changes.

© 2013 Microsoft Corporation

Microsoft Confidential
22 PowerShell v4 Introduction

14. After looking through the script, and when you are ready to run it, click the green
triangle at the top of the PowerShell ISE screen.

15. View the progress bar and the steps the script is taking in the bottom command
window.

Notice the warning that the computer name change will only take effect after the
required reboot.

a. To reboot the computer, in the bottom blue command window type:


Restart-Computer –Force

16. After the computer finishes the reboot, logon as Administrator password:
LS1setup!

17. Open Windows PowerShell


18. Type Hostname. It should now be WINSRV-AD1

19. Type Ipconfig. It should now be 192.168.1.103

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 23

In some cases, the IP Address does not change. This is because the VM is
Important: defaulting to “Ethernet 2” instead of “Ethernet”, which the script is designed to seek.
The Ipconfig result for this error would look like this:

IF for some reason your IP Address has not changed, Repeat steps 2-6. You
only need to do this if you have this specific issue. Otherwise, continue to
Task 2.
In the script view, change the following two lines of script to reflect your
VMs InterfaceAlias. Click Save.

Task 2: Promote the first DC in the Contoso Domain using DSC


1. Make sure you are on WINSRV-AD1 and logged on as Administrator.
2. In the PowerShell window, navigate to the c:\labfiles\scripts directory
a. Type: cd\
b. Type: cd labfiles\script

3. Run the DSC script called InstallContosoDomain.ps1


a. Type the first few characters, then use tab complete. Eg Install<tab> it
should autocomplete and look like the following:
.\InstallContosoDomain.ps1

b. The first Prompt is for the Safe Mode Admin Password. Type the following
and click OK:
User Name: Administrator
Password: LS1setup!

© 2013 Microsoft Corporation

Microsoft Confidential
24 PowerShell v4 Introduction

c. The next prompt is for the Domain Admin credentials. We do not need
these when we are building the first DC, only when we are adding DCs to
a domain or verifying the domain settings are correct. Type the following
and click OK:
User Name: contoso\administrator
Password: LS1setup!

d. A progress screen should appear. This installation will take a 3-5 of


minutes to complete.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 25

4. The script should begin to install the Cntoso forest. When it completes, scroll
back up the screen to look at the steps performed to promote this server to a
Domain Controller. Notice the warning about the server requiring a reboot, type:
Restart-Computer –force
After reboot, the system configuration before log-in take a few moments.

5. After the reboot completes, logon as:


User Name: contoso\administrator
Password: LS1setup!

6. The Server is now a Domain Controller for the Contoso Forest

7. Go to Server Manager—>Local Server. Look at Domain and Ethernet setting to


see the changes reflected.

Task 3: Join WINSRV-WEB1 to the Contoso Domain


1. The following Tasks will be completed on WINSRV-WEB1 , make sure you are on
WINSRV-WEB1 and logged on as a local Administrator
(LocalHost\Administrator).
2. Open Windows Explorer by clicking the yellow folder on the taskbar.
3. Navigate to C:\labfiles\scripts directory
4. Right click WINSRV-WEB-1JoinDomain choose Edit.
5. Run Script.
6. A box will pop up requesting credentials to use for joining the domain.

© 2013 Microsoft Corporation

Microsoft Confidential
26 PowerShell v4 Introduction

User Name: contoso\administrator


Password: LS1setup!
7. When the script is complete, verify that it completed without errors. Reboot the
server by typing:

8. When the server reboots, choose other user and logon with the following
credentials:
Username: contoso\administrator
Password: LS1setup!

9. Go to Server Manager  Local Server to ensure settings have been modified.

In some cases, the IP Address does not change. This is because the VM is defaulting
Important: to “Ethernet 2” instead of “Ethernet”, which the script is designed to seek.

The Ipconfig results for the error will look like this:

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 27

COMPLETE THE FOLLOWING ONLY IF YOU HAVE THE DESCRIBED ISSUE


ABOVE.

1. Repeat steps 2-3


In the script view, change the following two lines of script to reflect your VMs
InterfaceAlias. Click Save.

IPAddress NewIPAddress
IPAddress = 192.168.1.220
InterfaceAlias = “Ethernet 2”
Subnetmask = 24
AddressFamily = “IPV4”

DnsServerAddress DnsServerAddress
Address = “192.168.1.103”
InterfaceAlias = “Ethernet 2”
AddressFamily = “IPV4”

Repeat steps 5-9

© 2013 Microsoft Corporation

Microsoft Confidential
28 PowerShell v4 Introduction

Exercise 2: Using PowerShell Workflows


Objectives
In this exercise, you will:
 Use PowerShell Workflow to configure Windows Server 2008 R2 as a Replica
DC.

Scenario (if applicable)


You need to deploy a website to multiple servers. The content exists in a
development environment. You need to build it for production.
Prerequisites (if applicable)
None.

Task 1: Prepare WINSRV-2008 Server


Use PowerShell Workflow to join the server to the domain and promote it as a Domain
Controller.
1. From Hyper-V Manager, start WINSRV-2008.
2. Connect to WINSRV-2008 from Hyper-V
3. Click Configure Networking in the “Initial Configuration Tasks” window.

4. Right Click Local Area Connection and choose Properties

5. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 29

6. Select “Use the following IP address”


IP Address: 192.168.1.222
Subnet mask: 255.255.255.0
Default gateway: Empty
Preferred DNS server: 192.168.1.103
7. Click OK.
8. Close the Network Connections window.

Task 2: Installing Windows Management Framework 4.0


(PowerShell v4)
1. Open Windows Explorer
2. Navigate to c:\labfiles\WMF 4
3. Double click Windows6.1-KB2819745-x64-MultiPkg to install WMF 4.
4. Click Yes to install the update.
5. Click I accept.
6. After it finishes installing, click Restart Now.
Windows Server 2008 R2 requires the following pre-requisites to install:
 PowerShell v4 .Net 4.5.1
 Windows Management Framework 4.0

7. Click the Ctrl-Alt-Delete button

8. Logon to the server with the following credentials:

© 2013 Microsoft Corporation

Microsoft Confidential
30 PowerShell v4 Introduction

Username: administrator
Password: LS1setup!
9. Open Windows PowerShell.
10. Verify that PowerShell v4 is installed, type: $PSVersionTable
PSVersion should be 4.0

11. Prepare Windows Server 2008 R2 to be managed remotely:


a. In Windows PowerShell, type Enable-PSRemoting
b. Answer A to the two following prompts.
c. To allow scripts to run, type Set-ExecutionPolicy RemoteSigned
d. Answer Y to the next prompt

If Tasks 1 and 2 are not completed successfully, you will not be able to complete the
Important: Workflow. Do not skip these steps.

Task 3: Promote WINSRV-2008 as a Domain Controller


1. On WINSRV-AD1, open Windows Explorer.

Be sure you are on WINSRV-AD1 or the next task items will not work.
Important:

2. Browse to c:\labfiles\scripts. Right click Install-ReplicaDCWorkflow and


choose Edit.
3. Workflows are a series of tasks that can run in sequence or in parallel. They can
also survive reboots. Read the script. Notice the first command is netdom used to
join the contoso domain. After a computer joins a domain, it must reboot. The
wait parameter in the Restart-Computer cmdlet tells the script to wait until WMI is
accessible on the rebooted machine. It then runs the next step in the workflow. The
invoke-command cmdlet is used to run the command on the remote computer. In
our case, it runs DCPromo to promote the server to a DC.
4. Run the script by clicking the green arrow in the top toolbar.
5. Notice in the middle of the script window, the status of the script and the reboot
process.
WINSRV-2008 should reboot 3 times and should be a Domain Controller when it is
finished.

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 31

Exercise 3: Using PowerShell Web Access


Objectives
In this exercise, you will:
 Install PowerShell Web Access (PSWA)
 Explore the functionality of PSWA

Scenario
You need to deploy a management tool that allows any device access to manage
the server environment.
Prerequisites
Make sure that WINSRV-AD1, WINSRV-WEB1, and WINSRV-2008 are running.

Task 1: Installing PowerShell Web Access using PowerShell


1. Logon to WINSRV-WEB1 as Contoso\Administrator

2. Open PowerShell using the icon next to the start button.

3. Type the following command on one line and press Enter:


Install-WindowsFeature -Name WindowsPowerShellWebAccess
-IncludeManagementTools

There is a space between WindowsPowerShellWebAccess and –IncludeManagementTools

4. Type the following command on one line and press Enter:


Install-PswaWebApplication -UseTestCertificate

Important: The UseTestCertificate parameter should only be used in a private


test environment. For a secure production environment, we recommend using
a valid certificate that has been signed by a CA.

5. Type the following on one line and then press Enter:

Add-PswaAuthorizationRule -UserName contoso\administrator


-ComputerName * -ConfigurationName *

This authorization rule allows a specific user (contoso\administrator) access to


all computers on the network to which they typically have access, with access to
a specific session configuration that is scoped to the user’s typical scripting and
cmdlet needs.

© 2013 Microsoft Corporation

Microsoft Confidential
32 PowerShell v4 Introduction

6. Switch servers to WINSRV-AD1 and log in if you are not already, Open Server
manager and In the Server Manager Dashboard, click on Local Server on the left
side.

7. In the Server Properties for the Local Server, you will see the option for IE
Enhanced Security Configuration. Click ‘On’ to change the option. If
Administrators is already ‘Off’, skip step 8.

8. A prompt with the options to turn off Internet Explorer Enhanced Security
Configuration for Administrators and/or Users. Turn Off for Administrators and
Click OK.
9. Open Internet Explorer and browse to https://winsrv-web1/pswa. As we are
using a Test Certificate, you will see a warning. Click on Continue to this website
(not recommended). If you see a security warning, click ok.
10. Once you click on Continue you will see a Windows PowerShell Web Access
login

© 2013 Microsoft Corporation

Microsoft Confidential
PowerShell v4 Introduction 33

a. User name: Contoso\Administrator


b. Password: LS1setup!
c. Leave Connection Type at Computer Name
d. Computer name: WINSRV-2008
e. Click Sign In

11. Type Hostname. Press Enter.


Though we are logged into WINSRV-AD1, we are running PowerShell
commands on WINSRV-2008 (see hostname below) and connected with a web
browser to WinSrv-Web1 (see address at top)

© 2013 Microsoft Corporation

Microsoft Confidential

You might also like