Windows PowerShell cookbook : the complete guide to scripting Microsoft's command shell / by Lee Holmes
- Author:
- Holmes, Lee
- Published:
- Farnham : O'Reilly, 2013.
- Edition:
- 3rd ed.
- Physical Description:
- xxv, 1,007 pages ; 23 cm
- Contents:
- Machine generated contents note: pt. I Tour -- pt. II Fundamentals -- 1.The Windows PowerShell Interactive Shell -- 1.1.Run Programs, Scripts, and Existing Tools -- 1.2.Run a PowerShell Command -- 1.3.Resolve Errors Calling Native Executables -- 1.4.Supply Default Values for Parameters -- 1.5.Invoke a Long-Running or Background Command -- 1.6.Program: Monitor a Command for Changes -- 1.7.Notify Yourself of Job Completion -- 1.8.Customize Your Shell, Profile, and Prompt -- 1.9.Customize PowerShell's User Input Behavior -- 1.10.Customize PowerShell's Command Resolution Behavior -- 1.11.Find a Command to Accomplish a Task -- 1.12.Get Help on a Command -- 1.13.Update System Help Content -- 1.14.Program: Search Help for Text -- 1.15.Launch PowerShell at a Specific Location -- 1.16.Invoke a PowerShell Command or Script from Outside PowerShell -- 1.17.Understand and Customize PowerShell's Tab Completion -- 1.18.Program: Learn Aliases for Common Commands -- 1.19.Program: Learn Aliases for Common Parameters -- 1.20.Access and Manage Your Console History -- 1.21.Program: Create Scripts from Your Session History -- 1.22.Invoke a Command from Your Session History -- 1.23.Program: Search Formatted Output for a Pattern -- 1.24.Interactively View and Process Command Output -- 1.25.Program: Interactively View and Explore Objects -- 1.26.Store the Output of a Command into a File -- 1.27.Add Information to the End of a File -- 1.28.Record a Transcript of Your Shell Session -- 1.29.Extend Your Shell with Additional Commands -- 1.30.Use Commands from Customized Shells -- 1.31.Save State Between Sessions -- 2.Pipelines -- 2.1.Filter Items in a List or Command Output -- 2.2.Group and Pivot Data by Name -- 2.3.Program: Simplify Most Where-Object Filters -- 2.4.Program: Interactively Filter Lists of Objects -- 2.5.Work with Each Item in a List or Command Output -- 2.6.Automate Data-Intensive Tasks -- 2.7.Program: Simplify Most Foreach-Object Pipelines -- 2.8.Intercept Stages of the Pipeline -- 2.9.Automatically Capture Pipeline Output -- 2.10.Capture and Redirect Binary Process Output -- 3.Variables and Objects -- 3.1.Display the Properties of an Item as a List -- 3.2.Display the Properties of an Item as a Table -- 3.3.Store Information in Variables -- 3.4.Access Environment Variables -- 3.5.Program: Retain Changes to Environment Variables Set by a Batch File -- 3.6.Control Access and Scope of Variables and Other Items -- 3.7.Program: Create a Dynamic Variable -- 3.8.Work with .NET Objects -- 3.9.Create an Instance of a .NET Object -- 3.10.Create Instances of Generic Objects -- 3.11.Reduce Typing for Long Class Names -- 3.12.Use a COM Object -- 3.13.Learn About Types and Objects -- 3.14.Get Detailed Documentation About Types and Objects -- 3.15.Add Custom Methods and Properties to Objects -- 3.16.Create and Initialize Custom Objects -- 3.17.Add Custom Methods and Properties to Types -- 3.18.Define Custom Formatting for a Type -- 4.Looping and Flow Control -- 4.1.Make Decisions with Comparison and Logical Operators -- 4.2.Adjust Script Flow Using Conditional Statements -- 4.3.Manage Large Conditional Statements with Switches -- 4.4.Repeat Operations with Loops -- 4.5.Add a Pause or Delay -- 5.Strings and Unstructured Text -- 5.1.Create a String -- 5.2.Create a Multiline or Formatted String -- 5.3.Place Special Characters in a String -- 5.4.Insert Dynamic Information in a String -- 5.5.Prevent a String from Including Dynamic Information -- 5.6.Place Formatted Information in a String -- 5.7.Search a String for Text or a Pattern -- 5.8.Replace Text in a String -- 5.9.Split a String on Text or a Pattern -- 5.10.Combine Strings into a Larger String -- 5.11.Convert a String to Uppercase or Lowercase -- 5.12.Trim a String -- 5.13.Format a Date for Output -- 5.14.Program: Convert Text Streams to Objects -- 5.15.Generate Large Reports and Text Streams -- 5.16.Generate Source Code and Other Repetitive Text -- 6.Calculations and Math -- 6.1.Perform Simple Arithmetic -- 6.2.Perform Complex Arithmetic -- 6.3.Measure Statistical Properties of a List -- 6.4.Work with Numbers as Binary -- 6.5.Simplify Math with Administrative Constants -- 6.6.Convert Numbers Between Bases -- 7.Lists, Arrays, and Hashtables -- 7.1.Create an Array or List of Items -- 7.2.Create a Jagged or Multidimensional Array -- 7.3.Access Elements of an Array -- 7.4.Visit Each Element of an Array -- 7.5.Sort an Array or List of Items -- 7.6.Determine Whether an Array Contains an Item -- 7.7.Combine Two Arrays -- 7.8.Find Items in an Array That Match a Value -- 7.9.Compare Two Lists -- 7.10.Remove Elements from an Array -- 7.11.Find Items in an Array Greater or Less Than a Value -- 7.12.Use the ArrayList Class for Advanced Array Tasks -- 7.13.Create a Hashtable or Associative Array -- 7.14.Sort a Hashtable by Key or Value -- 8.Utility Tasks -- 8.1.Get the System Date and Time -- 8.2.Measure the Duration of a Command -- 8.3.Read and Write from the Windows Clipboard -- 8.4.Generate a Random Number or Object -- 8.5.Program: Search the Windows Start Menu -- 8.6.Program: Show Colorized Script Content -- pt. III Common Tasks -- 9.Simple Files -- 9.1.Get the Content of a File -- 9.2.Search a File for Text or a Pattern -- 9.3.Parse and Manage Text-Based Logfiles -- 9.4.Parse and Manage Binary Files -- 9.5.Create a Temporary File -- 9.6.Search and Replace Text in a File -- 9.7.Program: Get the Encoding of a File -- 9.8.Program: View the Hexadecimal Representation of Content -- 10.Structured Files -- 10.1.Access Information in an XML File -- 10.2.Perform an XPath Query Against XML -- 10.3.Convert Objects to XML -- 10.4.Modify Data in an XML File -- 10.5.Easily Import and Export Your Structured Data -- 10.6.Store the Output of a Command in a CSV or Delimited File -- 10.7.Import CSV and Delimited Data from a File -- 10.8.Manage JSON Data Streams -- 10.9.Use Excel to Manage Command Output -- 10.10.Parse and Interpret PowerShell Scripts -- 11.Code Reuse -- 11.1.Write a Script -- 11.2.Write a Function -- 11.3.Find a Verb Appropriate for a Command Name -- 11.4.Write a Script Block -- 11.5.Return Data from a Script, Function, or Script Block -- 11.6.Package Common Commands in a Module -- 11.7.Write Commands That Maintain State -- 11.8.Selectively Export Commands from a Module -- 11.9.Diagnose and Interact with Internal Module State -- 11.10.Handle Cleanup Tasks When a Module Is Removed -- 11.11.Access Arguments of a Script, Function, or Script Block -- 11.12.Add Validation to Parameters -- 11.13.Accept Script Block Parameters with Local Variables -- 11.14.Dynamically Compose Command Parameters -- 11.15.Provide -WhatIf, -Confirm, and Other Cmdlet Features -- 11.16.Add Help to Scripts or Functions -- 11.17.Add Custom Tags to a Function or Script Block -- 11.18.Access Pipeline Input -- 11.19.Write Pipeline-Oriented Scripts with Cmdlet Keywords -- 11.20.Write a Pipeline-Oriented Function -- 11.21.Organize Scripts for Improved Readability -- 11.22.Invoke Dynamically Named Commands -- 11.23.Program: Enhance or Extend an Existing Cmdlet -- 12.Internet-Enabled Scripts -- 12.1.Download a File from an FTP or Internet Site -- 12.2.Upload a File to an FTP Site -- 12.3.Download a Web Page from the Internet -- 12.4.Parse and Analyze a Web Page from the Internet -- 12.5.Script a Web Application Session -- 12.6.Program: Get-PageUrls -- 12.7.Interact with REST-Based Web APIs -- 12.8.Connect to a Web Service -- 12.9.Export Command Output as a Web Page -- 12.10.Send an Email -- 12.11.Program: Monitor Website Uptimes -- 12.12.Program: Interact with Internet Protocols -- 13.User Interaction -- 13.1.Read a Line of User Input -- 13.2.Read a Key of User Input -- 13.3.Program: Display a Menu to the User -- 13.4.Display Messages and Output to the User -- 13.5.Provide Progress Updates on Long-Running Tasks -- 13.6.Write Culture-Aware Scripts -- 13.7.Support Other Languages in Script Output -- 13.8.Program: Invoke a Script Block with Alternate Culture Settings -- 13.9.Access Features of the Host's User Interface -- 13.10.Program: Add a Graphical User Interface to Your Script -- 13.11.Interact with MTA Objects -- 14.Debugging -- 14.1.Prevent Common Scripting Errors -- 14.2.Trace Script Execution -- 14.3.Set a Script Breakpoint -- 14.4.Debug a Script When It Encounters an Error -- 14.5.Create a Conditional Breakpoint -- 14.6.Investigate System State While Debugging -- 14.7.Program: Watch an Expression for Changes -- 14.8.Program: Get Script Code Coverage -- 15.Tracing and Error Management -- 15.1.Determine the Status of the Last Command -- 15.2.View the Errors Generated by a Command -- 15.3.Manage the Error Output of Commands -- 15.4.Program: Resolve an Error -- 15.5.Configure Debug, Verbose, and Progress Output -- 15.6.Handle Warnings, Errors, and Terminating Errors -- 15.7.Output Warnings, Errors, and Terminating Errors -- 15.8.Program: Analyze a Script's Performance Profile -- 16.Environmental Awareness -- 16.1.View and Modify Environment Variables -- 16.2.Modify the User or System Path -- 16.3.Access Information About Your Command's Invocation -- 16.4.Program: Investigate the InvocationInfo Variable -- 16.5.Find Your Script's Name -- 16.6.Find Your Script's Location -- 16.7.Find the Location of Common System Paths -- 16.8.Get the Current Location -- 16.9.Safely Build File Paths Out of Their Components -- 16.10.Interact with PowerShell's Global Environment -- 16.11.Determine PowerShell Version Information -- 16.12.Test for Administrative Privileges -- 17.Extend the Reach of Windows PowerShell -- 17.1.Automate Programs Using COM Scripting Interfaces -- 17.2.Program: Query a SQL Data Source -- 17.3.Access Windows Performance Counters -- 17.4.Access Windows API Functions -- 17.5.Program: Invoke Simple Windows API Calls -- 17.6.Define or Extend a .NET Class -- 17.7.Add Inline C# to Your PowerShell Script -- 17.8.Access a NET SDK Library -- 17.9.Create Your Own PowerShell Cmdlet -- and Contents note continued: 17.10.Add PowerShell Scripting to Your Own Program -- 18.Security and Script Signing -- 18.1.Enable Scripting Through ah Execution Policy -- 18.2.Disable Warnings for UNC Paths -- 18.3.Sign a PowerShell Script, Module, or Formatting File -- 18.4.Program: Create a Self-Signed Certificate -- 18.5.Manage PowerShell Security in an Enterprise -- 18.6.Block Scripts by Publisher, Path, or Hash -- 18.7.Verify the Digital Signature of a PowerShell Script -- 18.8.Securely Handle Sensitive Information -- 18.9.Securely Request Usernames and Passwords -- 18.10.Program: Start a Process as Another User -- 18.11.Program: Run a Temporarily Elevated Command -- 18.12.Securely Store Credentials on Disk -- 18.13.Access User and Machine Certificates -- 18.14.Program: Search the Certificate Store -- 18.15.Add and Remove Certificates -- 18.16.Manage Security Descriptors in SDDL Form -- 19.Integrated Scripting Environment -- 19.1.Debug a Script -- 19.2.Customize Text and User Interface Colors -- 19.3.Connect to a Remote Computer -- 19.4.Extend ISE Functionality Through Its Object Model -- 19.5.Quickly Insert Script Snippets -- 19.6.Add an Item to the Tools Menu -- pt. IV Administrator Tasks -- 20.Files and Directories -- 20.1.Determine the Current Location -- 20.2.Get the Files in a Directory -- 20.3.Find All Files Modified Before a Certain Date -- 20.4.Clear the Content of a File -- 20.5.Manage and Change the Attributes of a File -- 20.6.Find Files That Match a Pattern -- 20.7.Manage Files That Include Special Characters -- 20.8.Program: Get Disk Usage Information -- 20.9.Monitor a File for Changes -- 20.10.Get the Version of a DLL or Executable -- 20.11.Program: Get the MD5 or SHA1 Hash of a File -- 20.12.Create a Directory -- 20.13.Remove a File or Directory -- 20.14.Rename a File or Directory -- 20.15.Move a File or Directory -- 20.16.Create and Map PowerShell Drives -- 20.17.Access Long File and Directory Names -- 20.18.Unblock a File -- 20.19.Interact with Alternate Data Streams -- 20.20.Program: Move or Remove a Locked File -- 20.21.Get the ACL of a File or Directory -- 20.22.Set the ACL of a File or Directory -- 20.23.Program: Add Extended File Properties to Files -- 20.24.Program: Create a Filesystem Hard Link -- 20.25.Program: Create a ZIP Archive -- 21.The Windows Registry -- 21.1.Navigate the Registry -- 21.2.View a Registry Key -- 21.3.Modify or Remove a Registry Key Value -- 21.4.Create a Registry Key Value -- 21.5.Remove a Registry Key -- 21.6.Safely Combine Related Registry Modifications -- 21.7.Add a Site to an Internet Explorer Security Zone -- 21.8.Modify Internet Explorer Settings -- 21.9.Program: Search the Windows Registry -- 21.10.Get the ACL of a Registry Key -- 21.11.Set the ACL of a Registry Key -- 21.12.Work with the Registry of a Remote Computer -- 21.13.Program: Get Registry Items from Remote Machines -- 21.14.Program: Get Properties of Remote Registry Keys -- 21.15.Program: Set Properties of Remote Registry Keys -- 21.16.Discover Registry Settings for Programs -- 22.Comparing Data -- 22.1.Compare the Output of Two Commands -- 22.2.Determine the Differences Between Two Files -- 22.3.Verify Integrity of File Sets -- 23.Event Logs -- 23.1.List All Event Logs -- 23.2.Get the Newest Entries from an Event Log -- 23.3.Find Event Log Entries with Specific Text -- 23.4.Retrieve and Filter Event Log Entries -- 23.5.Find Event Log Entries by Their Frequency -- 23.6.Back Up an Event Log -- 23.7.Create or Remove an Event Log -- 23.8.Write to an Event Log -- 23.9.Run a PowerShell Script for Windows Event Log Entries -- 23.10.Clear or Maintain an Event Log -- 23.11.Access Event Logs of a Remote Machine -- 24.Processes -- 24.1.List Currently Running Processes -- 24.2.Launch the Application Associated with a Document -- 24.3.Launch a Process -- 24.4.Stop a Process -- 24.5.Get the Owner of a Process -- 24.6.Get the Parent Process of a Process -- 24.7.Debug a Process -- 25.System Services -- 25.1.List All Running Services -- 25.2.Manage a Running Service -- 25.3.Configure a Service -- 26.Active Directory -- 26.1.Test Active Directory Scripts on a Local Installation -- 26.2.Create an Organizational Unit -- 26.3.Get the Properties of an Organizational Unit -- 26.4.Modify Properties of an Organizational Unit -- 26.5.Delete an Organizational Unit -- 26.6.Get the Children of an Active Directory Container -- 26.7.Create a User Account -- 26.8.Program: Import Users in Bulk to Active Directory -- 26.9.Search for a User Account -- 26.10.Get and List the Properties of a User Account -- 26.11.Modify Properties of a User Account -- 26.12.Change a User Password -- 26.13.Create a Security or Distribution Group -- 26.14.Search for a Security or Distribution Group -- 26.15.Get the Properties of a Group -- 26.16.Find the Owner of a Group -- 26.17.Modify Properties of a Security or Distribution Group -- 26.18.Add a User to a Security or Distribution Group -- 26.19.Remove a User from a Security or Distribution Group -- 26.20.List a User's Group Membership -- 26.21.List the Members of a Group -- 26.22.List the Users in an Organizational Unit -- 26.23.Search for a Computer Account -- 26.24.Get and List the Properties of a Computer Account -- 27.Enterprise Computer Management -- 27.1.Join a Computer to a Domain or Workgroup -- 27.2.Remove a Computer from a Domain -- 27.3.Rename a Computer -- 27.4.Program: List Logon or Logoff Scripts for a User -- 27.5.Program: List Startup or Shutdown Scripts for a Machine -- 27.6.Deploy PowerShell-Based Logon Scripts -- 27.7.Enable or Disable the Windows Firewall -- 27.8.Open or Close Ports in the Windows Firewall -- 27.9.Program: List All Installed Software -- 27.10.Uninstall an Application -- 27.11.Manage Computer Restore Points -- 27.12.Reboot or Shut Down a Computer -- 27.13.Determine Whether a Hotfix Is Installed -- 27.14.Manage Scheduled Tasks on a Computer -- 27.15.Retrieve Printer Information -- 27.16.Retrieve Printer Queue Statistics -- 27.17.Manage Printers and Print Queues -- 27.18.Program: Summarize System Information -- 27.19.Renew a DHCP Lease -- 27.20.Assign a Static IP Address -- 27.21.List All IP Addresses for a Computer -- 27.22.List Network Adapter Properties -- 28.Windows Management Instrumentation -- 28.1.Access Windows Management Instrumentation and CIM Data -- 28.2.Modify the Properties of a WMI or CIM Instance -- 28.3.Invoke a Method on a WMI Instance or Class -- 28.4.Program: Determine Properties Available to WMI and CIM Filters -- 28.5.Program: Search for WMI Classes -- 28.6.Use NET to Perform Advanced WMI Tasks -- 28.7.Improve the Performance of Large-Scale WMI Operations -- 28.8.Convert a VBScript WMI Script to PowerShell -- 29.Remoting -- 29.1.Find Commands That Support Their Own Remoting -- 29.2.Enable PowerShell Remoting on a Computer -- 29.3.Interactively Manage a Remote Computer -- 29.4.Invoke a Command on a Remote Computer -- 29.5.Disconnect and Reconnect PowerShell Sessions -- 29.6.Program: Remotely Enable PowerShell Remoting -- 29.7.Program: Invoke a PowerShell Expression on a Remote Machine -- 29.8.Test Connectivity Between Two Computers -- 29.9.Limit Networking Scripts to Hosts That Respond -- 29.10.Enable Remote Desktop on a Computer -- 29.11.Configure User Permissions for Remoting -- 29.12.Enable Remoting to Workgroup Computers -- 29.13.Implicitly Invoke Commands from a Remote Computer -- 29.14.Create Sessions with Full Network Access -- 29.15.Pass Variables to Remote Sessions -- 29.16.Configure Advanced Remoting Quotas and Options -- 29.17.Invoke a Command on Many Computers -- 29.18.Run a Local Script on a Remote Computer -- 29.19.Program: Transfer a File to a Remote Computer -- 29.20.Determine Whether a Script Is Running on a Remote Computer -- 29.21.Create a Task-Specific Remoting Endpoint -- 30.Workflows -- 30.1.Write a Workflow -- 30.2.Run a Workflow -- 30.3.Suspend and Resume a Workflow -- 30.4.Invoke Islands of Traditional PowerShell Script -- 30.5.Invoke Workflow Actions in Parallel -- 30.6.Customize an Activity's Connection Parameters -- 30.7.Write a Workflow That Requires Human Intervention -- 30.8.Add Raw XAML to a Workflow -- 30.9.Reference Custom Activities in a Workflow -- 30.10.Debug or Troubleshoot a Workflow -- 30.11.Use PowerShell Activities from a Traditional Windows Workflow Application -- 31.Transactions -- 31.1.Safely Experiment with Transactions -- 31.2.Change Error Recovery Behavior in Transactions -- 32.Event Handling -- 32.1.Respond to Automatically Generated Events -- 32.2.Create and Respond to Custom Events -- 32.3.Create a Temporary Event Subscription -- 32.4.Forward Events from a Remote Computer -- 32.5.Investigate Internal Event Action State -- 32.6.Use a Script Block as a NET Delegate or Event Handler -- pt. V References -- A.PowerShell Language and Environment -- B.Regular Expression Reference -- C.XPath Quick Reference -- D..NET String Formatting -- E..NET DateTime Formatting -- F.Selected .NET Classes and Their Uses -- G.WMI Reference -- H.Selected COM Objects and Their Uses -- I.Selected Events and Their Uses -- J.Standard PowerShell Verbs.
- Subject(s):
- ISBN:
- 9781449320683 (pbk.)
1449320686 (pbk.) - Note:
- Previous ed.: 2010.
- Source of Acquisition:
- Purchased with funds from the Paterno Libraries Endowment; 2012
- Endowment Note:
- Paterno Libraries Endowment
View MARC record | catkey: 9615262