Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

30
Windows PowerShell Crash Course Don Jones • Concentrated Technology Jeffrey Snover • Microsoft WSV321

Transcript of Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Page 1: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Windows PowerShellCrash Course

Don Jones • Concentrated TechnologyJeffrey Snover • Microsoft

WSV321

Page 2: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Welcome!

We’re here to get you up and running with PowerShell – as quickly as possible.99% of what you’ll see applies to v2 and v3; we’ll point out some specific v3 coolness as we goPlease ask questions as we go, although we are on a tight schedule, so some stuff we may need to pick up at the end.

Page 3: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Quick Introductions

Don JonesPowerShell MVP Award RecipientPowerShell columnist for TechNet MagazineAuthor, Learn Windows PowerShell in a Month of Lunches and PowerShell in Depth (forthcoming)

Jeffrey SnoverDistinguished Engineer in the Windows Server teamInventor of Windows PowerShell

Page 4: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Let’s Begin!

PowerShell is a command-line interface (CLI)……that contains a rich, yet simplified scripting language for automating complex, multi-step tasksBuilt on the .NET FrameworkExtensible, so various products and technologies can be managed by “snapping in” tech-specific extensions

Most importantly… it’s discoverable! It can teach you how to use itself!

Page 5: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

The Help System, Modules, and More

Letting PowerShell Teach You How to Use PowerShell

Page 6: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

The Pipeline

PowerShell has an extremely powerful pipeline that works unlike anything that’s really been done beforeIt carries the output of one command to the input of the next… but it does so in an amazingly flexible wayIf you can master the pipeline (and the help system helps!)

Page 7: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

ByValue. ByPropertyName, and ByJoveThatsAmazing

The PowerShell Pipeline

Page 8: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Speaking of CIM…

PowerShell remains the most effective way to access Windows Management Instrumentation, which provides a wealth of management informationV2 and v3 both have the “WMI” cmdlets, which utilize the old-school DCOM/RPC protocol for communicationsV3 Introduces “CIM” cmdlets, which use the same WMI back-end info repository, but communicate over WS-MAN

Page 9: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

(And why WS-MAN is your new best friend)

WMI and CIM

Page 10: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

And oh, You WANT WS-MAN!

First, it’s auto-enabled in Windows Server 2012It’s also the basis for PowerShell’s awesome-est feature, RemotingWe’ll do a quick Remoting demo, but Don has an entire “Remoting in Depth” session that you just gotta check out.

Page 11: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

PowerShell Remotingand WS-MAN

Page 12: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Objects

You may have heard that PowerShell is an object-oriented shellPeople make a big deal of this because it enables a lot… but conceptually it’s pretty simpleEver see an Excel spreadsheet? It’s just a data structure, right? Well, that’s all objects are. Data structures, in memory. Every PowerShell command (well, most) produces objects… and PowerShell will even show you everything about them

Page 13: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

It’s all just data!

Object-Oriented Shell

Page 14: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

But You Know…

Not every technology lends itself well to a static set of predefined commandsTake IIS, or SQL Server, or anything else that’s extensible. How do you know what commands admins will need when you don’t even know everything that might be added into the product?The answer: Providers. PowerShell providers can make any storage – even configuration stores – look like a disk drive. You get to use familiar commands with them!

Page 15: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Adapting storage to look like a file system

PSProviders and PSDrives

Page 16: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Lots of Smarts

PowerShell includes a full set of comparison operators that, combined with a filtering cmdlet, let you remove things from the pipeline.It’s what’s left at the end of the pipeline that gets displayed.

Page 17: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Help about_comparison_operators is your friend!

Comparing and Filtering

Page 18: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Hate Syntax?

Yeah, it’s harder than clicking buttons in a GUI.And in large part you can still use a GUI if you want to, even though it may just be running PowerShell commands under the hood.

But think about where companies are headed… and think about your value to your organization.

Page 19: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Would You Rather be a Button Monkey…or a ToolMaker?

If you do something more than once… automate it.PowerShell finally gives us a way to do that.

Page 20: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Not a Button Monkey!

Become a ToolMaker

Page 21: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

More Fun Tips

Why “cmdlet?”Formatting? Make it the last thing you do.Neat tricks with double quotes.Why you should avoid Write-Host

Page 22: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Formatting, Quotes, and How to Really Write

Last Quick Tips

Page 23: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Contact Info for Follow-Ups

Don:@concentrateddon on Twitterhttp://bit.ly/AskDon for online Q&ALearn Windows PowerShell in a Month of Lunches – get it anywhere or in the TechEd Bookstore!

Jeffrey:@jsnover on TwitterBlogs:

http://blogs.technet.com/b/windowsserver/ http://jsnover.com/blog

Page 24: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Related Content

WCL404: Building Reusable CLI and GUI Tools in PowerShell

WSV07-TLC: Windows Server 2012 Server Manager and PowerShell

DBI331: The Dirty Dozen: PowerShell Scripts for the Busy DBA

SIA404: Deep Dive on Windows Server Active Directory Shell

Find Me Later At “The Scripting Guys” pod in the Expo Hall!

Page 25: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

SIA, WSV, and VIR Track Resources

Talk to our Experts at the TLC

#TE(sessioncode)

DOWNLOAD Windows Server 2012 Release Candidate

microsoft.com/windowsserverHands-On Labs

DOWNLOAD Windows Azure

Windowsazure.com/teched

Page 26: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Resources

Connect. Share. Discuss.

http://northamerica.msteched.com

Learning

Microsoft Certification & Training Resources

www.microsoft.com/learning

TechNet

Resources for IT Professionals

http://microsoft.com/technet

Resources for Developers

http://microsoft.com/msdn

Page 27: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

Complete an evaluation on CommNet and enter to win!

Page 28: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

MS Tag

Scan the Tagto evaluate thissession now onmyTechEd Mobile

Page 29: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.

© 2012 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.

Page 30: Windows PowerShell Crash Course Don Jones Concentrated Technology Jeffrey Snover Microsoft WSV321.