Top Banner

of 47

Windows PowerShell and Windows Server 2008 R2

Apr 05, 2018

Download

Documents

alex.cordova
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    1/47

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    2/47

    Dan RegerSr. Product ManagerMicrosoft

    WSV319

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    3/47

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    4/47

    AgendaIntroduction to PowerShell

    Within the Context of ManagementPowerShell Goals and Themes

    PowerShell 2.0

    GUI over PowerShell (Demo)Production Scripting (Demo)

    Community Feedback

    Interlude - PowerShellCommunity.orgPowerShell 2.0 (continued)

    Universal Automation Environment

    Demo Compellent Technologies

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    5/47

    Todays IT Challenges

    Increasing demands from the businessReliance on technology for business-criticaloperations

    Always-available, anywhere

    Increasing complexity

    Adding capabilities adds management burden

    80% of IT cost is managing existing systems

    Trends of the future magnify challengesMove to Datacenters large scale, virtualizationremote management

    Outsourcing lower skilled, high turnover users

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    6/47

    Windows Server 2008 R2Streamlined Management Scenarios

    PowerShell: Universal Code Execution Model, GUI over PowerShell, Production Scripting

    WMI: Discoverability through PS, Profile discovery, CIM update

    WS-Man: Remote Shell, Support for hosted environments (Web proxy traversal, Federated Auth usingLive ID), Hardware Management (out-of-band management in-band with OS), Resource management

    BITS: Lightweight server

    PS cmdlets across all!

    DatacenterAutomation

    Known fact: most customers do not perform in-place upgrade

    Migration is a complex problem both from technical and process perspective

    WS7 pragmatic approach focus on understanding the problem and building foundation

    Goal: consistent documentation across all roles, Stretch: scriptable solution for core roles

    Lays foundation for more complete and richer solution in the future

    ServerMigration

    Server Manager creates consistency and enables integration

    Goal: Further improve Server Manager, adding incremental value

    Key features: PS cmdlets to add/remove roles/features, remoting, Best Practice Analyzers

    Incubating next-gen UX Active Directory User Management

    Rich ServerManagement

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    7/47

    Server Manager & PowerShell Integration

    Server Manager PowerShell Cmdlets:

    Get-WindowsFeature

    Add-WindowsFeature

    Remove-WindowsFeature

    Leverages PowerShell features/reachRicher command line experience (auto-completion,wildcards, object pipeline, etc)

    Remoting

    Availability on Server Core

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    8/47

    PowerShell

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    9/47

    As interactive and composable as BASH/KSH

    As programmatic as Perl/Python/Ruby

    As production oriented as AS400 CL/VMS DCL

    Allows access to data stores as easy to access as filesystem

    Windows PowerShellNew command-line shell and scripting language

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    10/47

    A taste of PowerShell

    Using pkgmgr to install Web Server (IIS):start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-

    StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-

    HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET; IIS-NetFxExtensibility;

    IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-

    HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;

    IIS-HttpTracing;IIS-CustomLogging;IIS-ODBCLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-

    ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;

    IIS-URLAuthorization;IIS-RequestFiltering;

    IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-

    HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-

    ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;

    IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;

    IIS-FTPPublishingService;IIS-FTPServer;IIS-FTPManagement;WAS-

    WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

    Or using Server Manager:

    Add-WindowsFeature web-server

    ORservermanagercmd install web-server

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    11/47

    Exchange 2003 (VBScript) E12 (PowerShell)

    MailboxStatistics

    Set listExchange_Mailboxs =GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\MicrosoftExchangeV2").InstancesOf("Exchange_Mailbox")

    For Each objExchange_Mailbox in listExchange_Mailboxs

    WScript.echo "AssocContentCount = + objExchange_Mailbox.AssocContentCount

    WScript.echo " DateDiscoveredAbsentInDS = +objExchange_Mailbox.DateDiscoveredAbsentInDS

    WScript.echo " DeletedMessageSizeExtended = + objExchange_Mailbox.DeletedMessageSizeExtended

    WScript.echo " LastLoggedOnUserAccount = + objExchange_Mailbox.LastLoggedOnUserAccount

    WScript.echo " LastLogoffTime = + objExchange_Mailbox. LastLogoffTime

    WScript.echo " LastLogonTime = + objExchange_Mailbox. LastLogonTime

    WScript.echo " LegacyDN = + objExchange_Mailbox. LegacyDN

    WScript.echo " MailboxDisplayName = + objExchange_Mailbox. MailboxDisplayName

    WScript.echo " MailboxGUID = + objExchange_Mailbox. MailboxGUID

    WScript.echo " ServerName = + objExchange_Mailbox. ServerNameWScript.echo " Size = + objExchange_Mailbox. Size

    WScript.echo " StorageGroupName = + objExchange_Mailbox. StorageGroupName

    WScript.echo " StorageLimitInfo = + objExchange_Mailbox. StorageLimitInfo

    WScript.echo " StoreName = + objExchange_Mailbox. StoreName

    WScript.echo " TotalItems = + objExchange_Mailbox. TotalItems

    Next

    Get-MailboxStatistics Server $servername

    DatabaseMgmt

    Dim StorGroup as New CDOEXM.StorageGroup

    StorGroup.DataSource.Open "LDAP://" + DCServer + "/ CN=First StorageGroup,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services,CN=Configuration," + DomainName

    StorGroup.MoveLogFiles("C:\newlogPath", 0)

    Move-StorageGroupPath

    -Identity First Storage Group

    Log "C:\newlogPath

    RecipientMgmt

    Dim objMailbox As CDOEXM.IMailboxStore

    Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName)

    objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First StorageGroup,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group,

    CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services,CN=Configuration," + DomainName

    Enable-Mailbox

    -Identity domain\FOO

    Database First Storage Group\Private MDB

    More Productivity

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    12/47

    Tower Of PowerPowerShell books

    Now available in

    JapaneseGerman

    French

    More

    2007 2008

    http://blogs.msdn.com/blogfiles/powershell/WindowsLiveWriter/TowerofPowerPart2_887B/001_1.jpg
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    13/47

    Discovery

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    14/47

    PowerShell V2 Goals

    Reduce the cost and effort to:Use PowerShell

    Get, learn, share scripts

    Layer applications on PowerShell

    GUI, web, workflow, etc.

    Manage anything/everything

    Servers, clients, distributed systems, applications, webservices, cloud services, raw HW, other OSes, everything

    Using any and all mechanisms (WMI, .Net, native code,web services, WSMAN)

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    15/47

    PowerShell V2 Themes

    GUI over PowerShell

    Production Scripting

    Universal Automation Environment

    Community Feedback

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    16/47

    Datacenter AutomationPowerShell

    GUI over PowerShell

    Admin GUIs layered over PowerShell

    Features: Graphical PowerShell, Outgrid View, New Engine APIs,Runspace Pooling, Thread control

    Server Role coverage:

    AD Domain Services, AD Lightweight Directory Services, ApplicationServer, Terminal Services, Web Server

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    17/47

    Datacenter AutomationPowerShell

    Production Scripting:

    Scripts are easy to use, share and support and safe to operate

    Features: Script cmdlets, debugger enhancements, restrictedlanguage, modules and transactions

    Universal Code Execution Model:

    Flexibility over where/how expressions, Commands &ScriptBlocks can run

    On one or more machines

    In restricted or unrestricted environmentsInitiated by user input or by events

    Features: Remoting, background jobs, eventing, restrictedrunspaces, mobile object model

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    18/47

    PowerShell Architecture

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Mgr

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XMLADO

    ADSI

    Native Commands

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    19/47

    Admin GUIs layer on top of PowerShellCLI & GUI

    Agility in delivering new GUIs

    Ensures automation

    GUI teaches command line

    Standardizes access to managed elements

    GUI over PowerShell

    PowerShell V2 Themes

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    20/47

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Mgr

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XMLADO

    ADSI

    Native Commands

    GUI Over PowerShell: Features

    Graphical

    PowerShell

    Out-Gridview

    New APIs

    PSSessionPooling

    Thread Control

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    21/47

    GUI Over PowerShell

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    22/47

    PowerShell V2 Themes

    Scripts areEasy to use

    Safe to operate

    Easy to share

    Easy to support

    Production Scripting

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    23/47

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Mgr

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XMLADO

    ADSI

    Native Commands

    Production Scripting: Features

    Script Cmdlets

    Restricted Language

    Modules

    Debugger Enhancements

    Transactions

    Script Cmdlets

    Native Code

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    24/47

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    25/47

    PowerShell V2 Themes

    Respond to community feedbackEnhance the language

    Tweak the engine

    Add and enhance Cmdlets

    Community Feedback

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    26/47

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Mgr

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XMLADO

    ADSI

    Native Commands

    Community Feedback: Features

    LanguageEnhancements

    ImprovedObject

    Adapters

    New Cmdlets

    WMI++

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    27/47

    PowerShellCommunity.orgHal RottenbergTitle

    Company

    http://powershellcommunity.org/
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    28/47

    PowerShellCommunity.org

    Forums

    Blogs

    Script Repository

    User GroupOutreach

    http://powershellcommunity.org/http://powershellcommunity.org/
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    29/47

    PowerScripting Podcast

    Hosts: Jonathan Walz & Hal Rottenberg

    Online at PowerScripting.net

    Weekly dose of News, Resources,

    Interviews, Tips and more!

    http://powerscripting.net/http://powerscripting.net/
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    30/47

    Virtual User Group

    Marco Shaw runs a monthly users groupmeeting online using Microsoft Live Meeting

    Interviews

    Q&A with experts

    Check news for upcoming events and Marcos

    get-powershellblog (marcoshaw.blogspot.com)

    http://marcoshaw.blogspot.com/http://marcoshaw.blogspot.com/http://marcoshaw.blogspot.com/http://marcoshaw.blogspot.com/
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    31/47

    PowerShell Newsgroup

    Use NNTP server msnews.microsoft.comor web portal

    Group name:

    microsoft.public.windows.powershell

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    32/47

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    33/47

    Microsoft Resources

    PowerShell Team Blogblogs.msdn.com/powershell

    Scripting Guys Script Centermicrosoft.com/technet/scriptcenter

    Hub for official documentation

    PowerShell Tip of the Week

    The Windows PowerShell Toolbox

    Script repository and other goodies

    http://blogs.msdn.com/powershellhttp://microsoft.com/technet/scriptcenterhttp://microsoft.com/technet/scriptcenterhttp://microsoft.com/technet/scriptcenterhttp://microsoft.com/technet/scriptcenterhttp://microsoft.com/technet/scriptcenterhttp://blogs.msdn.com/powershellhttp://blogs.msdn.com/powershell
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    34/47

    Join the Community!

    LinkedIn: PowerShell Power UsersTwitter: #powershell hashtag

    Facebook: PowerScripting Podcast, Windows

    Powershell Users, The Scripting Guys

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    35/47

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    36/47

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Mgr

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XMLADO

    ADSI

    Native Commands

    Universal Automation Features

    Remoting

    Background Jobs

    Eventing

    RestrictedPSSessions

    Mobile ObjectModel

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    37/47

    New Cmdlets (So Far)Remoting:

    Invoke-Command

    New-PSSession

    Get-PSSession

    Push-PSSession

    Pop-PSSession

    Remove-PSSession

    Converting Types:

    Add-Type

    ConvertTo-Csv

    ConvertFrom-Csv

    ConvertTo-Xml

    ConvertFrom-StringData

    Event Viewer and ETW Logs:

    Get-Event

    Script Internationalization:

    Import-LocalizedData

    Modules:

    Imort-Module

    Get-Module

    Remove-Module

    Export-ModuleMember

    Transactions:

    Complete-Transaction

    Start-Transaction

    Undo-Transaction

    Debugging:

    Set-PSBreakpoint

    Get-PSBreakpoint

    Enable-PSBreakpoint

    Disable-PSBreakpoint

    Remove-PSBreakpoint

    Get-PSCallStack

    Eventing:

    Register-ObjectEvent

    Register-EventWait-Event

    Remove-Event

    Unregister-Event

    Get-Event

    New-Event

    Get-EventSubscriber

    Background Jobs:Start-Job

    Get-Job

    Stop-Job

    Receive-Job

    Wait-Job

    Remove-Job

    WMI:

    Register-WMIEvent

    Set-WMIInstance

    Invoke-WMIMethod

    Remove-WMIObject

    More Cmdlets:

    Clear-History

    Get-Random

    Out-GridView

    Set-StrictMode

    Update-ListWait-Process

    Computer

    Add-Computer

    Checkpoint-Computer

    Disable-ComputerRestore

    Enable-ComputerRestore

    Get-ComputerRestorePoint

    Remove-Computer

    Rename-Computer

    Reset-ComputerMachinePassword

    Restart-Computer

    Restore-Computer

    Stop-Computer

    Test-ComputerSecureChannel

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    38/47

    Hyper-V Automation with Compellentand PowerShell 2.0Shane AndersonCompellent

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    39/47

    CreateHTML Report

    WindowsServer 2008R2 Hyper-V

    Host

    GoldImage

    Automation Overview

    VM

    DataFile

    C:\VirtualMachines

    = ..\TestVM30

    = ..\TestVM49

    ValidatePrerequisites Start VMs

    and Waitfor Ready

    PowerShell 2.0 Script

    M I f

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    40/47

    More InfoMicrosoft Alliance Page

    http://www.compellent.com/microsoft

    PowershellCompellent Powershell sitehttp://www.compellent.com/powershell

    Command Set White Paper

    http://www.compellent.com/~/media/com/Files/White_Papers/CML_WPS_RR.ashx

    Windows Live Community Site

    http://compellentpowershell.groups.live.com/

    Powershell Community.org

    http://www.powershellcommunity.org/

    Powershell.com

    http://www.powershell.com

    Microsoft and Compellent Joint Customer Webcast

    Saving Money while Improving Service availability at Indiana University.

    http://www.microsoft.com/virtualization

    http://www.compellent.com/microsofthttp://www.compellent.com/powershellhttp://www.compellent.com/~/media/com/Files/White_Papers/CML_WPS_RR.ashxhttp://compellentpowershell.groups.live.com/http://www.powershellcommunity.org/http://www.powershell.com/http://www.microsoft.com/virtualizationhttp://www.microsoft.com/virtualizationhttp://www.powershell.com/http://www.powershellcommunity.org/http://compellentpowershell.groups.live.com/http://www.compellent.com/~/media/com/Files/White_Papers/CML_WPS_RR.ashxhttp://www.compellent.com/powershellhttp://www.compellent.com/microsoft
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    41/47

    Summary

    The investments in Windows Server 2008 R2 area significant step towards increasing themanageability of the platform

    Expanded PowerShell - available on server core

    Remote-able

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    42/47

    C i R

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    43/47

    Community ResourcesNewsgroup: Microsoft.Public.Windows.PowerShell

    Team blog: http://blogs.msdn.com/PowerShell/

    PowerShellCommunity.Org: http://www.PowershellCommunity.Org

    Channel 9 http://channel9.msdn.com/tags/PowerShell

    Wiki

    http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki

    Script Center:http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

    CodePlex:

    http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershell

    Many excellent books

    Manning Press book by PowerShell Dev Lead Bruce Payette: PowerShell in Action

    http://manning.com/powershell/

    OReilly book by PowerShell Dev Lee Holmes Windows PowerShell Cookbook

    http://www.oreilly.com/catalog/9780596528492/index.html

    R

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    44/47

    www.microsoft.com/teched

    Sessions On-Demand & Community

    http://microsoft.com/technet

    Resources for IT Professionals

    http://microsoft.com/msdn

    Resources for Developers

    www.microsoft.com/learning

    Microsoft Certification and Training Resources

    www.microsoft.com/learning

    Microsoft Certification & Training Resources

    Resources

    R l d C

    http://www.microsoft.com/techedhttp://microsoft.com/technethttp://microsoft.com/msdnhttp://www.microsoft.com/learninghttp://www.microsoft.com/learninghttp://www.microsoft.com/learninghttp://www.microsoft.com/learninghttp://microsoft.com/msdnhttp://microsoft.com/technethttp://www.microsoft.com/teched
  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    45/47

    Related ContentWSV402 Advanced Windows PowerShell Scripting

    DAT314 Manageability Series: Microsoft SQL Server Automation on Steroids,Including PowerShell Support

    SIA313 Managing Active Directory Identities with Active Directory PowerShell

    WSV325 Windows PowerShell: Tips from the Expert

    WCL314 Windows PowerShell for the Windows 7 Enterprise Client

    WSV08-HOL Introduction to Windows PowerShell Fundamentals

    WSV19-HOL Windows Server 2008 R2: Server Management and PowerShell V2

    WSV02-HOL Administering Internet Information Services (IIS) 7.0 by Using WindowsPowerShell

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    46/47

    Complete an

    evaluation onCommNet andenter to win!

  • 7/31/2019 Windows PowerShell and Windows Server 2008 R2

    47/47