automating windows server 2008 r2 administration with windows powershell

22

Click here to load reader

Upload: alexandair

Post on 16-Apr-2017

4.913 views

Category:

Technology


7 download

TRANSCRIPT

Page 1: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Automating Windows Server 2008 R2 Administration with Windows PowerShell

Aleksandar Nikolić, PowerShell MVPTwitter: @alexandair

October 20, 2011

Page 2: Automating Windows Server 2008 R2 Administration with Windows PowerShell

What is Windows PowerShell?

• Not just a command-line shell• Not just a scripting language• An automation engine, an automation platform• Designed especially for system administration• Cmdlets – built-in PowerShell commands

Page 3: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Why Windows PowerShell? (1)

• To automate administrative tasks• Manage the computers from the command-line• Access to file system, Registry, certificate store…• The Admin Development Model

– An interactive shell -> quick and dirty scripting -> a formal production scripting

• Based on the .NET Framework

Page 4: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Why Windows PowerShell? (2)

• Consistency and discoverability• Standards-based management (WMI/CIM and WSMan)• Extensible (PowerShell modules/snap-ins)• Great help system• PowerShell vs. GUI PowerShell and GUI

Page 5: Automating Windows Server 2008 R2 Administration with Windows PowerShell

How to get it?

• Windows PowerShell v2• Windows 7 and Server 2008 R2

– A part of the operating system– Server Core! (optional feature)

• XP SP3, Vista SP2, Server 2003 SP2, and 2008 SP2– Windows Management Framework (KB968929)– Windows Update and WSUS

Page 6: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Windows PowerShell in a Nutshell

• Cmdlets (Verb-Noun)• PSProviders and PSDrives• Get-Help, Get-Command, Get-Member, Get-PSDrive• Pipeline• Sends objects down the pipeline• -WhatIf and –Confirm parameters

Page 7: Automating Windows Server 2008 R2 Administration with Windows PowerShell

DEMO:basic commands

Page 8: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Automating Management Tasks

• Standards-based management (WMI/CIM and WSMan)• Local and remote• PowerShell jobs• Task scheduling

Page 9: Automating Windows Server 2008 R2 Administration with Windows PowerShell

CustomPowerShellEndpoint

Management Stack in PowerShell v2

DCOMClient

DCOMService

WMIEngine

PowerShellRemoting

WinRMClient

ServerManagerConsole

ManagementApplication

DefaultPowerShellEndpoint

WMI

PowerShell

ProvidersProvidersDCOM

WS-ManagementWinRMService

Page 10: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Internet

Management Station

wsman.msft.netManaged Source

CommunicationPathway

Standards-Based Management

• Protocol: DMTF Standard Protocol: Web Services Management (WSMan)• Agent: The WinRM service in Windows implements the server role of the WSMan protocol. WMI

implements the CIMOM.• Tool: WSMan cmdlets allow access to any device that complies with CIM and WSMan standards• Extensions: Microsoft extensions to WSMan enable PowerShell remoting (1-1, 1-many, many-1)

Management Station

Managed Source

https (port 5986)

Page 11: Automating Windows Server 2008 R2 Administration with Windows PowerShell

DEMO:managementtasks

Page 12: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Extending Windows PowerShell

• Think about MMC snap-ins• A set of related PowerShell functionalities• To package and deploy PowerShell functionalities• PSSnapins (v1+)

– Get-PSSnapin –Registered– Quest AD cmdlets and VMware vSphere PowerCLI cmdlets

• Modules (v2+)– Get-Module –ListAvailable– include cmdlets, providers, functions, variables, aliases

Page 13: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Built-in Modules

Name Command to import module or add snap-in

Active Directory Rights Management Services module for Windows PowerShell

Import-Module ADRMS

Application ID Policy Management module for Windows PowerShell

Import-Module AppLocker

Best Practice Analyzer module for Windows PowerShell

Import-Module BestPractices

Background Intelligent Transfer Service (BITS) module for Windows PowerShell

Import-Module BITSTransfer

Server Manager module for Windows PowerShell Import-Module ServerManager

Troubleshooting pack support Import-Module TroubleshootingPack

Page 14: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Name Required installed role or feature Command to import module or add snap-in

Active Directory module for Windows PowerShell Requires installation of the Active Directory Domain Services role

Import-Module ActiveDirectory

Active Directory Rights Management Services administration module for Windows PowerShell

Requires installation of the AD RMS role. Import-Module ADRMSAdmin

Failover Clusters module for Windows PowerShell Requires installation of the Failover Clustering feature.

Import-Module FailoverClusters

Group Policy module for Windows PowerShell Requires installation of the Group Policy Management feature.

Import-Module GroupPolicy

Network Load Balancing Clusters module for Windows PowerShell

Requires installation of the Network Load Balancing feature.

Import-Module NetworkLoadBalancingClusters

