DESKTOP

Windows Server 2008 R2 : PowerShell V2 feature focus - Introduction to Powershell

2/27/2014 1:58:01 AM

To start at the very beginning, we answer the most basic question, “What is PowerShell?” PowerShell is a command-based shell and scripting language built on the .NET framework with incredible power and versatility designed especially for system administration. The latest version as of this writing is version 2.0 and it was officially released on October 28, 2009. We say shell and scripting language because both components can be used separately. At its fundamental level, it is a command-based shell in a console-like interface that will allow you to simply issue it commands and call its powerful scripting language to accomplish what tasks you need it to do. In this interactive use, you directly issue commands to the console and it performs the desired tasks. The other powerful part of PowerShell that takes full advantage of the underlying scripting language is the ability to run longer or complex instructions from a script. This allows you to automate some of the tasks you might need to perform. The final piece which is brand new to version 2.0 is the ability to run commands on one or more computers from a single computer running PowerShell. These abilities together should allow you to tackle almost any job without problem.

Another aspect of PowerShell you need to become familiar with is its command syntax. The commands PowerShell uses are called cmdlets. It is through these simple instructions that you will be performing all the common system administration tasks. cmdlets all share a similar syntax composed of a verb and a noun in a verb-noun format. As an example, we will use one of the most helpful commands, get-help. The get-help cmdlet is an easy example. Typing Get-help followed by the subject or command you want to get help about will get you more information about it. It will either give you the help you need or give you a list of subjects so that you can narrow it down to which one you need (Table 1).

Table 1. Getting Help Is Easy
cmdletDescription
Get-Help aboutWill list all the subjects that start with about
Get-Help about_scriptsWill get the specific help file about_scripts
Get-Help *about*Will give you a list of all the subjects that have “about” anywhere in them


As you can see, the main goal of Windows PowerShell is to give the administrator more control over the system and make it easier to perform the required tasks. It increases the administrator’s bag of tools by adding automation and remoting and their associated advantages. Imagine only having to write a command once and then being able to run it multiple times on different machines. This eliminates the need to run the same thing over and over by simply having PowerShell let you run it multiple times. It also eliminates some of the human error aspects since you only need to write it once and therefore only check it once.

What is new in PowerShell V2

Version 2.0 of Windows PowerShell was officially released on October 28, 2009 after much anticipation by the PowerShell community. It introduces a large amount of new features that were not available before. It stays true to its purpose of making system administration easier by adding remoting, debugging tools and other things to the administrator’s new shiny toolkit.

Of all the new features in Windows PowerShell version 2.0, the one feature that seems to elicit cheers and get the most attention is the new remote management or remoting feature. PowerShell supports interactive remoting where you connect directly and issue commands, fan-in (1 pc to many) and fan out (many pcs to 1). It allows the administrator to run scripts on one or many remote computers with a single command. Gone are the days of tediously going to different computers and running the same script on each of them one at a time. Gone are the days of taking your preferred script and copying it from machine to machine. Now, all you have to do is establish a session to the other computer or computers you want to run the script on and then issue the commands. From running a single cmdlet to a whole script, it is that simple. PowerShell 2.0 does have to be installed on the computers you are running the scripts on, the originating one and the target ones.

Another new feature sorely lacking from the earlier versions of PowerShell is the ability to run background jobs. This new ability of PowerShell version 2.0 to run background jobs allows you to asynchronously run other jobs or processes in the background while you continue to work on your session. You issue the command for the background job and immediately get the prompt back so that you can continue to work while the background job executes. These background jobs can be run on your local machine or on a remote computer.

Windows PowerShell 2.0 has also included new script debugging capabilities. Included now is the built-in capability to debug your scripts. It allows you to set breakpoints, step through code, monitor variable values, and more. It also allows you to decide what actions to take when the break point is hit. These capabilities give you the tools necessary to debug all your scripts with relative ease.

Another new feature is that of eventing. Eventing is the new capability of PowerShell to handle and react to events. It now includes an infrastructure that not only can listen for system and application events and act based on them. In addition, you can now create your own events which allow you to set up a chain of actions based on what your scripts do.

The new version also comes with a large number of new cmdlets. PowerShell version 2.0 introduces a little over 100 new cmdlets with numerous capabilities. All these cmdlets range from all the new functionalities mentioned earlier to powerful logging tools and mail-sending cmdlets.

PowerShell 2.0 also supports script internalization. This allows PowerShell to display messages in multiple languages. In addition to the regular get-help command and man command at the command line, PowerShell includes online help via a parameter to the get-help command. Using get-help, the command to get help on and then the online parameter opens a browser for you with the command help in Microsoft TechNet.

Another new feature is the support of Modules. A module is a package that includes Windows PowerShell commands like cmdlets, providers, aliases, and variables. PowerShell now lets you create these modules and organize your commands so that you can share them with others. PowerShell version 2.0 has also included a lot of advanced functions. These functions behave just like cmdlets but they are fully written in the Windows PowerShell scripting language as opposed to C#.

Another new feature that PowerShell 2.0 has brought is the new Integrated Scripting Environment or ISE. The PowerShell ISE lets you run commands and scripts in an integrated development environment (IDE). It allows you to edit and debug your scripts with many options to figure out what is wrong and where it is going wrong like most graphical interfaces. It makes writing cmdlets easier with multiline editing and line and column numbers. It includes color coding like most graphical interfaces which makes it very easy for the user to write and execute their own commands by immediately showing them if they have made any syntax errors. It has several panes or windows to make it easier to see what is going on. One pane to write your command(s), one to show your scripts, and one to show you the output or results of your commands or scripts. In essence, it makes it really easy to get started with PowerShell by giving the user the tools to create what they want quickly and easily.

Other  
  •  Installing Windows 8 on startup VHD files (part 3) - Starting the system from the VHD, Removing VHD installations
  •  Installing Windows 8 on startup VHD files (part 2) - Creating the VHD during the installation by using DiskPart
  •  Installing Windows 8 on startup VHD files (part 1) - Creating a VHD from an existing installation
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 4) - Migrating user data
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 3) - Using an external hard disk or USB flash drive, Using the User State Migration Tool
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 2) - Using removable media, Using a network connection
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 1) - Running the Setup Wizard , Configuring your account
  •  Installing Windows 8 on a new or formatted system (part 3) - Installing Windows 8 with Windows To Go
  •  Installing Windows 8 on a new or formatted system (part 2) - Configuring your account
  •  Installing Windows 8 on a new or formatted system (part 1) - Starting the installation
  •  
    Top 10
    Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
    Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
    3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
    3 Tips for Maintaining Your Cell Phone Battery (part 1) - Charge Smart
    OPEL MERIVA : Making a grand entrance
    FORD MONDEO 2.0 ECOBOOST : Modern Mondeo
    BMW 650i COUPE : Sexy retooling of BMW's 6-series
    BMW 120d; M135i - Finely tuned
    PHP Tutorials : Storing Images in MySQL with PHP (part 2) - Creating the HTML, Inserting the Image into MySQL
    PHP Tutorials : Storing Images in MySQL with PHP (part 1) - Why store binary files in MySQL using PHP?
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    VIDEO TUTORIAL
    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS