CDP H201 PDF
CDP H201 PDF
2012 R2
2012 R2 – Windows
PowerShell Desired
State Configuration Hands-on lab
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter
in this document. Except as expressly provided in any 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.
Microsoft Hyper-V, Internet Explorer, Windows, Windows PowerShell, and Windows Server 2012 are trademarks of the Microsoft
group of companies.
Introduction
Objectives
After completing this lab, you will be able to:
Prerequisites
Before working on this lab, you must have:
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 3
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
icon. If you encounter a shield icon, confirm your action by selecting the appropriate button in the dialog
box that is presented.
Note on activation
The virtual machines for these labs may have been built by using software that has not been activated.
This is by design in the lab to prevent the redistribution of activated software. The unactivated state of
software has been taken into account in the design of the lab. Consequently, the lab is in no way affected
by this state. For operating systems other than Windows 8.1, click Cancel or Close if prompted by an
activation dialog box. If you are prompted by an Activate screen for Windows 8.1, press the Windows key
to display the Start screen.
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 4
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
Begin this task logged on to Server1 as Contoso\Administrator using the password Passw0rd!
SProviders.
The resources available are:
Resource Purpose
Archive Unpack archive files (.zip) at a path
Registry Manage registry keys and values
Script Ability to run Windows PowerShell script blocks
Package Install and manage MSI packages
Environment Manage system environment variables
Group Manage local groups
User Manage local user accounts
Service Manage services
File Manage files and folders
Log Write messages to the Microsoft-Windows-Desired State Configuration
even log
Process Configure processes
Role Add or remove Windows Roles and Features
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 5
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
Begin this task logged on to Admin as Contoso\Administrator using the password Passw0rd!
1. On the taskbar, right-click the Windows PowerShell icon, and then click Windows PowerShell
ISE.
2. On the File menu, click New Remote PowerShell Tab.
3. In the New Remote PowerShell Tab window, in computer, type Server1, and then in the User
6. In the Windows PowerShell ISE Script Pane, type the following commands, pressing ENTER after
each one.
The code for this script file can also be found in c:\LabFiles\DSC-Scripts.ps1. Instead of typing you can
optionally copy the relevant code sections from that file.
You will be creating a script to add IIS and ASP.NET 4.5 to Server1.
↪ Configuration IISWebsite
↪ {
↪ Node Server1
↪ {
↪ WindowsFeature IIS
↪ {
↪ Ensure = “Present”
↪ Name = “Web-Server”
↪ }
↪ WindowsFeature ASP
↪ {
↪ Ensure = “Present”
↪ Name = “Web-Asp-Net45”
↪ }
↪ }
↪ }
↪ IISWebSite
installed.
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 6
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
The output of this configuration statement is a MOF file for the server Server1, in a folder named
IISWebSite. The folder represents the configuration set, and the MOF file a specific NODE (Server) in that
configuration set.
9. In Windows PowerShell ISE, type the following commands, pressing ENTER after each one.
This will verify that the web server and ASP.NET are not installed, apply the desired state which will
install the web server and ASP.NET, and then verify the results.
10. In Windows PowerShell ISE, type the following command, and then press ENTER.
This will verify that the web server and website are now running,
Begin this task logged on to Admin as Contoso\Administrator using the password Passw0rd!
1. On the taskbar, right-click Windows PowerShell, and then click Windows PowerShell ISE.
2. On the File menu, open a New Remote PowerShell Tab, and then connect to Server1.
3. In Windows PowerShell ISE, navigate to C:\LabFIles\Server1, and then open
DSC-Server1-IIS.ps1.
This is the file you created in the previous tasks
↪ Configuration IISWebsite
↪ {
↪ Node Server1
↪ {
↪ WindowsFeature IIS
↪ {
↪ Ensure = “Present”
↪ Name = “Web-Server”
↪ }
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 7
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
↪ WindowsFeature ASP
↪ {
↪ Ensure = “Present”
↪ Name = “Web-Asp-Net45”
↪ }
↪ }
↪ }
↪ IISWebSite
5. Add the following commands on line 15 after the closing brace in the ASP WindowsFeature
section.
This script is a file block. It will copy the BakeryWebsite content from a source directory to the standard
IIS folder path.
The code for this script file can also be found in c:\LabFiles\DSC-Scripts.ps1. Instead of typing, you can
↪ File WebContent
↪ {
↪ Ensure = “Present”
↪ Type = “Directory”
↪ SourcePath = “C:\labfiles\Source\BakeryWebsite”
↪ DestinationPath = “C:\inetpub\WWWRoot\”
↪ Recurse = $true
↪ }
↪ Configuration IISWebsite
↪ {
↪ Node Server1
↪ {
↪ WindowsFeature IIS
↪ {
↪ Ensure = “Present”
↪ Name = “Web-Server”
↪ }
↪ WindowsFeature ASP
↪ {
↪ Ensure = “Present”
↪ Name = “Web-Asp-Net45”
↪ }
↪ File WebContent
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 8
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
↪ {
↪ Ensure = “Present”
↪ Type = “Directory”
↪ SourcePath = “C:\labfiles\Source\BakeryWebsite”
↪ DestinationPath = “C:\inetpub\WWWRoot\”
↪ Recurse = $true
↪ }
↪ }
↪ }
↪ IISWebSite
9. In Windows PowerShell ISE, type the following command, and then press ENTER:
Begin this task logged on to Admin as Contoso\Administrator using the password Passw0rd!
1. In Windows PowerShell ISE, type the following command, and then press ENTER.
2. Click Yes.
3. Navigate to http://server1.
Note that all images are missing.
4. In Windows PowerShell ISE, type the following command, and then press ENTER.
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 9
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
6. If you are going to be performing the next (optional) exercise, leave the Windows PowerShell ISE
console open.
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 10
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
The prerequisites for SharePoint foundation are extensive and take quite a bit of time to apply. Only
complete this exercise if you are prepared to wait up to 15 minutes. This is due to extensive installation
and the need to download some components from the Internet.
Begin this task logged on to Admin as Contoso\Administrator using the password Passw0rd!
1. In the Windows PowerShell ISE console you left open from the previous exercise, open the file
C:\LabFIles\DSC-SharePoint.ps1.
This file includes all role prerequisites needed for a SharePoint Foundation 2013 deployment.
You may observe that the Media Foundation has been marked as commented, causing it to be skipped.
Media Foundation requires a system restart so it was omitted from this configuration run simply to
If you open a new Windows PowerShell ISE console, ensure that you connect to Server1 using the New
by copying the files from a distribution source. It will produce an updated MOF file.
4. In Windows PowerShell ISE, type the following command, and then press ENTER.
5. In Windows PowerShell ISE, type the following command, and then press ENTER.
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 11
Windows Server 2012 R2 – Windows PowerShell Desired State Configuration
For this command to succeed, you must be connected to Server1 in the PowerShell ISE.
6. In Windows PowerShell ISE, type the following command, and then press ENTER.
7. In Windows PowerShell ISE, type the following command, and then press ENTER:
The value and entry for DisableLoopbackCheck is no longer listed and the command returns an error.
8. In Windows PowerShell ISE, type the following command, and then press ENTER:
9. In Windows PowerShell ISE, type the following command, and then press ENTER:
The value and entry for DisableLoopbackCheck is presented and restored based on the standardization
Lab created by HynesITe, Inc. For questions or comments, send an email message to [email protected] Page | 12