资源描述:
《[Windows.PowerShell.for.Developers(Early.Release,2012.3)].Douglas.Finke.文字版》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、O’ReillyMedia,Inc.3/23/20122TheDimeTour“Scriptingandsystemprogrammingaresymbiotic.Usedtogether,theyproduceprogrammingenvironmentsofexceptionalpower.”-JohnOusterhout,creatorofTclPowerShellprovidesrapidturnaroundduringdevelopmentforanumberofreasons.Iteliminatescompiletime,i
2、t’saninterpreterandmakesdevelopmentmoreflexiblebyallowingprogrammingduringapplicationruntime,anditsitsontopofpowerfulcomponents,the.NETframework,connectingthemtogether.IfyouwanttowritePowerShellscriptsyouneedtolearnthePowerShellsyntaxanditsbuildingblocks,likeCmdlets,Funct
3、ionsandhowtotapintoPowerShell’secosystem,includingthe.Netframework,thirdpartyDLLsandDLLsyoucreate.There’salottocover,eveninthedimetour,soheregoes.TheObjectPipelineThese63charactersarewhathookedmewhenIsawmyfirstPowerShelldemo.TheGameChangerGet-Process
4、Where{$_.Handles-gt75
5、0}
6、SortPM-DescendingHandlesNPM(K)PM(K)WS(K)VM(M)CPU(s)IdProcessName-----------------------------------------------96543173992107044602157.342460MetroTwit78421881968358829019.845776chrome95244394562010028729.272612explorer784343426828361094.563712SearchIndexer1158281886814
7、0481506.21956svchost7791437843900364.46580lsassTheyconveykeyconceptsinPowerShell’svalueproposition,maximizingeffortandreducingtime.Herearethehighlights.1O’ReillyMedia,Inc.3/23/2012•Usingcmdletstocomposesolutions,Get-Process,Where,Sort•Piping.NETobjects,notjusttext•Elimina
8、tingparsingandpraying.Noneedtocountspaces,tabsandotherwhitespacetopullouttheHandlesvalueandthenconvertingittonumericforthecomparison•Workingwith.NETpropertiesdirectly,$_.HandlesintheWhereandPMintheSort•Lessbrittle.IfsomeoneaddspropertiestotheoutputofGet-Process,mycodeisno
9、taffected.Iamworkingwithanobject-orientedpipeline.AutomationReferencesWhenyoucreateaConsoleApplicationProjectinVisualStudio,thewizardaddstheseusingstatementsforyou:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;InaPowerShellsession,createdby
10、launchingtheconsoleorISE(IntegratedScriptingEnvironment).PowerShelldoesmoreworkforyou.Bydefault,