wsv315 windows power shell for beginners

29

Upload: jsnover1

Post on 15-Jan-2015

1.835 views

Category:

Technology


0 download

DESCRIPTION

Atlanta TechEd 2011 talk

TRANSCRIPT

Page 1: Wsv315 Windows Power Shell For Beginners
Page 2: Wsv315 Windows Power Shell For Beginners

Windows PowerShell for BeginnersWSV315Jeffrey SnoverDistinguished Engineer/Lead Architect for Windows Server

Mir RosenbergSenior Program ManagerMicrosoft Corporation

Page 3: Wsv315 Windows Power Shell For Beginners

BuckyBalls

Page 4: Wsv315 Windows Power Shell For Beginners

Building Blocks

Page 5: Wsv315 Windows Power Shell For Beginners

Agenda

Introduce Windows PowerShellLearning to learn PowerShellDrill into utility cmdletsWord from PowerShellCommunity.orgQ&A!Have some FUN!

Page 6: Wsv315 Windows Power Shell For Beginners

Windows PowerShell

Command line and scripting languageAs interactive and composable as BASH/KSH

As programmatic as Perl/Python/Ruby

As production oriented as AS400 CL/VMS DCL

Page 7: Wsv315 Windows Power Shell For Beginners

Common Engineering Criteria70+ active internal partners

Lync Server • SharePoint Server • Service Manager • Windows Small Business Server • Exchange Server • Windows Diagnostics • Server Manager • SQL Server • Active Directory • Failover Clustering • System Center Operations Manager • Windows Backup • Server Migration • System Center Virtual Machine Manager • Best Practices Analyzer • Active Directory Rights Management Services • Internet Information Services • Background Intelligent Transfer Service • System Center Data Protection Manager • Network Load Balancing • Remote Desktop Services • Group Policy • WS-Management • AppLocker • WMI

Page 8: Wsv315 Windows Power Shell For Beginners

Who’s using Windows PowerShell 2.0?

Page 9: Wsv315 Windows Power Shell For Beginners

Productivity

Exchange 2003 (VBScript) Exchange 2007 (PowerShell)

Mailbox Stats

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

For Each objExchange_Mailbox in listExchange_MailboxsWScript.echo "AssocContentCount =” + objExchange_Mailbox.AssocContentCountWScript.echo " DateDiscoveredAbsentInDS =” + objExchange_Mailbox.DateDiscoveredAbsentInDSWScript.echo " DeletedMessageSizeExtended =” + objExchange_Mailbox. DeletedMessageSizeExtendedWScript.echo " LastLoggedOnUserAccount =” + objExchange_Mailbox. LastLoggedOnUserAccountWScript.echo " LastLogoffTime =” + objExchange_Mailbox. LastLogoffTimeWScript.echo " LastLogonTime =” + objExchange_Mailbox. LastLogonTime WScript.echo " LegacyDN =” + objExchange_Mailbox. LegacyDNWScript.echo " MailboxDisplayName =” + objExchange_Mailbox. MailboxDisplayNameWScript.echo " MailboxGUID =” + objExchange_Mailbox. MailboxGUID WScript.echo " ServerName =” + objExchange_Mailbox. ServerName WScript.echo " Size =” + objExchange_Mailbox. SizeWScript.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 Storage Group,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”

Recipient Mgmt

Dim objMailbox As CDOEXM.IMailboxStore

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

objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage Group,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”

Page 10: Wsv315 Windows Power Shell For Beginners

Short Introduction

Jeffrey SnoverDistinguished Engineer / Lead ArchitectWindows Server demo

Page 11: Wsv315 Windows Power Shell For Beginners

Objects“An object is a collection of parts and how to

use them”

PartsProperties

Front Wheel

Back Wheel

Pedals

Saddle

Frame

How to useMethods

Pedal

Steer Left

Steer Right

Apply Front Brake

Apply Rear Brake

Parts How to use

Page 12: Wsv315 Windows Power Shell For Beginners

Objects

DisplayName

PartsProperties

Status

RequiredServices

Stop()

How to useMethods

Start()

Pause()WindowsService

Page 13: Wsv315 Windows Power Shell For Beginners

The Difference is OBJECTS!

Get-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table

Get-P

rocess

Cm

dlet

Common Windows PowerShell Parser

Windows PowerShell Pipeline Processor

Wh

ere C

md

let

So

rt C

md

let

Fo

rmat

Cm

dlet

Page 14: Wsv315 Windows Power Shell For Beginners

Working With Objects

Mir RosenbergSenior Program ManagerWindows Server demo

Page 15: Wsv315 Windows Power Shell For Beginners

Learn and Leverage

In-box documentsPowerShell_ISE HelpGetting StartedUser’s GuideAbout HelpCmdlet Help Provider Help

Discovery utilitiesBooksCommunity

Practice ad hoc development

Page 16: Wsv315 Windows Power Shell For Beginners

Command FunctionGet-Help Help about PowerShell commands and topicsGet-Command Get information about anything that can be invokedGet-Member Show what can be done with an objectGet-Module Shows packages of commands

Utilities - Discovery

Page 17: Wsv315 Windows Power Shell For Beginners

Discovery UtilitiesMir RosenbergSenior Program ManagerWindows Server

demo

Page 18: Wsv315 Windows Power Shell For Beginners

Command Action

Compare Compare 2 sets of objects

Foreach Act on each element of a set

Group Split a set of objects into groups

Measure Measure some property of a set of objects

Select Select a set of properties from a set of objects

Sort Sort objects

Tee Make a copy of a set of objects

Where Select a subset of objects

Utilities – Object Manipulation

Page 19: Wsv315 Windows Power Shell For Beginners

Object Manipulation Utilities

Jeffrey SnoverDistinguished Engineer / Lead ArchitectWindows Server demo

Page 20: Wsv315 Windows Power Shell For Beginners

PowerShell Script Explorer and Visual SearchMir RosenbergSenior Program ManagerWindows Server demo

Page 21: Wsv315 Windows Power Shell For Beginners
Page 22: Wsv315 Windows Power Shell For Beginners

Summary / Call to Action

Available at: www.microsoft.com/downloadsSearch for PowerShell

Try it, Deploy it, Use it, Share it!Focus on learning to learn

Automate and Prosper!

Page 23: Wsv315 Windows Power Shell For Beginners

Windows PowerShell Community ResourcesTeam blog: http://blogs.msdn.com/PowerShellPowerShell Community: http://www.powershellcommunity.orgPowerShell Forum: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads Channel 9: http://channel9.msdn.com/tags/PowerShellWiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWikiScript Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspxCodePlex: http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershellSome good books

PowerShell in Action, 2nd Edition by Bruce Payettehttp://www.manning.com/payette2 Windows PowerShell Cookbook, 2nd Edition by Lee Holmes http://oreilly.com/catalog/9780596801519/ PowerShell Comics! http://borntolearn.mslearn.net/comics/b/weblog/archive/2011/04/20/climbing-mt-powershell-comic-book-first-pages.aspx

Page 24: Wsv315 Windows Power Shell For Beginners

Q&A

Page 25: Wsv315 Windows Power Shell For Beginners

Related ContentBreakout Sessions

WSV406 | Advanced Automation Using Windows PowerShell 2.0 WSV316 | WS08R2: Tips on Automating the Breadth of Your IT Environment WCL321 | Windows PowerShell Remoting: Definitely NOT Just for Servers WSV322 | Managing the Registry with Windows PowerShell 2.0WSV471-INT | Build Reusable Tools in Windows PowerShellWSV473-INT | Windows PowerShell 3.0: Why Wait? Get Next-Generation PowerShell…EXL321 | Microsoft Lync Server 2010: Administering Lync Server Deployment

Hands-on LabsWSV276-HOL Introduction to Windows PowerShell Fundamentals WSV371-HOL Advanced Windows PowerShell Scripting WSV378-HOL Server Management and Windows PowerShell V2

Product Demo Stations WSV 1 – Windows PowerShell and Server Management

Page 26: Wsv315 Windows Power Shell For Beginners

Resources

www.microsoft.com/teched

Sessions On-Demand & Community Microsoft Certification & Training Resources

Resources for IT Professionals Resources for Developers

www.microsoft.com/learning

http://microsoft.com/technet http://microsoft.com/msdn

Learning

http://northamerica.msteched.com

Connect. Share. Discuss.

Page 27: Wsv315 Windows Power Shell For Beginners

Complete an evaluation on CommNet and enter to win!

Page 28: Wsv315 Windows Power Shell For Beginners

MS Tag Placeholder Slide

Page 29: Wsv315 Windows Power Shell For Beginners

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.