Windows PowerShell Cookbook, Second edition
معرفی کتاب «Windows PowerShell Cookbook, Second edition» نوشتهٔ Lee Holmes، منتشرشده توسط نشر O Reilly Media در سال 2010. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Windows PowerShell Cookbook, Second edition» در دستهٔ بدون دستهبندی قرار دارد.
Table of Contents......Page 7 Foreword......Page 19 Glue, Enablers, and a WSH......Page 23 That Lee Guy......Page 25 Preface......Page 27 Part III: Common Tasks......Page 28 What You Need to Use This Book......Page 29 Using Code Examples......Page 30 Safari® Books Online......Page 31 Acknowledgments......Page 32 Part I. Tour......Page 33 Introduction......Page 35 An Interactive Shell......Page 36 Structured Commands (Cmdlets)......Page 39 Administrators as First-Class Users......Page 40 Composable Commands......Page 41 Common Discovery Commands......Page 42 Ubiquitous Scripting......Page 43 Bridging Technologies......Page 44 Namespace Navigation Through Providers......Page 46 Much, Much More......Page 48 Part II. Fundamentals......Page 49 Solution......Page 51 Discussion......Page 52 Problem......Page 53 Discussion......Page 54 Solution......Page 55 Solution......Page 56 Discussion......Page 57 Discussion......Page 59 Solution......Page 60 Discussion......Page 61 Discussion......Page 63 Solution......Page 64 Discussion......Page 65 1.9 Program: Search Help for Text......Page 66 1.10 Program: View PowerShell’s HTML Help......Page 68 Discussion......Page 69 Discussion......Page 70 Solution......Page 72 Discussion......Page 73 1.14 Program: Learn Aliases for Common Commands......Page 74 Solution......Page 76 Discussion......Page 77 Problem......Page 78 Discussion......Page 79 1.17 Program: Create Scripts from Session History......Page 80 Problem......Page 81 Discussion......Page 82 1.19 Program: Search Formatted Output for a Pattern......Page 83 Discussion......Page 84 Processing output......Page 85 Discussion......Page 86 Problem......Page 87 Discussion......Page 88 Solution......Page 89 Detecting loaded modules......Page 90 Solution......Page 91 Discussion......Page 92 See Also......Page 93 2.0 Introduction......Page 95 Discussion......Page 96 Solution......Page 97 Discussion......Page 98 2.3 Program: Simplify Most Where-Object Filters......Page 100 See Also......Page 101 2.4 Program: Interactively Filter Lists of Objects......Page 102 Solution......Page 104 See Also......Page 105 Solution......Page 106 Discussion......Page 107 See Also......Page 109 Solution......Page 110 Discussion......Page 111 Solution......Page 112 Solution......Page 113 Solution......Page 115 Discussion......Page 117 See Also......Page 119 3.0 Introduction......Page 121 Discussion......Page 122 Discussion......Page 124 Discussion......Page 126 Solution......Page 127 Discussion......Page 128 See Also......Page 129 3.5 Program: Retain Changes to Environment Variables Set by a Batch File......Page 130 See Also......Page 131 Discussion......Page 132 Aliases and drives......Page 133 3.7 Program: Create a Dynamic Variable......Page 134 Solution......Page 136 Static methods......Page 137 Instance methods......Page 138 Instance properties......Page 139 Solution......Page 140 Discussion......Page 141 3.10 Program: Create Instances of Generic Objects......Page 142 Solution......Page 145 See Also......Page 146 Solution......Page 147 Discussion......Page 148 Discussion......Page 149 Public methods......Page 150 Discussion......Page 151 Calculated properties......Page 152 Solution......Page 153 Discussion......Page 154 Discussion......Page 157 Getting started......Page 158 Add a ScriptProperty......Page 159 Add a ScriptMethod......Page 160 Add other extension points......Page 161 Solution......Page 163 Discussion......Page 164 Solution......Page 165 Discussion......Page 166 Discussion......Page 167 Solution......Page 168 Discussion......Page 169 See Also......Page 170 Discussion......Page 171 See Also......Page 172 Solution......Page 173 Discussion......Page 174 See Also......Page 175 Problem......Page 176 See Also......Page 177 Discussion......Page 178 Discussion......Page 179 Solution......Page 180 Discussion......Page 181 See Also......Page 182 Discussion......Page 183 Discussion......Page 184 Solution......Page 186 Discussion......Page 187 Discussion......Page 188 Solution......Page 189 Solution......Page 190 Discussion......Page 191 5.14 Program: Convert Text Streams to Objects......Page 192 See Also......Page 195 Discussion......Page 196 Creating large text reports......Page 197 Discussion......Page 198 Solution......Page 203 Discussion......Page 204 Solution......Page 205 Working with degrees instead of radians......Page 206 Solution......Page 207 Discussion......Page 208 Discussion......Page 209 Solution......Page 212 Solution......Page 213 See Also......Page 214 Solution......Page 215 Discussion......Page 216 Solution......Page 217 Solution......Page 218 Discussion......Page 219 Discussion......Page 220 Discussion......Page 221 See Also......Page 222 Discussion......Page 223 Discussion......Page 224 Problem......Page 225 Problem......Page 226 Problem......Page 227 Discussion......Page 228 Discussion......Page 229 Discussion......Page 230 See Also......Page 231 See Also......Page 233 Discussion......Page 234 Problem......Page 235 Solution......Page 236 Discussion......Page 237 Discussion......Page 238 See Also......Page 239 8.5 Program: Search the Windows Start Menu......Page 240 Discussion......Page 241 See Also......Page 246 Part III. Common Tasks......Page 247 Discussion......Page 249 See Also......Page 250 Discussion......Page 251 See Also......Page 253 Solution......Page 254 Discussion......Page 255 Problem......Page 256 Solution......Page 257 Discussion......Page 258 Discussion......Page 259 Solution......Page 260 Discussion......Page 261 Replace text that spans multiple lines......Page 262 9.7 Program: Get the Encoding of a File......Page 263 9.8 Program: View the Hexadecimal Representation of Content......Page 265 See Also......Page 268 Problem......Page 269 Solution......Page 270 Discussion......Page 271 Solution......Page 272 Discussion......Page 273 Discussion......Page 274 Solution......Page 275 Discussion......Page 276 Solution......Page 277 Discussion......Page 278 Discussion......Page 279 Discussion......Page 280 Solution......Page 281 Solution......Page 283 Discussion......Page 284 See Also......Page 285 Discussion......Page 287 Solution......Page 290 See Also......Page 291 Discussion......Page 292 Solution......Page 293 Discussion......Page 294 Discussion......Page 295 Solution......Page 297 Discussion......Page 298 Problem......Page 300 Discussion......Page 301 Problem......Page 302 Discussion......Page 303 Solution......Page 304 Solution......Page 306 Discussion......Page 307 Solution......Page 308 Discussion......Page 309 Supporting PowerShell’s common parameters......Page 310 See Also......Page 311 Discussion......Page 312 Defining parameter behavior......Page 313 Defining parameter validation......Page 314 Solution......Page 316 See Also......Page 317 Discussion......Page 318 Discussion......Page 319 See Also......Page 321 Discussion......Page 322 Solution......Page 324 Discussion......Page 325 See Also......Page 326 Discussion......Page 327 Solution......Page 328 Discussion......Page 329 Solution......Page 332 Solution......Page 333 See Also......Page 334 Solution......Page 335 11.23 Program: Enhance or Extend an Existing Cmdlet......Page 336 See Also......Page 343 Discussion......Page 345 Solution......Page 346 Discussion......Page 347 12.3 Program: Get-PageUrls......Page 350 Solution......Page 353 Discussion......Page 354 12.5 Program: Connect-WebService......Page 355 Solution......Page 358 Discussion......Page 359 12.8 Program: Send-MailMessage......Page 360 12.9 Program: Interact with Internet Protocols......Page 361 See Also......Page 366 Solution......Page 367 Solution......Page 368 13.3 Program: Display a Menu to the User......Page 369 Discussion......Page 371 Solution......Page 374 Discussion......Page 375 Date, time, and number formats......Page 376 Capitalization rules......Page 377 See Also......Page 378 Discussion......Page 379 13.8 Program: Invoke a Script Block with Alternate Culture Settings......Page 381 Problem......Page 382 Discussion......Page 383 13.10 Program: Add a Graphical User Interface to Your Script......Page 384 See Also......Page 386 Discussion......Page 387 See Also......Page 389 14.0 Introduction......Page 391 Problem......Page 392 Discussion......Page 393 Solution......Page 394 Discussion......Page 395 Discussion......Page 397 Solution......Page 400 Discussion......Page 401 Solution......Page 402 Discussion......Page 403 Solution......Page 404 Discussion......Page 405 See Also......Page 406 14.7 Program: Watch an Expression for Changes......Page 407 14.8 Program: Get Script Code Coverage......Page 409 See Also......Page 411 Solution......Page 413 Discussion......Page 414 Discussion......Page 415 Discussion......Page 417 15.4 Program: Resolve an Error......Page 418 Solution......Page 419 Discussion......Page 420 Discussion......Page 421 Problem......Page 424 15.8 Program: Analyze a Script’s Performance Profile......Page 425 See Also......Page 430 Solution......Page 431 Discussion......Page 432 Solution......Page 433 Functions......Page 434 16.3 Program: Investigate the InvocationInfo Variable......Page 435 Solution......Page 437 Discussion......Page 438 Discussion......Page 439 Problem......Page 441 Discussion......Page 442 Problem......Page 443 Solution......Page 444 Discussion......Page 445 Problem......Page 447 17.2 Program: Query a SQL Data Source......Page 448 Problem......Page 451 Discussion......Page 452 Solution......Page 454 Discussion......Page 455 17.5 Program: Invoke Simple Windows API Calls......Page 460 Solution......Page 463 Discussion......Page 464 See Also......Page 465 Discussion......Page 466 See Also......Page 467 Discussion......Page 468 See Also......Page 469 Step 2: Create a file to hold the cmdlet source code......Page 470 Problem......Page 472 Step 2: Create a file to hold the hosting source code......Page 473 See Also......Page 475 18.0 Introduction......Page 477 Solution......Page 478 Discussion......Page 479 Execution policies are not user restrictions......Page 480 Discussion......Page 481 Discussion......Page 482 See Also......Page 483 Discussion......Page 484 Apply PowerShell’s Group Policy templates......Page 485 Discussion......Page 487 See Also......Page 488 Discussion......Page 489 Discussion......Page 490 See Also......Page 491 Discussion......Page 492 18.10 Program: Start a Process as Another User......Page 493 18.11 Program: Run a Temporarily Elevated Command......Page 495 Solution......Page 497 Discussion......Page 498 Discussion......Page 499 18.14 Program: Search the Certificate Store......Page 500 Discussion......Page 502 Discussion......Page 503 See Also......Page 504 19.0 Introduction......Page 505 Discussion......Page 507 Discussion......Page 509 See Also......Page 510 Solution......Page 511 Discussion......Page 512 See Also......Page 513 Part IV. Administrator Tasks......Page 515 20.0 Introduction......Page 517 Discussion......Page 518 Discussion......Page 519 Discussion......Page 520 Discussion......Page 521 Discussion......Page 522 Solution......Page 523 Discussion......Page 524 Discussion......Page 526 20.8 Program: Get Disk Usage Information......Page 527 Problem......Page 529 20.11 Program: Get the MD5 or SHA1 Hash of a File......Page 530 Discussion......Page 533 Solution......Page 534 See Also......Page 535 20.16 Program: Move or Remove a Locked File......Page 536 Discussion......Page 538 Discussion......Page 540 20.19 Program: Add Extended File Properties to Files......Page 541 20.20 Program: Create a Filesystem Hard Link......Page 543 20.21 Program: Create a ZIP Archive......Page 545 See Also......Page 547 Solution......Page 549 Solution......Page 550 Discussion......Page 551 Solution......Page 552 Discussion......Page 553 Solution......Page 554 See Also......Page 555 Discussion......Page 556 Discussion......Page 558 21.9 Program: Search the Windows Registry......Page 559 See Also......Page 561 Solution......Page 562 Problem......Page 563 Discussion......Page 564 21.13 Program: Get Registry Items from Remote Machines......Page 565 21.14 Program: Get Properties of Remote Registry Keys......Page 567 21.15 Program: Set Properties of Remote Registry Keys......Page 569 Launch and configure Process Monitor......Page 571 Tell Process Monitor to begin capturing information......Page 572 Review the capture logs for registry modification......Page 573 See Also......Page 574 Discussion......Page 575 Problem......Page 577 Discussion......Page 578 See Also......Page 579 Solution......Page 581 Discussion......Page 582 Solution......Page 583 Solution......Page 584 Problem......Page 585 Discussion......Page 586 Performing complex event analysis and correlation......Page 587 Solution......Page 588 Discussion......Page 589 Solution......Page 590 Discussion......Page 591 Discussion......Page 592 See Also......Page 593 Discussion......Page 594 Problem......Page 595 Discussion......Page 596 Solution......Page 597 Discussion......Page 598 See Also......Page 599 24.0 Introduction......Page 601 Discussion......Page 602 Solution......Page 603 Solution......Page 604 Solution......Page 605 Discussion......Page 606 Discussion......Page 607 See Also......Page 608 Solution......Page 609 Discussion......Page 610 Discussion......Page 611 See Also......Page 612 26.0 Introduction......Page 613 Install ADAM......Page 614 Create a test instance......Page 615 See Also......Page 616 Discussion......Page 617 Discussion......Page 618 Solution......Page 619 See Also......Page 620 See Also......Page 621 26.8 Program: Import Users in Bulk to Active Directory......Page 622 Discussion......Page 624 Discussion......Page 625 Discussion......Page 626 Discussion......Page 627 Problem......Page 628 Problem......Page 629 Solution......Page 630 Discussion......Page 631 Solution......Page 632 See Also......Page 633 Solution......Page 634 Solution......Page 635 Problem......Page 636 Discussion......Page 637 Solution......Page 639 See Also......Page 640 27.3 Program: List Logon or Logoff Scripts for a User......Page 641 27.4 Program: List Startup or Shutdown Scripts for a Machine......Page 642 See Also......Page 643 Solution......Page 644 Solution......Page 645 27.8 Program: List All Installed Software......Page 646 See Also......Page 648 Discussion......Page 649 Discussion......Page 651 Solution......Page 652 Discussion......Page 653 Solution......Page 654 Solution......Page 655 Problem......Page 656 Discussion......Page 657 27.17 Program: Summarize System Information......Page 658 Solution......Page 659 See Also......Page 660 See Also......Page 661 See Also......Page 662 Discussion......Page 663 See Also......Page 664 28.0 Introduction......Page 665 Solution......Page 667 Discussion......Page 668 Solution......Page 669 Discussion......Page 670 Solution......Page 671 28.4 Program: Determine Properties Available to WMI Filters......Page 672 See Also......Page 673 28.5 Program: Search for WMI Classes......Page 674 Advanced class features......Page 677 Discussion......Page 678 Solution......Page 679 Retrieving data......Page 680 Calling methods on an instance......Page 681 See Also......Page 682 29.0 Introduction......Page 683 Discussion......Page 684 29.2 Program: Invoke a PowerShell Expression on a Remote Machine......Page 685 Solution......Page 688 Discussion......Page 689 Solution......Page 690 Solution......Page 691 Enable remoting on a single local machine......Page 692 Discussion......Page 693 29.7 Program: Remotely Enable PowerShell Remoting......Page 694 Discussion......Page 696 Problem......Page 697 Discussion......Page 698 Solution......Page 699 Discussion......Page 700 Problem......Page 701 Discussion......Page 702 Solution......Page 705 Discussion......Page 706 Discussion......Page 708 See Also......Page 711 Discussion......Page 712 Discussion......Page 713 Discussion......Page 715 Solution......Page 716 29.18 Program: Transfer a File to a Remote Computer......Page 717 See Also......Page 719 29.20 Program: Create a Task-Specific Remoting Endpoint......Page 720 See Also......Page 724 30.0 Introduction......Page 725 Solution......Page 727 Discussion......Page 728 Solution......Page 729 See Also......Page 730 31.0 Introduction......Page 731 Solution......Page 732 Discussion......Page 733 Discussion......Page 735 See Also......Page 737 Solution......Page 738 Solution......Page 739 Problem......Page 740 Discussion......Page 741 Solution......Page 742 Discussion......Page 743 See Also......Page 744 Part V. References......Page 745 Commands and Expressions......Page 747 Variables......Page 748 Booleans......Page 749 Literal and Expanding Strings......Page 750 Escape Sequences......Page 751 Hexadecimal and Other Number Bases......Page 752 Array Definitions......Page 753 Array Access......Page 754 Hashtable Definitions......Page 755 XML......Page 756 Arithmetic Operators......Page 757 Binary Operators......Page 759 Other Operators......Page 761 Comparison Operators......Page 763 if, elseif, and else Statements......Page 765 switch Statements......Page 766 for Statement......Page 768 while Statement......Page 769 Flow Control Statements......Page 770 break......Page 771 continue......Page 772 Instance Methods......Page 773 The Get-Member cmdlet......Page 774 Type Shortcuts......Page 775 Creating Instances of Types......Page 776 The Add-Member cmdlet......Page 777 Writing Scripts, Reusing Functionality......Page 778 Writing functions......Page 779 Invoking......Page 780 Dot-sourcing......Page 781 Formal parameters......Page 782 Parameter attribute customizations......Page 783 Parameter validation attributes......Page 784 Cmdlet keywords in commands......Page 786 Exit statement......Page 787 Help Documentation......Page 788 Nonterminating Errors......Page 789 Terminating Errors......Page 790 Formatting Output......Page 791 Capturing Output......Page 792 Adjust your window size......Page 793 Use hotkeys to operate the shell more efficiently......Page 794 Profiles......Page 795 Tab Completion......Page 796 Appendix B. Regular Expression Reference......Page 797 Appendix C. XPath Quick Reference......Page 805 Standard Numeric Format Strings......Page 809 Custom Numeric Format Strings......Page 810 Appendix E. .NET DateTime Formatting......Page 813 Custom DateTime Format Strings......Page 814 Appendix F. Selected .NET Classes and Their Uses......Page 819 Appendix G. WMI Reference......Page 827 Appendix H. Selected COM Objects and Their Uses......Page 835 Appendix I. Selected Events and Their Uses......Page 839 Appendix J. Standard PowerShell Verbs......Page 847 Index......Page 853 Do you know how to use Windows PowerShell to navigate the filesystem and manage files and folders? Or how to retrieve a web page? This introduction to the PowerShell language and scripting environment provides more than 430 task-oriented recipes to help you solve the most complex and pressing problems, and includes more than 100 tried-and-tested scripts that intermediate to advanced system administrators can copy and use immediately.You'll find hands-on tutorials on fundamentals, common tasks, and administrative jobs that you can apply whether you're on a client or server version of Windows. You also get quick references to technologies used in conjunction with PowerShell, including format specifiers and frequently referenced registry keys to selected .NET, COM, and WMI classes. With Windows PowerShell Cookbook, you’ll get more done in less time.Take a tour of PowerShell’s core features, including the command model, object-based pipeline, and ubiquitous scriptingLearn PowerShell fundamentals such as the interactive shell and fundamental pipeline and object conceptsPerform common tasks that involve working with files, Internet-connected scripts, user interaction, and moreSolve tasks in systems and enterprise management, such as working with Active Directory, the filesystem, registry, event logs, processes, and services Do you know how to use Windows PowerShell to navigate the filesystem and manage files and folders? Or how to retrieve a web page? This introduction to the PowerShell language and scripting environment provides more than 430 task-oriented recipes to help you solve the most complex and pressing problems, and includes more than 100 tried-and-tested scripts that intermediate to advanced system administrators can copy and use immediately. You'll find hands-on tutorials on fundamentals, common tasks, and administrative jobs that you can apply whether you're on a client or server version of Windows. You also get quick references to technologies used in conjunction with PowerShell, including format specifiers and frequently referenced registry keys to selected .NET, COM, and WMI classes. With Windows PowerShell Cookbook, you’ll get more done in less time.Take a tour of PowerShell’s core features, including the command model, object-based pipeline, and ubiquitous scripting Learn PowerShell fundamentals such as the interactive shell and fundamental pipeline and object concepts Perform common tasks that involve working with files, Internet-connected scripts, user interaction, and more Solve tasks in systems and enterprise management, such as working with Active Directory, the filesystem, registry, event logs, processes, and services Do you know how to use Windows PowerShell to navigate the filesystem and manage files and folders? Or how to retrieve a web page? This introduction to the PowerShell language and scripting environment provides more than 430 task-oriented recipes to help you solve the most complex and pressing problems, and includes more than 100 tried-and-tested scripts that intermediate to advanced system administrators can copy and use immediately. You'll find hands-on tutorials on fundamentals, common tasks, and administrative jobs that you can apply whether you're on a client or server version of Windows. You also get quick references to technologies used in conjunction with PowerShell, including format specifiers and frequently referenced registry keys to selected.NET, COM, and WMI classes. With Windows PowerShell Cookbook, you'll get more done in less time. Take a tour of PowerShell's core features, including the command model, object-based pipeline, and ubiquitous scripting Learn PowerShell fundamentals such as the interactive shell and fundamental pipeline and object concepts Perform common tasks that involve working with files, Internet-connected scripts, user interaction, and more Solve tasks in systems and enterprise management, such as working with Active Directory, the filesystem, registry, event logs, processes, and services
دانلود کتاب Windows PowerShell Cookbook, Second edition