Windows Scripting
  Home arrow Windows Scripting arrow Page 4 - An Introduction to Microsoft PowerShell
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

An Introduction to Microsoft PowerShell
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-03-12

    Table of Contents:
  • An Introduction to Microsoft PowerShell
  • PowerShell Features
  • A Look at Cmdlets
  • Harnessing the Power

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    An Introduction to Microsoft PowerShell - Harnessing the Power


    (Page 4 of 4 )

    You can customize output further by sorting from the output as well.  Let’s use the Get-Process cmdlet as an example.  It lists all of the currently running processes.  You can sort results using the Where-Object method in many different ways.  In this example, I’m going to use the command:

    Get-Process | Where-Object { $_.ProcessName –match "^e.*" }

    Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName                                                 

    -------  ------    -----      ----- -----   ------     -- -----------                                                 

        461      14    42848      53732   124    24.13   2792 explorer     

    The use of regular expressions is far beyond the scope of this article but essentially this searches for and returns only processes beginning with the letter E.

    We’re only beginning to tap into the true power that PowerShell has to offer.  Not only do you have a full range of cmdlets available to you, but you can also add third-party ones and even write your own.  It truly is the most flexible command line environment.

    Another very cool feature that I like in PowerShell is its ability to work directly with the Windows registry.  Try typing Set-Location HKLM:.  You’ll notice by the change in prompt that your are sitting at the root of the HKEY_LOCAL_MACHINE registry hive.  From here you can navigate and view the registry as if it were a standard directory structure.

    You can use the Get-ChildItem cmdlet to get a “directory” listing for each level of sub keys.  To see a listing of keys at the current location you’ll need to use the Get-ItemProperty cmdlet instead.

    As you can see, PowerShell has a lot of power built into it.  It’s the most advanced command line environment to date.  As you experiment and learn more you’ll begin finding even more robust ways of getting things done.

    In the future, I will be presenting a series of articles to help you learn how to use this new environment as well as how to write PowerShell scripts.  Download the latest copy of PowerShell and start exploring.  Until next time.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · You've heard all of the buzz around Microsoft's latest scripting technology. Now we...
       · Nice introduction, but the last example does not work:It was:Get Process |...
       · Thanks so much for catching that typo. I've fixed it. I'm glad you enjoyed the...
     

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT