作者:empty 页数:1016 出版社:empty |
The book on Power Shell it has all t be sec rcIf all it had going for it was the authoritative pedigree of the writer it nag ht be worth it, bur it salowell-u ritten, well organized d.and thorough, which I think makes it invaluable as both a learning tooland a reference.ian encyolopedictomeofPrwer Shell scripting bringing the reader through the basics wihs in ple shellscripts through powerful and flexible scripts any Windows systems ae mini strt to r will find immediatelywie fud.The nuances of Power Shel from the lead language des gner him sef Excellent content and cay readability!ll giver you/inside information, excelente x atm ples, and a colorful wrt ing styleTheres no better way to learn Power Shell than from som conc on the core Power Shell team—and s hatsexactly what you get with this book.W bers the 6 stars option?I havent enjoyed as of war ceng neering book to the sane extent for aongte
Consider this book the definitive reference for PowerS hellAs on c of the designers of the Power Shellenvironment, the author knows all the ins and outs, back alleys, hidden rooms.and secret handshakesthe language offers, and ist afraid io grab yow by the hand and drag you along(like it or not) for thetour of your feI love this book!
For online informaton and ordering of this and other Manning books, please visitwww.manning.com.Thepublisheroffersdiscountsonthisbaokwhenorderedinquantity:For more information.please contact:@2011by Manning Public arion sCo.All rights reservedNo part of this publication maybe reproduced, stored in a retrieval system, or transmitted, inany form or by means electronic, mechanical, ph oro copying.or otherwise, with our prior writtenpermission of the publ she.Many of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks.Where those designations appear in the book, and ManningPublications was aware of at a demark claim.the dei nations have been prnt ed in in i al capsor all caps.e Recogni xing also our responsibility to conserve the resources of our planet, Manning booksare printed on paper that is atleast l 5 percent recycled and processed without the use ofelemental chlorine
Well, is been a wild ride since the first edition of this book was released.Ar thattime.Power Shell had just shipped and had a fairly limited scope of influence.Thingshave changed alot.Power Shell now ships in the box with Windows(at leas rW indows7andServer2008R 2) .The number of Power Shell users is now in the hundredsof thousands, if not millions(this is not a formal estimate—I just looked at some ofthe download counters for Power Shell-related tools and went from there) .One of the biggest events from my perspective was the release of Power Shell version2in July of 2009.Obviously it was time for a sequel to the book.I put together a shortproposal and estimate of the amount of work needed to update the book.The initialestimate was for a few months of work—a couple of new chapters, a few updates hereand there, and were good to go.Wow, was I ever wrong about that!Power Shell v 2was a really big release,When you arc in the middle of something, working heads down.you tend to loseperspective of the overall project—that old forest/trees problem.It was n't untill waspreparing a talk for MMS(Microsoft Management Summit) that I realized just howBIG it was.In a one-hour talk, we barely had time to list all of the new stuff, muchless describe it in detail.But describing it in detail was exactly what I needed to do andthat's why this book took a great deal longer to write than anticipated.I's also muchbigger than I had expected or wanted.At one point it was double the sizeof the rstedition.So we cut some stuff i hat was no longer as relevant with Power Shell v 2, movedsome stuff into the onlne appendixes, and capped the book at about 1000 pagesSo why wte the book in their st place!The answer is the same no was it wasthen—I wanted the Power Shell community to have away to see“inside the box andhave a more intimate insight into the goals and motivations behind Power Shell.Although Power Shell draws heavily from exiting technologies, it combines them in
Part l
Devel a pment Editr Cynthia Kane
Cpyeditr Liz Welch
Typesetter:Marija Tudr
Cver designer:Maja Tudr
Learning PwerS bell 1
1 Welcme t Pwer Shell 3
2 Fundatins f Pwer Shell 36
3 Wrking with types 72
4 peratrs and expressins110
5 Advanced peratrs and variables151
6Flucntrlinseript198
7 Pwer Shell functins 236
8 Advanced functins and scripts 275
9 Using and authring mdules 322
10 Mdule manifests and metadata 361
11Meta prgram mig with script blcks and dynamic cde 392
12 Remting and backgrund jbs 447
13Remtng:cnfiguring applicatins and services 502
14 Errrs and exceptins 553
15 The Pwer Shell IS E and debugger 606
Part 2 Using Pwer Shell 661
16 Wrking with files, text, and XML 663
17Exteneling yur reach with.NET719
Wrking with CM 760
19 Management bjects:WMI and WS-MAN 797
20Respndngin realtime with eventing 847
21 Security, security, security 888
cntents
Part 1
BRIEF CNTENTS
pre lace xix
acknwledgments xxi
a bst this bk xxi li
1.1 What is Pwer Shell ? 5
1.2Sulfa new language 9
1.3 Brushing upn bjects 11
abut t be cver illustratin xxix
Learning Pwer Shell 1
1 Welcme t Pwer Shell 3
Shells.cmm and lines.and x cript ing languages 6+Why a new
shell:Whynw:7+Thelastmileprblem8
Learning frm histry 9+Leveraging.NET 10
Reviewing bject-riented prgramming 11+bjects in
Pwer Shell 13
Pwer Shell 14+Starting Pwer Shell 14+The Pwer Shell
cnsle hst 14+The Pwer Shell Integrated Ser ip ting
Envirnment 17+Cmmand cmpletin 20
Navigatin and basic peratins 22+Basic expressins and
variables 23+Pr acessing data 25+Flwcntrl
statements 30+Scripts and functins 31+Remting and
the Universal Executin Mdel 32
1.4Up and running with Pwer Shell 13
1.5Dude!Where's my cde ? 22
1.6 Summary 35
2 Fundatins f Pwer Shell 36
2.1Gettnga sense f the Pwer Shell language 37
2.2 The cre cncepts 38
2.3 Aliases and clastic syntax 46
2.4 Parsing and Pwer Shell 50
2.5Hwthepipeie wrks 60
2.6 Frmatting and ut pur 64
2.7 Summary 70
3.1 Type management in the wild, wildWest 72
3.2 Basic types and literals 77
3.3 Cllectins:dictinaries and hashtables 85
3.4 Cllectins:arrays and sequences 91
3.5 Type literals 96
3.6 Type cnversins 101
3.7 Summary 109
Cmmand cncepts and terminlgy 38+Cmmands and
cmd lets 38+Cmmand categries 42
Hw Pwer Shell parses 51+Quting 51+Expressin-
mde and cmmand-mde parsing 54+Statement
terminatin 56+Cmment syntax in Pa wer Shell 58
Pipelines and streaming behavir 61+Parameters and
parameter binding 62
The frmatting cmd lets 64+The utput tere md lets 67
3Wrking with r ypes72
4 peratrs and expressins110
5 Advanced peratrs and variables151
PwerShell:arype-prmiscuuslanguage73+Thetype
system and rype adap ratin 75
String literals 77+Numbers and numeric literals 82
Cre aig and inspecting has hr ables 85+Mdifying and
manipulating hashtables 88+Hashtables as reference
types 90
Cllecting pipeline utput as an array 91+Array
indexing 92+Plymrphism in art ays 92+A may sas
reference types 93+Singletn arrays and empty arrays 94
Typename aliases 96+Generic type literals 98+Accessing
static members with type literals 99
Hw type cnversin wrks 101+Pwer Shell's type-
cnversin algrithm 104+Special cyp e cnversins in
parameter binding 107
4.1 Arithmetic peratrs112
4.2Theasignmentperatars 119
4.3 Cmparisn peratrs 124
4.4 Pattern matching and text manipulatin I 31
4.5Lgieal and bitwise peratrs 148
4.6 Summary 150
5.1 peratrs fr wrking with types 152
5.2Theunary peratrs 154
5.3 Gruping and subexpressins 157
5.4 Array peratrs 162
5.5 Prperty and methd peratrs 173
5.6 The frmat peratr 179
5.7 Redirectin and the redirectin peratrs 181
5.8 Wrking with variables 184
5.9 Summary 196
The additin peratr
113+The muli pic atin pet at r 116
Subtract n, dv sin, and the mdulus peratr 117
Multiple assignments 120+Multiple assignments with rype
quali tiers 121+Assignment peratins as
value expressins 123
Scalar cmparisns 125+Cmparisns and case
sensitivity 127+Using campari n peratrs
with cllectins 129
Wildcard patterns and the-like peratr 132+Regular
expressins 133+The-match peratr 134+The-replace
peratr 137+The-jin peratr 139+The-split
peratr 143
Subexpressins S(a 159+Array subexpressins@(.) 160
The cmma pera r r 162+The range peratr 165
Array indexing and slicing 167+Using the rang c
peratr with arrays 170+Wrking with
multidimensinal arrays 171
The dr peratr 174+Static methds and the duble-cln
peratr 177+Indirect methd invcatin 178
Creating variables 185+Variablename syntax 186
Wrking with the variable cmd lets 188
Splatting a variable 193
Flwcntrl in scripts
7 Pwer Shell functins
198
236
6.1 The cnditinal statement 200
6.2 Lping statements 203
6.3 Labels, break, and cntinue 212
6.4 The switch statement 215
6.5 Flwcntrl using cmd lets 223
6.6Satementsas values 231
6.7Awrdabur perfrmance 233
6.8 Summary 234
The while lp 203+The d-while lp 204+The fr
lp 205+The fr each lp 207
Basic use f the switch statement 215+Using wildcard
patterns with the switch statement 216+Using regular
expressins with the switch statement 217+Prcessing files
with the switch state men r 221+Using the S switch lp
enumeratr in the switch statement 222
The Fr Each-bject cmd let 223+The Where-bject
cmd let 228
Passing arguments using S args 237+Example functins:
ql and qs 239+Simplifying S args prcessing with multiple
Mixing named and psitinal parameters 242+Adding type
cnstraints t parameters 243+Handling variable numbers f
arguments 245+Initializing fianc tin parameters with default
values 246+Handling mandatry parameters.vl-style 248
Using switch parameters t deine cmmand switches 248
Switch parameters vs.Blean parameters 252
Debugging prblems in functin utput 259+The return
Filters and functins 265+Functins with begin, prcess, and
Declaring variables 270+Using variable scpe mdifiers 272
8.1 Pwer Shell scripts 276
7.1 Fundamentals f Pwer Shell functins 237
assignment 240
7.2 Declaring frmal parameters fr a functin 241
7.3 Returning values frm functins 257
statement 262
7.4Usingsimplefunctnsina pipeline 263
end blcks 266
7.5 Managing functin definitins in a sessin 267
7.6 Variables cping in functins 269
7.7 Summary 273
8Adeanced functins and scripts 275
9 Using and authring mdules 322
CNTENTS
Script executin plicy 276+Passing arguments t
scripts 278+Exiting scripts and the exit state men: 280
Scpes and scripts 281+Managing yur scripts 284
Running Pwer Shell scripts frm ther applica r ins 285
8.2 Writing advanced functins and scripts 287
Specifying script and functin attributes 288+The
Cmd let Binding attribute 289+The utput Type
attribute 293+Specifying parameter attributes 296
Creating parameter aliases with the Alias attrib ure 303
Parameter validatin attributes 305
8.3 Dynamic parameters and dynamic Param 311
Steps fr adding a dyna nic parameter 312+When shuld
dynamic parameters be used : 314
8.4 Dcumenting functins and scripts 314
Autmatically generated help fields 315+Creating manual help
cntent 315+Cmment-based help 316+Tags used in
dcumentatin cmments 318
8.5 Summary 321
9.1 The rle f a mdule system323
Mdule rles in Pwer Shell 32