Remote Desktop Services module for Windows PowerShell

Requires installation of the Remote Desktop Services role.

Import-Module RemoteDesktopServices

Server Migration module for Windows PowerShell Requires installation of the Windows Server Migration Tools feature

Add-PSSnapin Microsoft.Windows.ServerManager.Migration

Windows Backup snap-in for Windows PowerShell Requires installation of the Windows Server Backup Features: Windows Server Backup and Command-line Tools.

Add-PSSnapin Windows.ServerBackup

Internet Information Services (IIS) module for Windows PowerShell

Requires installation of the Web Server (IIS) role Import-Module WebAdministration

Web Services for Management (WS-Management) Requires installation of Web Services for Management (WS-Management) role

Add-PSSnapin Microsoft.WSMan.Management

Page 15: Automating Windows Server 2008 R2 Administration with Windows PowerShell

DEMO:built-inmodules

Page 16: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Windows PowerShell in Action, Second EditionBruce Payettehttp://www.manning.com/payette2/

Windows PowerShell Cookbook, Second EditionLee Holmeshttp://oreilly.com/catalog/9780596801519

Administrator's Guide to Windows PowerShell RemotingDr. Tobias Weltner, Aleksandar Nikolic, Richard Gileshttp://powershell.com/cs/media/p/4908.aspx

Further Reading

Page 17: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Requirements

• Windows PowerShell requires Microsoft .NET Framework 2.0 SP1

• PowerShell ISE requires Microsoft .NET Framework 3.5 SP1

• Out-GridView requires Microsoft .NET Framework 3.5 SP1

• Get-WinEvent requires Vista or newer and Microsoft .NET Framework 3.5

• Get-Counter and Import-Counter require Vista or newer

• Export-Counter requires Windows 7

Page 18: Automating Windows Server 2008 R2 Administration with Windows PowerShell

• Microsoft Windows PowerShell– http://www.microsoft.com/powershell

• Windows PowerShell Team Blog– http://blogs.msdn.com/PowerShell

• MS TechNet Script Center– http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

• PowerShell Forum– http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/

• Windows PowerShell Survival Guide– http://social.technet.microsoft.com/wiki/contents/articles/windows-

powershell-survival-guide.aspx

Microsoft Resources

Page 19: Automating Windows Server 2008 R2 Administration with Windows PowerShell

• PowerShell Community– http://powershellcommunity.org

• PowerShell Code Repository– http://poshcode.org

• PowerShell.com Community– http://powershell.com

• PowerGUI.org Community– http://powergui.org

• PowerShell Magazine– http://powershellmagazine.com

• irc.freenode.net #PowerShell

Community Resources

Page 20: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Thank you for your attention.

Page 21: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Microsoft and Open Source

gateway for deeper exploration of open

source engagements

http://www.microsoft.com/openness

Port25blogs from the

platform community and the OSS Lab

teams http://Port25.technet.com

Codeplexresources for

developers and consumers of open

source projectshttp://www.codeplex.com

Interoperability Bridgestechnical

collaborative works http://www.interoperabilitybridges.com

Open Upcross-Industry

Interoperability and Standards activitieshttp://www.microsoft.com/interop/openup

Shared Sourceportal for

programmatically sharing code

http://www.microsoft.com/sharedsource

ODataopen source starter

kit for Internet publishing of

Government datasets using the Open Data

http://ogdisdk.cloudapp.net

Open Specprotocols, file

formats, standards, technical

specificationshttp://www.microsoft.com/openspecifications

BizSparkProgram for Start-Up

companies from both commercial and open source

backgroundshttp://www.microsoft.com/bizspark

Openness and Interoperability @Microsoft

How can I receive up-to-date Openness announcements from Microsoft?In addition to the websites above, you can receive regular updates to Microsoft’s openness, interoperability and standards efforts via the following channels:• http://blogs.technet.com/b/openness/ • http://blogs.msdn.com/b/interoperability/ • http://twitter.com/OpenAtMicrosoft • http://port25.technet.com • http://channel9.msdn.com/Blogs/Interoperability

Page 22: Automating Windows Server 2008 R2 Administration with Windows PowerShell

Help us choose the best Sinergija lecturer! Telekom

Srbija and Microsoft will award you – at the conference end, we’ll give one HTC Mozart WP7 phone to someone from

the audience – randomly.

Go to www.mssinergija.net, log in and cast your votes.

Please rate this lecture

and WIN HTC MOZART!

You can rate only lectures that you were present at, just once. More lectures you rate, more chances you have.Please use computers at the front of this room, or rate lecture from your phone or home computer, at Sinergija

portal. This prize contest will end at Thursday, October 20th at 9 PM. Winner will be announced at the official Sinergija web

portal, www.mssinergija.net

is a friend of Sinergija 2011 Conference and Imagine Cup student competition in Serbia.