Post on 20-Jan-2017
Microsoft® Jump Start
M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0
Rick Claus | Technical Evangelist | Microsoft
Ed Liberman | Technical Trainer | Train Signal
Jump Start Target Agenda | Day One
Day 1 Day 2
Module 1: Installing and Configuring
Servers Based on Windows Server
2012
Module 7: Implementing Failover
Clustering
Module 2: Monitoring and
Maintaining Windows Server 2012
Module 8: Implementing Hyper-V
Module 3: Managing Windows Server
2012 by Using PowerShell 3.0
Module 9: Implementing Failover
Clustering with Hyper-V
- MEAL BREAK - - MEAL BREAK -
Module 4: Managing Storage for
Windows Server 2012
Module 10: Implementing Dynamic
Access Control
Module 5: Implementing Network
Services
Module 11: Implementing Active
Directory Domain Services
Module 6: Implementing Direct Access Module 12: Implementing Active
Directory Federation Services
Module Overview
•Overview of Windows PowerShell 3.0
•Using PowerShell 3.0 to Manage AD DS
•Managing Servers by Using PowerShell 3.0
What Is Windows PowerShell?
•An object-based management environment
•An engine that enables administrators to: – Create automation scripts
– Perform batch modifications
– Access unavailable settings
• Provides a foundation upon which the GUI-based
administrative tools of Microsoft can rest: – Actions can be accomplished in its command-line
console
– Actions can be invoked within GUIs by running
PowerShell commands in the background
Windows PowerShell Syntax
Verb Noun Cmdlet
Get EventLog Get-EventLog
Set ExecutionPolicy Set-ExecutionPolicy
New VM New-VM
• Verb-Noun pair naming is as follows:
• Use cmdlet parameters to modify actions and provide
configuration information. Parameters include:
• Named. -EventLog System, -UserName John
• Switch. -Verbose, -Debug, -Confirm
• Positional.
• Get-EventLog System
• Get-EventLog –LogName System
• Common parameters: -WhatIf, -Debug, -Verbose, -Confirm
Cmdlet Aliases
Common Aliases:
• cd -> Set-Location
• dir -> Get-Child-Item
• ls -> Get-Child-Item
• copy -> Copy-Item
• kill -> Stop-Process
• rm -> Remove-Item
• type -> Get-Content
• help -> Get-Help
You can use aliases for:
• Backward compatibility
• Shorten scripts
• Easier discoverability
DEMO: Using the Windows PowerShell ISE
• In this demonstration, you will use the Windows
PowerShell Integrated Scripting Environment (ISE)
Accessing Help in Windows PowerShell
• To access the Help documentation, run Get-Help or the
alias help followed by the cmdlet name:
• Get-Help has parameters to adjust the amount of help
displayed. The parameters are:
• -detailed
• -examples
• -full
• -online
• Other cmdlets that you can use for accessing help: Update-Help, Show-Command, Get-Command, and tab completion
Get-Help Get-EventLog
Get-EventLog -help
Using Windows PowerShell Modules
Windows PowerShell is extended through modules
• You can import modules by using the Import-Module cmdlet:
Import-Module Hyper-V
• You can list loaded modules by running the following
command:
Get-Module
• Modules can be of the following types:
• Script
• Binary
What Is Windows PowerShell Remoting?
• The purpose of Windows PowerShell remoting is to:
Connect to a remote computer
Run one or more commands on that computer
Bring those results back to your computer
• The goals of Windows PowerShell remoting are:
Single-seat administration
Batch administration
Lightweight administration
• The three ways to use Windows PowerShell remoting are:
1-to-1 Remoting
1-to-Many (or Fan-Out) Remoting
Many-to-1 (or Fan-In) Remoting
Local Remote
Run
Command
What Is New in Windows PowerShell 3.0?
Windows PowerShell 3.0 improvements include:
• Over 260 core cmdlets
• Management of all Windows Roles and Features
• Windows PowerShell Workflow
• Windows PowerShell Web Access
• Scheduled Jobs
• Enhanced Online Help
• ISE Autosense
• Robust Session Connectivity
Using the Active Directory Module for Windows PowerShell
The Active Directory PowerShell Module included in
Windows Server 2012, provides over 130 cmdlets for
managing Active Directory objects, such as:
• Computer Accounts
• User Accounts
• Service Accounts
• Groups
• Organizational Units
• Replication
• Trusts
• Central Access Policies
• Password Polices
Using Windows PowerShell Variables
• A variable is a temporary holding place in memory for a
value, object, or collection of objects
• Variables are named, and their names are preceded with a
dollar sign
= $ADDS Get-ADDomain
The Windows PowerShell Pipeline
• Used to connect the output from one cmdlet to the input
of another cmdlet
• The combination of the first cmdlet, pipe, and second
cmdlet makes a pipeline
Get-ADUser –Filter * | Enable-ADAccount
Enable
ADAccount
Cmdlet
Get-ADUser
Cmdlet
Process
Object
Pipe
Options for Formatting Windows PowerShell Output
• Cmdlets for Formatting Output
• Cmdlets for Manipulating Output
Format-Table
(FT) Format-List
(FL)
Format-Custom
(FC)
Measure-Object
(measure) Sort-Object
(sort)
Select-Object
(select)
Where-Object
(where)
Format-Wide
(FW)
Creating and Running Windows PowerShell Scripts
• Execution policy restricts script execution, the execution policies
include:
• Restricted
• AllSigned
• RemoteSigned
• Unrestricted
• Bypass
• Scripts are text files with a .ps1 extension
• Scripts contain one or more commands that you want the shell
to execute in order
• Scripts, when run, require a relative or full path to be specified:
.\Get-LatestLogon.ps1
E:\Mod03\Democode\Get-LatestLogon.ps1
Using Windows PowerShell Loops and Conditional Expressions
foreach ($user in $group){
write-host $user ” is in “ $group}
if ($Today.DayOfWeek = “Monday”) {
write-host “Today is Monday”}
while ($i -ne 25) {write-host $i “is not 25”}
for ($i=1; $i < 25; $i++) {
write-host $i “is not 25”}
DEMO: Managing AD DS by Using PowerShell
• In this demonstration, you will manage AD DS by using
Windows PowerShell
Active Directory Administrative Center Integration with Windows PowerShell
•Allows management of user accounts, computer
accounts, groups, and organizational units
• Provides a Windows PowerShell history of all
commands used
• Is a Windows PowerShell learning tool
Discussion: The Need for Windows PowerShell for Server Management
I <3 PS: c:\users\administrator
I ≠ <3 PS: c:\users\administrator
What Is Windows PowerShell Web Access?
Internet
Windows
PowerShell
Web Access
Gateway
Organization
Perimeter
Network
Organization
Network
Target 1
Target 2
Target n
……
….
What Are Windows PowerShell Jobs?
Background Jobs:
• Enable extended tasks to be performed in the
background
• Perform tasks on a number of remote servers
Scheduled Jobs:
• Registered background jobs that can run on a
schedule
• Triggers are created to define schedule
Introduction to Windows PowerShell Workflow
• Enables automating long-running and complex
activities
• Enables automating multiple server management
and application provisioning
• Enables processes to be resumed, paused, and
restarted
•Created by using Windows PowerShell or Visual
Studio Workflow Designer
•Windows Server 2012 includes over 60 predefined
workflows
Quick Review
•What happens if you try to run an unsigned script
that you have created locally and the execution
policy is set to RemoteSigned?
•When a user that is not authorized attempts to
logon to Windows PowerShell Web Access, what
occurs?