Windows PowerShell 4.0 for .NET Developers

Book Description

Starting with the basics and moving steadily forward to an advanced level, this book is perfect for .NET developers who want to learn PowerShell scripting the logical way. Packed with practical examples and real-world scenarios.

In Detail

The world of technology is growing faster than ever, and the business needs are getting more complex every day. With PowerShell in your toolbox, you have an object-based scripting language, task-based shell, along with a powerful automation engine. PowerShell is built on top of .NET framework which gives an edge over the other tools when it comes to integration and automation of Microsoft product and technologies.

Packed with a set of real world scenarios and detailed scripts that will help you get started with PowerShell, this practical guide will help you to understand the syntax and grammar, build your scripts and modules, and integrate them with different technologies and tools. PowerShell is built on top of .NET framework, which gives an edge over other tools when it comes to integration and automation of Microsoft products and technologies.

Starting with the essentials of PowerShell along with the new features in PowerShell 4.0, this guide explores building scripts and modules, and takes an in-depth look at integration topics.

This book covers the use of PowerShell with .NET, WMI, and COM. It also covers the use of PowerShell to manage Windows Server, Internet Information Services, SQL Server, and Team Foundation Server. You will also learn to work with XML and RESTful web services.

This practical guide provides an easy and fast way to become a PowerShell expert via a collection of selected real world scenarios, detailed solutions, and screenshots.

What You Will Learn

  • Explore the new features of Windows PowerShell 4.0
  • Understand PowerShell syntax and grammar such as pipeline, looping and working with objects
  • Discover how to extend PowerShell capabilities with .NET framework, XML, WMI, and COM+
  • Work with Windows Server, Users and Groups, IIS, and SQL Server
  • Automate ALM using Team Foundation Server and Windows PowerShell
  • Get to grips with Windows PowerShell and Internet technologies such as JSON, XML web services, and RESTful applications

Table of Contents

  1. Windows PowerShell 4.0 for .NET Developers
    1. Table of Contents
    2. Windows PowerShell 4.0 for .NET Developers
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
        3. Instant Updates on New Packt Books
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Getting Started with Windows PowerShell
      1. Introducing Windows PowerShell
      2. Windows PowerShell consoles
        1. The Windows PowerShell console
        2. The Integrated Scripting Environment (ISE)
      3. The key features of Windows PowerShell
      4. PowerShell fundamentals – back to basics
        1. Working with objects
        2. Understanding the piping and pipelines
        3. Understanding and using aliases
        4. Using variables and data types
        5. Comparison and logical operators
        6. Working with arrays and hash tables
        7. Script flow and execution control
          1. Conditional execution
          2. Iterations statements
        8. Using functions
        9. Understanding providers and drives
        10. Working with script files
        11. Comments in PowerShell
        12. Using help in Windows PowerShell
        13. PowerShell's common parameters
      5. Summary
    10. 2. Unleashing Your Development Skills with PowerShell
      1. Understanding CIM and WMI
        1. CIM and WMI in Windows PowerShell
        2. More reasons to adopt CIM
      2. Working with XML
        1. Loading XML files
          1. Using the Get-Content cmdlet
          2. Using the Select-Xml cmdlet
        2. Importing and exporting XML files
      3. Working with COM
        1. Creating an instance of a COM object
        2. Automating Internet Explorer with COM and PowerShell
        3. Automating Microsoft Excel with COM and PowerShell
      4. Working with .NET objects
        1. Creating .NET objects
        2. Extending .NET objects
        3. Extending .NET framework types
          1. Defining the object type using an inline C# class
          2. Defining an object type using an assembly name or file
      5. Understanding Windows PowerShell Modules
      6. Creating Windows PowerShell Modules
        1. The script modules
        2. The binary modules
          1. Creating your first binary module
        3. The manifest modules
        4. The dynamic modules
      7. Script debugging and error handling
        1. Working with breakpoints
        2. Debugging your script
        3. Error-handling techniques
          1. The $Error and $LastExistCode variables
      8. Building GUI with PowerShell
      9. Summary
    11. 3. PowerShell for Your Daily Administration Tasks
      1. Windows PowerShell remoting
        1. Four different ways of using remoting
          1. Interactive remoting
          2. Ad hoc remoting
          3. Persistent session
          4. Implicit remoting
      2. Windows PowerShell Workflow (PSW)
        1. Creating a workflow using PowerShell
        2. Executing a PowerShell Workflow
          1. Sequential execution
          2. Parallel execution
          3. InlineScript activity
        3. Controlling the PowerShell workflow execution
          1. Persistent workflows
      3. Windows PowerShell in action
        1. Working with Windows roles and features
          1. Installing Windows roles and features
          2. Uninstalling Windows roles and features
        2. Managing local users and groups
          1. Creating a new local user account
          2. Modifying an existing local user account
          3. Adding and removing a user account to and from a group
            1. Removing an existing local user account
          4. Listing all the existing users and groups
        3. Managing web servers – IIS
          1. Working with web application pools
          2. Creating a new website
          3. Creating a new virtual directory
          4. Creating a new web application
          5. Creating an FTP site
          6. Creating and modifying an existing website binding
          7. Backing up and restoring the web configuration
        4. SQL Server and Windows PowerShell
          1. Loading SQL Server PowerShell
            1. Importing SQL Server PowerShell module
            2. Launching the SQL Server PowerShell from SSMS
          2. Working with the SQL Server scripting
            1. Example 1 – executing the T-SQL statement
            2. Example 2 – backing up the SQL Server database
            3. Example 3 – restoring the SQL Server database
            4. Example 4 – generating the SQL script for a database, tables, and stored procedures
      4. Summary
    12. 4. PowerShell and Web Technologies
      1. Web cmdlets in PowerShell
        1. Working with web services
          1. Example 1 – using the GeoIPService web service
          2. Example 2 – using the Stock Quote web service
        2. Working with web requests
          1. Example 1 – downloading files from the Internet
        3. Using REST APIs
          1. Example 1 – finding YouTube videos using PowerShell
          2. Example 2 – reading web feeds
        4. Working with JSON
          1. Example 1 – converting objects into the JSON format
          2. Example 2 – converting objects from JSON to the PowerShell format
      2. Summary
    13. 5. PowerShell and Team Foundation Server
      1. TFS Power Tools
      2. Getting started with TFS PowerShell cmdlets
        1. Working with TFS PowerShell cmdlets
        2. Retrieving TFS information
        3. Working with TFS items' information
        4. Managing TFS workspace
        5. Managing changesets, shelvesets, and pending changes
      3. Summary
    14. Index

Product Information

  • Title: Windows PowerShell 4.0 for .NET Developers
  • Author(s): Sherif Talaat
  • Release date: January 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781849688765