Windows PowerShell in action [Third edition] 9781633430297, 1633430294

Windows PowerShell transformed the way administrators and developers interact with Windows. PowerShell, an elegant dynam

245 16 14MB

English Pages 625 [938] Year 2016;2018

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Dedication......Page 4
About this Book......Page 31
Who should read this book?......Page 32
Roadmap......Page 33
Code conventions......Page 36
Source code downloads......Page 37
Book forum......Page 38
About the authors......Page 39
About the title......Page 40
Chapter 1. Welcome to PowerShell......Page 42
1.1. What is PowerShell?......Page 45
1.2. PowerShell example code......Page 48
1.3. Core concepts......Page 59
1.4. Parsing the PowerShell language......Page 67
1.5. How the pipeline works......Page 76
1.6. Formatting and output......Page 80
1.7. Summary......Page 86
Chapter 2. Working with types......Page 87
2.1. Type management in the wild, wild West......Page 88
2.2. Basic types and literals......Page 97
2.3. Collections: dictionaries and hashtables......Page 103
2.4. Collections: arrays and sequences......Page 109
2.5. Type literals......Page 113
2.6. Type conversions......Page 116
2.7. Summary......Page 122
Chapter 3. Operators and expressions......Page 123
3.1. Arithmetic operators......Page 126
3.2. Assignment operators......Page 131
3.3. Comparison operators......Page 135
3.4. Pattern matching and text manipulation......Page 142
3.5. Logical and bitwise operators......Page 153
3.6. Where() and ForEach() methods......Page 155
3.7. Summary......Page 158
Chapter 4. Advanced operators and variables......Page 159
4.1. Operators for working with types......Page 161
4.2. Unary operators......Page 163
4.3. Grouping and subexpressions......Page 165
4.4. Array operators......Page 170
4.5. Property and method operators......Page 179
4.6. Format operator......Page 186
4.7. Redirection and redirection operators......Page 188
4.8. Working with variables......Page 191
4.9. Summary......Page 200
Chapter 5. Flow control in scripts......Page 201
5.1. Conditional statement......Page 203
5.2. Looping statements......Page 206
5.3. Labels, break, and continue......Page 212
5.4. switch statement......Page 214
5.5. Flow control using cmdlets......Page 221
5.6. Statements as values......Page 230
5.7. A word about performance......Page 231
5.8. Summary......Page 233
Chapter 6. PowerShell functions......Page 234
6.1. Fundamentals of PowerShell functions......Page 235
6.2. Declaring formal parameters for a function......Page 239
6.3. Returning values from functions......Page 252
6.4. Using simple functions in a pipeline......Page 257
6.5. Managing function definitions in a session......Page 260
6.6. Variable scoping in functions......Page 262
6.7. Summary......Page 267
Chapter 7. Advanced functions and scripts......Page 268
7.1. PowerShell scripts......Page 269
7.2. Writing advanced functions and scripts......Page 279
7.3. Dynamic parameters and dynamicParam......Page 303
7.4. Cmdlet default parameter values......Page 306
7.5. Documenting functions and scripts......Page 310
7.6. Summary......Page 317
Chapter 8. Using and authoring modules......Page 318
8.1. The role of a module system......Page 320
8.2. Module basics......Page 322
8.3. Working with modules......Page 325
8.4. Writing script modules......Page 336
8.5. Binary modules......Page 357
8.6. Summary......Page 362
Chapter 9. Module manifests and metadata......Page 363
9.1. Module folder structure......Page 364
9.2. Module manifest structure......Page 366
9.3. Production manifest elements......Page 370
9.4. Construction manifest elements......Page 373
9.5. Content manifest elements......Page 380
9.6. Advanced module operations......Page 382
9.7. Publishing a module to a PowerShell Gallery......Page 394
9.8. Summary......Page 401
Chapter 10. Metaprogramming with scriptblocks and dynamic code......Page 402
10.1. Scriptblock basics......Page 404
10.2. Building and manipulating objects......Page 410
10.3. Using the Select-Object cmdlet......Page 421
10.4. Dynamic modules......Page 423
10.5. Steppable pipelines......Page 429
10.6. A closer look at the type-system plumbing......Page 433
10.7. Extending the PowerShell language......Page 438
10.8. Building script code at runtime......Page 443
10.9. Compiling code with Add-Type......Page 448
10.10. Summary......Page 452
Chapter 11. PowerShell remoting......Page 453
11.1. PowerShell remoting overview......Page 454
11.2. Applying PowerShell remoting......Page 462
11.3. PowerShell remoting sessions and persistent connections......Page 468
11.4. Implicit remoting......Page 478
11.5. Considerations when running commands remotely......Page 483
11.6. Building custom remoting services......Page 490
11.7. PowerShell Direct......Page 503
11.8. Summary......Page 505
Chapter 12. PowerShell workflows......Page 506
12.1. Workflow overview......Page 507
12.2. Workflow keywords......Page 520
12.3. Using workflows effectively......Page 527
12.4. Workflow cmdlets......Page 536
12.5. Summary......Page 543
Chapter 13. PowerShell Jobs......Page 544
13.1. Background jobs in PowerShell......Page 545
13.2. Workflows as jobs......Page 559
13.3. Scheduled jobs......Page 567
13.4. Summary......Page 571
Chapter 14. Errors and exceptions......Page 572
14.1. Error handling......Page 573
14.2. Dealing with errors that terminate execution......Page 589
14.3. PowerShell and the event log......Page 595
14.4. Summary......Page 603
Chapter 15. Debugging......Page 604
15.1. Script instrumentation......Page 605
15.2. Capturing session output......Page 621
15.3. PowerShell script debugging features......Page 626
15.4. Command-line debugging......Page 634
15.5. Beyond scripts......Page 640
15.6. Summary......Page 647
Chapter 16. Working with providers, files, and CIM......Page 648
16.1. PowerShell providers......Page 649
16.2. Files, text, and XML......Page 658
16.3. Accessing COM objects......Page 685
16.4. Using CIM......Page 693
16.5. Summary......Page 701
Chapter 17. Working with .NET and events......Page 702
17.1. .NET and PowerShell......Page 703
17.2. Real-time events......Page 718
17.3. Summary......Page 748
Chapter 18. Desired State Configuration......Page 749
18.1. DSC model and architecture......Page 750
18.2. Push mode to a single node......Page 757
18.3. Pushing to multiple nodes......Page 764
18.4. DSC in pull mode......Page 771
18.5. Configuring the Local Configuration Manager......Page 782
18.6. Partial configurations......Page 789
18.7. Summary......Page 797
Chapter 19. Classes in PowerShell......Page 798
19.1. Writing classes in PowerShell......Page 799
19.2. Methods in PowerShell classes......Page 807
19.3. Extending existing classes......Page 818
19.4. Classes, modules, using, and namespaces......Page 823
19.5. Writing class-based DSC resources......Page 827
19.6. Summary......Page 832
Chapter 20. The PowerShell and runspace APIs......Page 833
20.1. PowerShell API basics......Page 834
20.2. Runspaces and the PowerShell API......Page 844
20.3. Runspace pools......Page 850
20.4. Out-of-process runspaces......Page 853
20.5. Remote runspaces......Page 855
20.6. Managing runspaces......Page 858
20.7. Summary......Page 860
The PowerShell open source project......Page 862
PowerShell on Linux and macOS......Page 865
PowerShell remoting and Linux......Page 871
DSC and Linux......Page 875
Summary......Page 880

Windows PowerShell in action [Third edition]
 9781633430297, 1633430294

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers