powershell 101 - what is it and why should you care!

33
PowerShell 101 What is it and why should YOU care? Thomas Lee Partner, PS Partnership @DoctorDNS on Twitter

Upload: thomas-lee

Post on 11-Apr-2017

60 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: PowerShell 101 - What is it and Why should YOU Care!

PowerShell 101What is it and why should YOU care?

Thomas LeePartner, PS Partnership@DoctorDNS on Twitter

Page 2: PowerShell 101 - What is it and Why should YOU Care!

Agenda

• What IS PowerShell?• What are Cmdlets, Objects and the Pipeline?• PowerShell in Windows and Windows Applications• Why PowerShell Matters to YOU• Questions

Page 3: PowerShell 101 - What is it and Why should YOU Care!

Who am I?

• 17-time MVP – many on PowerShell• PowerShell Pioneer

– Into PowerShell from the get-go (Oct 2003)• Author

– PowerShell 2.0 bible with another book in probress• Trainer• Admin for PowerShell group on Spiceworks

Page 4: PowerShell 101 - What is it and Why should YOU Care!

Why PowerShell?

• PowerShell is the future of Windows administration

• PowerShell makes your life easier• PowerShell magnifies your effort• Let me show you how and why!

Page 5: PowerShell 101 - What is it and Why should YOU Care!

But First - What IS PowerShell?

• Microsoft’s Strategic Task Automation Platform for IT Pros• It contains

–Shell – think Unix like in terms of usefulness–Scripting Language – with the power of Perl or Ruby –Extensible – bring on the community

Page 6: PowerShell 101 - What is it and Why should YOU Care!

Looking at PowerShell

Cmdlets Objects Pipeline

Community

Discovery

PowerShell Language Features

Page 7: PowerShell 101 - What is it and Why should YOU Care!

What are Cmdlets?

• A unit of functionality – much like a Linux command• Implemented as a .NET Class

– Get some with PowerShell/Windows– Buy some – e.g. /n Software’s NetCmdlets– Find some – leverage the community efforts– Build your own – use C# and VS

Page 8: PowerShell 101 - What is it and Why should YOU Care!

Cmdlets (continued)

• Cmdlets named with a Verb-Noun syntax– Verbs are standard to aid discovery

• Cmdlets can have aliases– Built in or add your own– Aliases do NOT include parameter aliasing

• Cmdlets come from PowerShell, Windows, apps

Page 9: PowerShell 101 - What is it and Why should YOU Care!

Cmdlets (continued)

• Cmdlets take parameters• All parameters have parameter names that begin

with a ‘-’ • Some parameter names can be omitted• Tab completion is your friend!• Cmdlets are discoverable

Get-Help, Get-Command

Page 10: PowerShell 101 - What is it and Why should YOU Care!

Cmdlets and Modules

• Cmdlets/Functions packaged into modules• Modules can be dynamically loaded• You can develop your own modules

Page 11: PowerShell 101 - What is it and Why should YOU Care!

What are Objects?

• A computer abstraction of a real life thing– A process– An AD User– A folder

• In PowerShell everything is an object

Page 12: PowerShell 101 - What is it and Why should YOU Care!

Objects (continued)

• Objects have occurrences you manage– The processes running on a computer– The users in an OU– The files in a folder

• Objects dramatically simplifies scripting

Page 13: PowerShell 101 - What is it and Why should YOU Care!

PowerShell Object Support

• PowerShell supports:– .NET objects– COM objects– WMI objects– Custom Objects

• Syntax and usage vary – similar, yet different

Page 14: PowerShell 101 - What is it and Why should YOU Care!

Objects in PowerShell

• Cmdlets produce and consume objects– E.g. Get-Process produces objects of the type System.Diagnostics.Process

• Objects are discoverable–Get-Member tells you the what an object contains

• Refer to MSDN documentation for more detail

Page 15: PowerShell 101 - What is it and Why should YOU Care!

What Is The Pipeline?

