bringing home the bacon - spiceworks › u › gen › may2016 › 2016spiceworldlon… ·...

33
Bringing Home The Bacon An Introduction to Windows PowerShell Thomas Lee Partner, PS Partnership @DoctorDNS on Twitter Tfl on Spiceworks

Upload: others

Post on 04-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

Bringing Home The BaconAn Introduction to Windows PowerShell

ThomasLeePartner,PSPartnership@DoctorDNS onTwitterTflonSpiceworks

Page 2: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• WhatIS PowerShell?• WhatareCmdlets,ObjectsandThePipeline?• PowerShellinWindowsandWindowsApplications• WhyPowerShellMatterstoYOU• DesiredStateConfiguration• Questions

Page 3: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

•PowerShell is thefutureofWindowsadministration•PowerShellmakesyourlifeeasier•PowerShellmagnifiesyoureffort•WithPowerShell youhavemoretimetoenjoyandconsume bacon• Letmeshowyouhowandwhy!

Page 4: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

•Microsoft’s StrategicTaskAutomationPlatformforITPros• Itcontains• Shell– thinkUnixlikeintermsofusefulness• ScriptingLanguage– withthepowerofPerlorRuby• Extensible– bringonthecommunity

• Basedon.NET– Microsoftfocused,but…

Page 5: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

Cmdlets Objects Pipeline

Page 6: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Aunitoffunctionality– muchlikeaLinuxcommand• Implementedasa.NETClass

• GetsomewithPowerShell/Windows• Buysome– e.g./nSoftware’sNetCmdlets• Findsome– leveragethecommunityefforts• Buildyourown– useC#andVS

Page 7: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Cmdlets namedwithaVerb-Noun syntax• Verbsarestandardtoaiddiscovery

• Cmdlets canhavealiases• Built inoraddyourown• AliasesdoNOTincludeparameteraliasingL

• Cmdlets comefromPowerShell,Windows,apps

Page 8: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

•Cmdlets takeparameters•Allparameters haveparameternames• Beginwitha‘-’

•Someparameternamescanbeomitted•Tabcompletion isyourfriend!•Cmdlets arediscoverable – Get-Help,Get-Command

Page 9: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Cmdlets/Functionspackagedintomodules• Modulescanbedynamicallyloaded• Youcandevelopyourownmodules

Page 10: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Acomputerabstractionofareallifething• Aprocess• Aserver• AnADUser

• InPowerShelleverything isanobject

Page 11: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Objectshaveoccurrencesyoumanage• Theprocessesrunningonacomputer• TheusersinanOU• Thefiles inafolder

• Objectsdramaticallysimplifiesscripting

Page 12: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• PowerShellsupports:• .NETobjects• COMobjects• WMIobjects• CustomObjects

• Syntaxandusagevary– similar,yetdifferent

Page 13: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Cmdlets produceandconsumeobjects• E.g.Get-ProcessproducesobjectsofthetypeSystem.Diagnostics.Process

• Objectsarediscoverable• Get-Member tellsyouthewhatanobjectcontains

• RefertoMSDNdocumentationformoredetail

Page 14: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Thepipelineconnectscmdlets• Onecmdletoutputsobjects• Nextcmdletusesthemasinput

• Pipelineisnotanewconcept• CameFromUnix/Linux• PowerShellPipesobjectsnottext

Page 15: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Simpletouse– fareasiertocompose• Powerfulinoperation- PowerShell(and.NET)dotheheavylifting• Improvesintegrationoffunctionalitystacks

• OS/Application/PowerShellbase/Communityefforts/etc

Page 16: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• AkeyconceptinPowerShell• Whatyouknowhelpsyoulearnmore• PowerShellbuilttobediscoverable

Page 17: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Get-Command – helpsyoutofindcmdlet/functionnames• Get-Help– getsyoudetailsonaspecificcmdlets/function• Get-Member– pipeyouroutputtoGet-Membertodiscoverwhatitis

Page 18: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

CmdletsPipelineObjects

Discovery

Demo Time

Page 19: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Youneverwalkalone=>thereisaHUGEPowerShellecosystem• Spiceheads• Productteams• Vendors

• Variouswaystoengagewiththecommunity• Spiceworks PowerShellGroup• Blogs• Twitter

Page 20: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• PowerShellhasalanguage• Thisisusedtocreatescripts,scriptcmdlets,etc.• SyntaxsimilartoC#,etal• LanguagecontainsfeaturesfromUnix/Linuxandabunchofothers• Youneedtoknowthelanguagetowritescripts

Page 21: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Aricherenvironment• Doescolourcodingofsyntax• Goodeditingfeatures• Extensible

Page 22: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• CoremodulescomewithWindows• AdditionalmodulescomewithWindowsfeatures• MoremodulecomewithWindowsapps• Evenmoremodulescomefromthecommunity

Page 23: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• V3BuiltintoWin8,Server2012• V4BuiltintoWin8.1,Server2012R2• V5inWindows10andavailablefordownload• V5.1inWin10AEandServer2016TP5

Page 24: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Somebuiltin• SomewithServerfeatureand/orRSATtools• Somedownloadable(eg Azure)• Some3rd partycommercial• UsePowerShellGet moduletofindandinstallmore!

Page 25: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• DSC– DesiredStateConfiguration• Youdefineaconfiguration

• PowerShellDSC– Makes itso!• PowerShellDSC– KEEPSitso!

Page 26: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Today– DSCisstillaworkinprogress• Only12fullyreleasedresourcesinV5• Loadsmorebeingdeveloped– manyarestable• Windows10helps,butWindowsServer2016shouldhavemore• Themoveisnowtoplacethese intoPSGallery – online

Page 27: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Becauseit’severywhere!• It’sfasterforrepetitivetasks• It’srepeatableandauditable• Lesspronetoerror

Page 28: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• Books/blogs/forums• Microsoftandothertrainingcourses• Getyourcompanytosponsoraclass• Learnbydoing

Page 29: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• First,removecmd.exefromyoursystem• UsePowerShelleverywhere

• UsePowerShellforasmuchasyoucan• AskquestionsonSpiceworks

• MasterPowerShell• Andbringhomethebacon

Page 30: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier

• IfyouareanITProintheWindowsspaceyouneedtoeither• LearnPowerShell• Learnhowtosmilewhenyousay‘wouldyoulikefrieswiththat’

Page 31: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier
Page 32: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier
Page 33: Bringing Home The Bacon - Spiceworks › u › gen › May2016 › 2016spiceworldlon… · •PowerShell isthe future of Windows administration •PowerShell makes your life easier