course windows powershell v2

Click here to load reader

Post on 13-Apr-2015

60 views

Category:

Documents

4 download

Embed Size (px)

DESCRIPTION

Course Windows PowerShell v2

TRANSCRIPT

The Administrator Crash Course

Windows PowerShell v2

Don Jones

PowerShellCrashCourse

DonJones

IntroductiontoRealtimePublishersby Don Jones, Series Editor

Forseveralyearsnow,Realtimehasproduceddozensanddozensofhighqualitybooks thatjusthappentobedeliveredinelectronicformatatnocosttoyou,thereader.Weve madethisuniquepublishingmodelworkthroughthegeneroussupportandcooperationof oursponsors,whoagreetobeareachbooksproductionexpensesforthebenefitofour readers. Althoughwevealwaysofferedourpublicationstoyouforfree,dontthinkforamoment thatqualityisanythinglessthanourtoppriority.Myjobistomakesurethatourbooksare asgoodasandinmostcasesbetterthananyprintedbookthatwouldcostyou$40or more.Ourelectronicpublishingmodeloffersseveraladvantagesoverprintedbooks:You receivechaptersliterallyasfastasourauthorsproducethem(hencetherealtimeaspect ofourmodel),andwecanupdatechapterstoreflectthelatestchangesintechnology. Iwanttopointoutthatourbooksarebynomeanspaidadvertisementsorwhitepapers. Wereanindependentpublishingcompany,andanimportantaspectofmyjobistomake surethatourauthorsarefreetovoicetheirexpertiseandopinionswithoutreservationor restriction.Wemaintaincompleteeditorialcontrolofourpublications,andImproudthat weveproducedsomanyqualitybooksoverthepastyears. Iwanttoextendaninvitationtovisitusathttp://nexus.realtimepublishers.com,especially ifyouvereceivedthispublicationfromafriendorcolleague.Wehaveawidevarietyof additionalbooksonarangeoftopics,andyouresuretofindsomethingthatsofinterestto youanditwontcostyouathing.WehopeyoullcontinuetocometoRealtimeforyour educationalneedsfarintothefuture. Untilthen,enjoy. DonJones

i

PowerShellCrashCourse

DonJones

IntroductiontoRealtimePublishers.................................................................................................................i PowerShellCrashCourseWeek1.....................................................................................................................1 PreRequisites.......................................................................................................................................................2 Week1,Day1:Commands,Cmdlets,andAliases..................................................................................2 Week1,Day2:Output.......................................................................................................................................4 Step1:FindAttributes..................................................................................................................................4 Step2:PickaLayout.....................................................................................................................................5 Step3:AddYourProperties .......................................................................................................................5 Format,ThenYoureDone..........................................................................................................................6 Week1,Day3:ThePipeline...........................................................................................................................6 Step1:DetermineYourOutput................................................................................................................7 Step2:FindMatchingInputTypes.........................................................................................................7 Step3:WhenTypesArentEnough........................................................................................................8 Week1,Day4:CoreCmdlets..........................................................................................................................9 Week1,Day5:ConfigurationBaselines.................................................................................................10 PowerShellCrashCourseWeek2..................................................................................................................12 Week2,Day1:Variables...............................................................................................................................12 Week2,Day2:OperatorsandFiltering..................................................................................................15 Week2,Day3:Formatting...........................................................................................................................17 Week2,Day4:GettingOut.......................................................................................................................19 Week2,Day5:ExtendingtheShell..........................................................................................................20 WeekendWrapUp ...........................................................................................................................................21 PowerShellCrashCourseWeek3..................................................................................................................22 Week3,Day1:RemoteControl..................................................................................................................23 PreRequisitesandSetup.........................................................................................................................23 1:1Remoting ..................................................................................................................................................23 1:ManyRemoting.........................................................................................................................................23

ii

PowerShellCrashCourse

DonJones

ReUsingConnections................................................................................................................................25 Week3,Day2:IntheBackground............................................................................................................26 StartingaJob ..................................................................................................................................................26 ManagingJobs...............................................................................................................................................27 GettingResultsfromJobs.........................................................................................................................27 Week3,Day3:ImplicitRemoting.............................................................................................................28 Week3,Day4:MakingaSimpleReusableCommand......................................................................28 Week3,Day5:SELECTing............................................................................................................................29 Week3WrapUp ...............................................................................................................................................30 PowerShellCrashCourseWeek4..................................................................................................................31 Week4,Day1:ErrorHandling...................................................................................................................32 Week4,Day2:DebugTraceMessages...................................................................................................32 Week4,Day3:Breakpoints.........................................................................................................................33 Week4,Day4:WMI........................................................................................................................................34 Week4,Day5:Tools.......................................................................................................................................35 MonthWrapUp .................................................................................................................................................36 DownloadAdditionalBooksfromRealtimeNexus!..........................................................................36

iii

PowerShellCrashCourse

DonJones

Copyright Statement 2010 Realtime Publishers. All rights reserved. This site contains materials that have been created, developed, or commissioned by, and published with the permission of, Realtime Publishers (the Materials) and this site and any such Materials are protected by international copyright and trademark laws. THE MATERIALS ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. The Materials are subject to change without notice and do not represent a commitment on the part of Realtime Publishers its web site sponsors. In no event shall Realtime Publishers or its web site sponsors be held liable for technical or editorial errors or omissions contained in the Materials, including without limitation, for any direct, indirect, incidental, special, exemplary or consequential damages whatsoever resulting from the use of any information contained in the Materials. The Materials (including but not limited to the text, images, audio, and/or video) may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way, in whole or in part, except that one copy may be downloaded for your personal, noncommercial use on a single computer. In connection with such use, you may not modify or obscure any copyright or other proprietary notice. The Materials may contain trademarks, services marks and logos that are the property of third parties. You are not permitted to use these trademarks, services marks or logos without prior written consent of such third parties. Realtime Publishers and the Realtime Publishers logo are registered in the US Patent & Trademark