• The pipeline connects cmdlets– One cmdlet outputs objects– Next cmdlet uses them as input

• Pipeline is not a new concept– Came From Unix/Linux– PowerShell Pipes objects not text

Page 16: PowerShell 101 - What is it and Why should YOU Care!

Why This Design Matters

• Simple to use – far easier to compose• Powerful in operation - PowerShell (and .NET) do the

heavy lifting• Improves integration of functionality stacks

– OS/Application/PowerShell base/Community efforts/etc.

Page 17: PowerShell 101 - What is it and Why should YOU Care!

Discovery

• A key concept in PowerShell• What you know helps you learn more• PowerShell built to be discoverable

Page 18: PowerShell 101 - What is it and Why should YOU Care!

Key Discovery Cmdlets

• Get-Command – helps you to find cmdlet/function names

• Get-Help – gets you details on a specific cmdlets/function

• Get-Member – pipe your output to Get-Member to discover what it is

Page 19: PowerShell 101 - What is it and Why should YOU Care!

CmdletsPipelineObjectsDiscovery

Demo Time

Page 20: PowerShell 101 - What is it and Why should YOU Care!

PowerShell Community

• You never walk alone => PowerShell ecosystem– Product teams– Vendors

• Various ways to engage with the community– Blogs– Twitter– Spiceworks PowerShell forum

Page 21: PowerShell 101 - What is it and Why should YOU Care!

PowerShell Language

• PowerShell has a language• This is used to create scripts, script cmdlets, etc.• Syntax similar to C#• Language contains features from Unix/Linux and others• You need to know the language to write scripts

Page 22: PowerShell 101 - What is it and Why should YOU Care!

PowerShell ISE

• A richer development environment• Does colour coding of syntax• Good editing features• Extensible

Page 23: PowerShell 101 - What is it and Why should YOU Care!

PowerShell is Everywhere

• Core modules come with Windows• Additional modules come with Windows features• More module come with Windows apps• Even more modules come from the community

Page 24: PowerShell 101 - What is it and Why should YOU Care!

How Do I Get PowerShell?

• V3 Built into Win8, Server 2012• V4 Built into Win 8.1, Server 2012 R2• V5 in Windows 10• V5.1 in Win10 AU and Server 2016• V6.0 Alpha available

Page 25: PowerShell 101 - What is it and Why should YOU Care!

Getting Modules

• Some built-in• Some come with Server feature and/or RSAT tools• Some downloadable (e.g. Azure)• Some 3rd party commercial• Use PowerShellGet module to find and install more!

Page 26: PowerShell 101 - What is it and Why should YOU Care!

So Why Does PowerShell Matter?

• Because it’s everywhere!• It’s faster for repetitive tasks• It’s repeatable and auditable• Less prone to error• It’s easy (once you get past the learning curve)

Page 27: PowerShell 101 - What is it and Why should YOU Care!

PowerShell Is Not Universal!

• Windows has over 300 console applications that you use to administer and manage aspects of Windows

• Many of these have NO equivalent in PowerShell• Examples include:

– Certutil– Slmgr.vbs/Ospp.vbs– Wevtutil.exe

Page 28: PowerShell 101 - What is it and Why should YOU Care!

Learning PowerShell

• Books/blogs/forums• Microsoft and other training courses• Get your company to sponsor a class• Learn by doing

Page 29: PowerShell 101 - What is it and Why should YOU Care!

So What Next?

• First, remove cmd.exe from your system– Use PowerShell everywhere

• Use PowerShell for as much as you can– Ask questions on Spiceworks

• Master PowerShell– Advance your career

Page 30: PowerShell 101 - What is it and Why should YOU Care!

Summary

• If you are an IT Pro in the Windows space you need to either– Learn PowerShell– Learn how to smile when you say ‘would you like fries with

that burger’

Page 31: PowerShell 101 - What is it and Why should YOU Care!
Page 32: PowerShell 101 - What is it and Why should YOU Care!
Page 33: PowerShell 101 - What is it and Why should YOU Care!