20417A_03.pdf

download 20417A_03.pdf

of 25

Transcript of 20417A_03.pdf

  • 7/27/2019 20417A_03.pdf

    1/25

    MicrosoftJump Start

    M3: Managing WindowsServer 2012 by UsingWindows PowerShell 3.0

    Rick Claus | Technical Evangelist | MicrosoftEd Liberman | Technical Trainer | Train Signal

  • 7/27/2019 20417A_03.pdf

    2/25

    Jump Start Target Agenda | Day One

    Day 1 Day 2

    Module 1: Installing and ConfiguringServers Based on Windows Server2012

    Module 7: Implementing FailoverClustering

    Module 2: Monitoring andMaintaining Windows Server 2012

    Module 8: Implementing Hyper-V

    Module 3: Managing Windows Server2012 by Using PowerShell 3.0

    Module 9: Implementing FailoverClustering with Hyper-V

    - MEAL BREAK - - MEAL BREAK -

    Module 4: Managing Storage forWindows Server 2012

    Module 10: Implementing DynamicAccess Control

    Module 5: Implementing NetworkServices

    Module 11: Implementing ActiveDirectory Domain Services

    Module 6: Implementing Direct Access Module 12: Implementing ActiveDirectory Federation Services

  • 7/27/2019 20417A_03.pdf

    3/25

    Module Overview

    Overview of Windows PowerShell 3.0 Using PowerShell 3.0 to Manage AD DS

    Managing Servers by Using PowerShell 3.0

  • 7/27/2019 20417A_03.pdf

    4/25

    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-basedadministrative tools of Microsoft can rest:

    Actions can be accomplished in its command-lineconsole

    Actions can be invoked within GUIs by runningPowerShell commands in the background

  • 7/27/2019 20417A_03.pdf

    5/25

    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 provideconfiguration 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

  • 7/27/2019 20417A_03.pdf

    6/25

    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

  • 7/27/2019 20417A_03.pdf

    7/25

    DEMO: Using the Windows PowerShell ISE

    In this demonstration, you will use the Windows

    PowerShell Integrated Scripting Environment (ISE)

  • 7/27/2019 20417A_03.pdf

    8/25

    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 helpdisplayed. 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-EventLogGet-EventLog -help

  • 7/27/2019 20417A_03.pdf

    9/25

    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 followingcommand:

    Get-Module

    Modules can be of the following types:

    Script

    Binary

  • 7/27/2019 20417A_03.pdf

    10/25

    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 WindowsPowerShell remoting are:

    1-to-1 Remoting

    1-to-Many (or Fan-Out) Remoting

    Many-to-1 (or Fan-In) Remoting

    Local Remote

    RunCommand

  • 7/27/2019 20417A_03.pdf

    11/25

    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

    U i th A ti Di t M d l f

  • 7/27/2019 20417A_03.pdf

    12/25

    Using the Active Directory Module forWindows PowerShell

    The Active Directory PowerShell Module included in

    Windows Server 2012, provides over 130 cmdlets formanaging Active Directory objects, such as:

    Computer Accounts

    User Accounts

    Service Accounts Groups

    Organizational Units

    Replication

    Trusts

    Central Access Policies

    Password Polices

  • 7/27/2019 20417A_03.pdf

    13/25

    Using Windows PowerShell Variables

    A variable is a temporary holding place in memory for avalue, object, or collection of objects

    Variables are named, and their names are preceded with adollar sign

    =$ADDS Get-ADDomain

  • 7/27/2019 20417A_03.pdf

    14/25

    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 secondcmdlet makes a pipeline

    Get-ADUser Filter *| Enable-ADAccount

    EnableADAccount

    Cmdlet

    Get-ADUserCmdlet

    ProcessObject

    Pipe

  • 7/27/2019 20417A_03.pdf

    15/25

    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)

  • 7/27/2019 20417A_03.pdf

    16/25

    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.ps1E:\Mod03\Democode\Get-LatestLogon.ps1

    i i d h ll d di i l

  • 7/27/2019 20417A_03.pdf

    17/25

    Using Windows PowerShell Loops and ConditionalExpressions

    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}

  • 7/27/2019 20417A_03.pdf

    18/25

    DEMO: Managing AD DS by Using PowerShell

    In this demonstration, you will manage AD DS by using

    Windows PowerShell

    A i Di Ad i i i C I i

  • 7/27/2019 20417A_03.pdf

    19/25

    Active Directory Administrative Center Integrationwith Windows PowerShell

    Allows management of user accounts, computeraccounts, groups, and organizational units

    Provides a Windows PowerShell history of allcommands used

    Is a Windows PowerShell learning tool

    Di i Th N d f Wi d P Sh ll f

  • 7/27/2019 20417A_03.pdf

    20/25

    Discussion: The Need for Windows PowerShell forServer Management

    I

  • 7/27/2019 20417A_03.pdf

    21/25

    What Is Windows PowerShell Web Access?

    Internet

    WindowsPowerShellWeb Access

    Gateway

    OrganizationPerimeterNetwork

    Organization

    Network

    Target 1

    Target 2

    Target n

    .

  • 7/27/2019 20417A_03.pdf

    22/25

    What Are Windows PowerShell Jobs?

    Background Jobs:

    Enable extended tasks to be performed in thebackground

    Perform tasks on a number of remote servers

    Scheduled Jobs:

    Registered background jobs that can run on aschedule

    Triggers are created to define schedule

  • 7/27/2019 20417A_03.pdf

    23/25

    Introduction to Windows PowerShell Workflow

    Enables automating long-running and complexactivities

    Enables automating multiple server managementand application provisioning

    Enables processes to be resumed, paused, andrestarted

    Created by using Windows PowerShell or Visual

    Studio Workflow Designer

    Windows Server 2012 includes over 60 predefinedworkflows

  • 7/27/2019 20417A_03.pdf

    24/25

    Quick Review

    What happens if you try to run an unsigned scriptthat you have created locally and the executionpolicy is set to RemoteSigned?

    When a user that is not authorized attempts to

    logon to Windows PowerShell Web Access, whatoccurs?

  • 7/27/2019 20417A_03.pdf

    25/25