PowerShell in depth : an administrator's guide
معرفی کتاب «PowerShell in depth : an administrator's guide» نوشتهٔ Don Jones, Richard Siddaway, Jeffrey Hicks، منتشرشده توسط نشر Manning Publications Co. LLC در سال 2013. این کتاب در 52 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «PowerShell in depth : an administrator's guide» در دستهٔ بدون دستهبندی قرار دارد.
This Book Requires Basic Familiarity With Powershell.--resource Description Page. By Don Jones, Richard Siddaway, Jeffrey Hicks. Includes Index. Front cover......Page 1 brief contents......Page 6 contents......Page 8 preface......Page 22 acknowledgments......Page 24 about this book......Page 26 Author Online......Page 27 about the authors......Page 28 about the cover illustration......Page 30 Part 1—PowerShell fundamentals......Page 32 1.1 Who this book is for......Page 34 1.3 What this book won’t teach you......Page 35 1.5 Beyond PowerShell......Page 36 1.6 Ready?......Page 37 2 PowerShell hosts......Page 38 2.1 32-bit vs. 64-bit, and administrator vs. not......Page 39 2.2 The console......Page 41 2.3 The PowerShell ISE......Page 43 2.4 Command history buffer vs. PowerShell’s history......Page 46 2.6 Summary......Page 47 3.1 The help commands......Page 48 3.2 Where’s the help?......Page 49 3.3 Using the help......Page 51 3.4 “About” help files......Page 54 3.5 Provider help......Page 55 3.6 Interpreting command help......Page 56 3.7 Common parameters......Page 58 3.8 Summary......Page 59 4 The basics of PowerShell syntax......Page 60 4.1 Commands......Page 61 4.1.1 Aliases: nicknames for commands......Page 62 4.2 Parameters......Page 63 4.2.1 Truncating parameter names......Page 65 4.3 Typing trick: line continuation......Page 66 4.4 Parenthetical commands and expressions......Page 67 4.5 Script blocks......Page 68 4.6 Summary......Page 69 5.1 There’s only one shell......Page 70 5.2 PSSnapins vs. modules......Page 71 5.4.1 Discovering extensions......Page 72 5.4.3 Discovering extensions’ additions......Page 74 5.5 Command name conflicts......Page 75 5.7 Summary......Page 76 6 Operators......Page 77 6.1 Logical and comparison operators......Page 78 6.1.1 The –contains operator......Page 79 6.1.2 The -in and -notin operators......Page 80 6.1.3 Boolean, or logical, operators......Page 81 6.1.4 Bitwise operators......Page 82 6.2 Arithmetic operators......Page 84 6.3.1 String and array manipulation operators......Page 86 6.3.2 Object type operators......Page 87 6.3.3 Format operator......Page 88 6.3.4 Miscellaneous operators......Page 89 6.4 Summary......Page 90 7 Working with objects......Page 91 7.1 Introduction to objects......Page 92 7.2 Members: properties, methods, and events......Page 94 7.3 Sorting objects......Page 99 7.4 Selecting objects......Page 100 7.4.1 Use 1: choosing properties......Page 101 7.4.2 Use 2: choosing a subset of objects......Page 102 7.4.3 Use 3: making custom properties......Page 104 7.4.4 Use 4: extracting and expanding properties......Page 106 7.5.1 Simplified syntax......Page 110 7.6 Grouping objects......Page 112 7.7 Measuring objects......Page 114 7.8 Enumerating objects......Page 115 7.8.2 Simplified syntax......Page 116 7.9 Importing, exporting, and converting objects......Page 117 7.10 Comparing objects......Page 121 7.11 Summary......Page 123 8.1 How the pipeline works......Page 124 8.1.1 The old way of piping......Page 125 8.1.2 The PowerShell way of piping......Page 126 8.2 Parameter binding ByValue......Page 127 8.3 Pipeline binding ByPropertyName......Page 129 8.4 Troubleshooting parameter binding......Page 135 8.5 When parameter binding lets you down......Page 140 8.7 Summary......Page 141 9.1 The time to format......Page 142 9.2.2 What properties should be displayed?......Page 144 9.3.1 Formatting wide lists......Page 145 9.3.2 Formatting tables......Page 146 9.3.3 Formatting lists......Page 151 9.4.1 Formatting is the end of the line......Page 153 9.4.2 Select or format?......Page 154 9.4.3 Format, out, export—which?......Page 155 9.5 Summary......Page 156 Part 2—PowerShell management......Page 158 10 PowerShell Remoting......Page 160 10.2 Remoting overview......Page 161 10.2.1 Authentication......Page 162 10.3.1 Enabling Remoting......Page 163 10.3.2 1-to-1 Remoting......Page 164 10.3.3 1-to-many Remoting......Page 165 10.3.4 Remoting caveats......Page 167 10.3.5 Remoting options......Page 169 10.4.2 Using a session......Page 171 10.4.4 Disconnecting and reconnecting sessions......Page 172 10.5.1 Session parameters......Page 175 10.6 Creating a custom endpoint......Page 176 10.6.1 Custom endpoints for delegated administration......Page 178 10.7 Connecting to nondefault endpoints......Page 179 10.8 Enabling the “second hop”......Page 180 10.9 Setting up WinRM listeners......Page 181 10.10.1 Cross-domain Remoting......Page 183 10.10.2 Quotas......Page 184 10.10.4 Key WinRM configuration settings......Page 185 10.10.5 Adding a machine to your Trusted Hosts list......Page 186 10.10.6 Using Group Policy to configure Remoting......Page 187 10.11 Implicit Remoting......Page 188 10.12 Summary......Page 190 11.1 Remoting-based jobs......Page 191 11.1.1 Starting jobs......Page 192 11.1.3 Working with child jobs......Page 193 11.1.6 Getting job results......Page 195 11.1.7 Removing jobs......Page 196 11.2 WMI jobs......Page 197 11.3 Scheduled jobs......Page 198 11.3.2 Creating a scheduled job......Page 199 11.3.3 Managing scheduled jobs......Page 200 11.4 Job processes......Page 201 11.4.1 Jobs created with Start-Job......Page 202 11.4.2 Jobs created with Invoke-Command......Page 203 11.5 Summary......Page 204 12 Working with credentials......Page 205 12.1 About credentials......Page 206 12.2 Using credentials......Page 209 12.3.2 Saving a credential object......Page 210 12.3.4 Supporting credentials in your script......Page 212 12.4 Summary......Page 214 13 Regular expressions......Page 215 13.1 Basic regular expression syntax......Page 216 13.2 The –match operator......Page 219 13.4 Switch statement......Page 221 13.5 The REGEX object......Page 223 13.6 Summary......Page 226 14.1 Working with HTML......Page 227 14.1.1 Retrieving an HTML page......Page 228 14.1.2 Working with the HTML results......Page 229 14.1.3 Practical example......Page 232 14.1.4 Creating HTML output......Page 233 14.2.1 Using XML to persist data......Page 237 14.2.2 Reading arbitrary XML data......Page 238 14.2.3 Creating XML data and files......Page 239 14.3 Summary......Page 240 15.1 Why use PSProviders?......Page 241 15.2 What are PSProviders?......Page 242 15.3 What are PSDrives?......Page 243 15.4 Working with PSDrives......Page 244 15.4.1 Working with PSDrive items......Page 245 15.4.2 Working with item properties......Page 247 15.5 Transactional operations......Page 250 15.6 Every drive is different......Page 252 15.7 Summary......Page 254 16.1 Variables......Page 255 16.1.1 Variable names......Page 256 16.1.2 Variable types......Page 257 16.1.3 Being strict with variables......Page 259 16.2 Built-in variables and the Variable: drive......Page 261 16.3 Variable commands......Page 262 16.4 Arrays......Page 263 16.5 Hash tables and ordered hash tables......Page 266 16.5.1 Ordered hash tables......Page 270 16.6 Scriptblocks......Page 272 16.7 Summary......Page 274 17.1 PowerShell security goals......Page 275 17.2.1 Script execution requires a path......Page 276 17.2.2 Filename extension associations......Page 277 17.3.1 A digital signature crash course......Page 278 17.3.2 Understanding script signing......Page 280 17.3.3 The execution policy in depth......Page 282 17.4 The PowerShell security debate......Page 286 17.5 Summary......Page 287 18.1 Splatting......Page 288 18.2 Defining default parameter values......Page 290 18.3 Running external utilities......Page 294 18.4 Expressions in quotes: $($cool)......Page 300 18.5 Parentheticals as objects......Page 301 18.6 Increase the format enumeration limit......Page 302 18.7 Hash tables as objects......Page 303 18.8 Summary......Page 305 Part 3—PowerShell scripting and automation......Page 306 19.1 Defining conditions......Page 308 19.2.1 The For loop......Page 309 19.2.2 The other loops......Page 311 19.3 ForEach......Page 312 19.4 Break and Continue......Page 314 19.5 If . . . ElseIf . . . Else......Page 315 19.6 Switch......Page 317 19.7 Mastering the punctuation......Page 320 19.8 Summary......Page 321 20.1 Script or function?......Page 322 20.2 Execution lifecycle and scope......Page 323 20.4 Accepting input......Page 324 20.5 Creating output......Page 326 20.6 “Filtering” scripts......Page 328 20.7 Moving to a function......Page 330 20.8 Summary......Page 331 21 Creating objects for output......Page 332 21.1 Why output objects?......Page 333 21.2.1 Technique 1: using a hash table......Page 334 21.2.2 Technique 2: using Select-Object......Page 336 21.2.3 Technique 3: using Add-Member......Page 337 21.2.5 Technique 5: creating a new class......Page 338 21.3 Complex objects: collections as properties......Page 340 21.4 Applying a type name to custom objects......Page 343 21.5 So, why bother?......Page 344 21.6 Summary......Page 347 22.1 Understanding scope......Page 348 22.2 Observing scope in action......Page 352 22.3 Dot sourcing......Page 354 22.4 Manipulating cross-scope elements......Page 355 22.6 Being strict......Page 359 22.7 Summary......Page 362 23 PowerShell workflows......Page 363 23.1 Workflow overview......Page 364 23.2 Workflow basics......Page 365 23.2.2 Activities and stateless execution......Page 366 23.2.5 Workflow limitations......Page 368 23.2.6 Parallelism......Page 371 23.3 General workflow design strategy......Page 372 23.5 Writing the workflow......Page 373 23.6 Workflows vs. functions......Page 374 23.7.1 Sequences......Page 376 23.7.2 InlineScript......Page 377 23.8.1 Workflow jobs......Page 380 23.8.2 Suspending and restarting a workflow......Page 381 23.9 A practical example......Page 382 23.10 Invoke-AsWorkflow......Page 384 23.11 PSWorkflowSession......Page 386 23.12 Troubleshooting a workflow......Page 388 23.13 Summary......Page 389 24 Advanced syntax for scripts and functions......Page 390 24.2 Advanced parameters......Page 391 24.3 Variations on parameter inputs......Page 396 24.4 Parameter aliases......Page 397 24.5 Parameter validation......Page 398 24.6 Parameter sets......Page 403 24.7 WhatIf and Confirm parameters......Page 404 24.8 Verbose output......Page 406 24.9 Summary......Page 409 25 Script modules and manifest modules......Page 410 25.1 Making a script module......Page 411 25.2 Exporting module members......Page 413 25.3 Making a module manifest......Page 417 25.4 Creating dynamic modules......Page 418 25.5 Summary......Page 421 26 Custom formatting views......Page 422 26.1 Object type names......Page 423 26.3 Starting a view file......Page 424 26.4 Adding view types......Page 425 26.5 Importing view data......Page 428 26.6 Using named views......Page 430 26.7 Going further......Page 432 26.8 Summary......Page 433 27 Custom type extensions......Page 434 27.1 What are type extensions?......Page 435 27.2 Creating and loading a type extension file......Page 436 27.3.2 ScriptProperty......Page 438 27.3.3 ScriptMethod......Page 439 27.4 A complete example......Page 440 27.5 Updating type data dynamically......Page 442 27.6 Get-TypeData......Page 445 27.7 Remove-TypeData......Page 446 27.8 Summary......Page 447 28 Data language and internationalization......Page 448 28.1 Internationalization basics......Page 449 28.2 Adding a data section......Page 451 28.3 Storing translated strings......Page 453 28.4 Testing localization......Page 456 28.5 Summary......Page 459 29 Writing help......Page 460 29.1 Comment-based help......Page 461 29.3 XML-based help......Page 463 29.4 Summary......Page 465 30 Error handling techniques......Page 466 30.2 Using $ErrorActionPreference and –ErrorAction......Page 467 30.3 Using –ErrorVariable......Page 469 30.4 Using $Error......Page 470 30.5 Trap constructs......Page 471 30.6 Try...Catch...Finally constructs......Page 474 30.7 Summary......Page 477 31 Debugging tools and techniques......Page 478 31.1 Debugging: all about expectations......Page 479 31.2 Write-Debug......Page 487 31.3 Breakpoints......Page 491 31.4 Using Set-PSDebug......Page 494 31.6 Summary......Page 496 32 Functions that work like cmdlets......Page 497 32.1 Defining the task......Page 498 32.2 Building the command......Page 499 32.3 Parameterizing the pipeline......Page 500 32.5 Error handling......Page 503 32.5.1 Adding verbose and debug output......Page 505 32.6 Making it a function and adding help......Page 508 32.7 Creating a custom view......Page 510 32.8 Creating a type extension......Page 511 32.9 Making a module manifest......Page 512 32.10 Summary......Page 515 33.1 What not to do......Page 516 33.2 Working with HTML fragments and files......Page 518 33.2.2 Producing an HTML fragment......Page 519 33.2.3 Assembling the final HTML page......Page 520 33.3 Sending email......Page 523 33.4 Summary......Page 524 Part 4—Advanced PowerShell......Page 526 34 Working with the Component Object Model (COM)......Page 528 34.1 Introduction to COM objects......Page 529 34.3 Accessing and using COM objects’ members......Page 531 34.4 PowerShell and COM examples......Page 534 34.5 Summary......Page 535 35 Working with .NET Framework objects......Page 536 35.1 Classes, instances, and members......Page 537 35.2 .NET Framework syntax in PowerShell......Page 538 35.3 .NET support in PowerShell......Page 539 35.5 Finding the right framework bits......Page 540 35.6 Creating and working with instances......Page 545 35.7 Summary......Page 547 36 Accessing databases......Page 548 36.2 Connecting to data sources......Page 549 36.3 Querying data......Page 550 36.3.2 Databases with DataReaders......Page 551 36.5 Calling stored procedures......Page 552 36.6 A module to make it easier......Page 553 36.7 Summary......Page 555 37.1 The purpose of proxy functions......Page 556 37.3 Creating a basic proxy function......Page 557 37.4 Adding a parameter......Page 559 37.5 Removing a parameter......Page 563 37.6 Turning it into a function......Page 565 37.7 Summary......Page 567 38 Building a GUI......Page 569 38.1 WinForms via PowerShell Studio......Page 570 38.1.1 Creating the GUI......Page 571 38.1.2 Adding the code......Page 574 38.1.3 Using the script......Page 579 38.2 Windows Presentation Foundation (WPF) and ShowUI......Page 583 38.3 WinForms vs. WPF......Page 585 38.4 Ideas for leveraging a GUI tool......Page 586 38.5 Summary......Page 587 39 WMI and CIM......Page 588 39.1 What is WMI?......Page 589 39.2.1 Get-WmiObject......Page 590 39.2.2 Remove-WmiObject......Page 592 39.2.3 Set-WmiInstance......Page 593 39.2.4 Invoke-WmiMethod......Page 594 39.2.5 Register-WmiEvent......Page 597 39.3 CIM cmdlets......Page 598 39.3.1 Get-CIMClass......Page 601 39.3.2 Get-CimInstance......Page 602 39.3.3 Remove-CimInstance......Page 604 39.3.5 Invoke-CimMethod......Page 605 39.3.6 Register-CimIndicationEvent......Page 606 39.4 CIM sessions......Page 607 39.5 “Cmdlets over objects”......Page 609 39.6 Summary......Page 614 40.1 PowerShell general best practices......Page 615 40.2 PowerShell scripting best practices......Page 616 40.3 PowerShell in the enterprise best practices......Page 618 B......Page 620 C......Page 621 E......Page 622 F......Page 623 I......Page 624 M......Page 625 O......Page 626 P......Page 627 R......Page 628 S......Page 629 T......Page 630 W......Page 631 X......Page 632 Back cover......Page 633 SummaryPowerShell in Depth is the kind of book you'll want open on your desk most of the time. With 40 short chapters, each focused on a specific area of PowerShell, you'll be able to find the answers you need quickly. Each chapter is concise and to-the-point, so you can spend less time reading and more time getting down to the business at hand. It was written by three seasoned PowerShell experts, and every technique has been thoroughly tested. With this book in hand, you'll be able to consistently and quickly produce production quality, maintainable scripts that will save you countless hours of time and effort.About this Book Organized into 40 concise chapters, PowerShell in Depth is the go-to reference for administrators working with Windows PowerShell. Every major shell technique, technology, and tactic is explained and demonstrated, providing a comprehensive reference to almost everything an admin would do in the shell. Written by three experienced authors and PowerShell MVPs, this is the PowerShell book you'll keep next to your monitor—not on your bookshelf!This book requires basic familiarity with PowerShell.What's InsideCovers PowerShell 3.0 Automating time-consuming tasks Managing HTML and XML data Background jobs and scheduling PowerShell security Packaging and deploying scripts Standard scripting conventions Using the .NET Framework in PowerShell scripts Much morePurchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.About the Authors Don Jones, Jeffery Hicks, and Richard Siddaway are Microsoft MVPs who have collectively authored nearly three dozen books on PowerShell and Windows administration.Table of ContentsPART 1: POWERSHELL FUNDAMENTALS Introduction PowerShell hosts Using the PowerShell help system The basics of PowerShell syntax Working with PSSnapins and modules Operators Working with objects The PowerShell pipeline Formatting PART 2: POWERSHELL MANAGEMENT PowerShell Remoting Background jobs and scheduling Working with credentials Regular expressions Working with HTML and XML data PSDrives and PSProviders Variables, arrays, hash tables, and scriptblocks PowerShell security Advanced PowerShell syntax PART 3: POWERSHELL SCRIPTING AND AUTOMATION PowerShell's scripting language Basic scripts and functions Creating objects for output Scope PowerShell workflows Advanced syntax for scripts and functions Script modules and manifest modules Custom formatting views Custom type extensions Data language and internationalization Writing help Error handling techniques Debugging tools and techniques Functions that work like cmdlets Tips and tricks for creating reports PART 4: ADVANCED POWERSHELL Working with the Component Object Model (COM) Working with .NET Framework objects Accessing databases Proxy functions Building a GUI WMI and CIM Best practices PowerShell in Depth is the kind of book you'll want open on your desk most of the time. With 40 short chapters, each focused on a specific area of PowerShell, you'll be able to find the answers you need quickly. Each chapter is concise and to-the-point, so you can spend less time reading and more time getting down to the business at hand. It was written by three seasoned PowerShell experts, and every technique has been thoroughly tested. With this book in hand, you'll be able to consistently and quickly produce production quality, maintainable scripts that will save you countless hours of time and effort. About this Book Organized into 40 concise chapters, PowerShell in Depth is the go-to reference for administrators working with Windows PowerShell. Every major shell technique, technology, and tactic is explained and demonstrated, providing a comprehensive reference to almost everything an admin would do in the shell. Written by three experienced authors and PowerShell MVPs, this is the PowerShell book you'll keep next to your monitor--not on your bookshelf! This book requires basic familiarity with PowerShell. What's Inside Covers PowerShell 3.0 Automating time-consuming tasks Managing HTML and XML data Background jobs and scheduling PowerShell security Packaging and deploying scripts Standard scripting conventions Using the .NET Framework in PowerShell scripts Much more Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Authors Don Jones, Jeffery Hicks, and Richard Siddaway are Microsoft MVPs who have collectively authored nearly three dozen books on PowerShell and Windows administration PowerShell is part of nearly everything a Windows administrator touches, and the soon-to-be-released version 3 adds even more powerful features. With PowerShell, almost every aspect of Windows systems and servers can be securely and efficiently automated. Designed to provide the know- how needed to master PowerShell, this book goes beyond the basics and offers the deep knowledge and insight needed to tackle any task. PowerShell in Depth is a book that will be used again and again. Each of the 40 chapters is short, concise, to-the-point, and focused on a specific area of PowerShell. Written by three seasoned PowerShell experts, every technique has been thoroughly tested. With this book in hand, readers will save hours of time and effort while consistently and quickly creating production-quality, maintainable scripts. Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.
دانلود کتاب PowerShell in depth : an administrator's guide