Welcome to MSDN Blogs Sign in | Join | Help

January 2007 - Posts

PowerShell Benefits Over COM Scripting

On an internal email thread, someone asked Vivek Sharma why they should implement PowerShell. They knew that PowerShell provided scripting but they had a COM interface which already gave them scripting so the question was – what, if any, were the additional

PowerShell Cheat Sheet – Now in XPS

I originally published Ben Pearce's PowerShell Cheat sheet in Word 2007 format . Given that I posted it a week before the Office 2007 launch, it turned out that not many people could read that so I posted it in PDF format as well. It now turns out that
Posted by PowerShellTeam | 9 Comments

Attachment(s): Cheat Sheet V1.00.xps

Virtual Machine Manager’s PowerShell Support

One of the cornerstone features of System Center Virtual Machine Manager (SCVMM) is PowerShell. They have built their entire GUI layered on top of PowerShell in the same way that Exchange 2007 did. A little while ago, I talked to Rakesh Malhotra (the

Windows PowerShell 1.0 for Windows Vista

As Jeffery promised to you folks, today we have offically released Windows PowerShell 1.0 for Microsoft Windows Vista . Thanks to everyone for patiently waiting for this release. To download Windows PowerShell 1.0 for Windows Vista, please visit the following
Posted by PowerShellTeam | 57 Comments
Filed under:

Working With WMI Events

PowerShell V1 does not provide native support for WMI events. That doesn't mean that you can't use WMI events with PowerShell, it just means that you need to leverage the .NET classes to do so. This falls into the category of "to ship is to choose". Here
Posted by PowerShellTeam | 6 Comments

Attachment(s): get-wmievent.ps1

Executive Demo

I was in an executive review today where a team was demonstrating their technology (don't ask for details, I won't provide any :-) ). At some point they brought up this beautiful graphic showing the geographic distribution of resources and then the graph

Controlling PowerShell Function (Re)Definition

A question came up in the PowerShell news group recently where someone was asking how they could prevent functions from being redefined. There are a couple of approaches you can use. First you can make functions read-only or constant. This is pretty straight-forward

NetCmdlets Beta 2 is now Available.

nsoftware has released Beta 2 of NetCmdlet, a PowerShell snapin which provides Cmdlets for a wide range of protocols. The following is from their Release Notes: New In Beta 2 The current release is packed with new features, new functionality, and new

PowerShell Cheat Sheet Redux - the PDF version

Attached is a PDF version of Ben Pearce's PowerShell Cheat Sheet. In the past I've encouraged everyone to speak up and complain if we were messing up or not giving you what you needed. I'm pleased to see that you have taken this to heart (seriously).
Posted by PowerShellTeam | 8 Comments

Attachment(s): Cheat Sheet V1.00.pdf

PowerShell Cheat Sheet

Ben Pearce was gracious enough to put together a good looking PowerShell Cheat Sheet which I've included as an attachment to this blog post. By definition, a cheat sheet is incomplete so this contains the things that Ben has found to be the most import.

Array Literals In PowerShell

The first thing to understand is that there are no array literals in PowerShell J Arrays are built using operators or casts. The way to build an array in PowerShell is to use the comma operator as shown in the following examples: $a = , 1 # array of one

How to create enum in PowerShell?

[Updated to comply with the naming guidelines (create=>new)] Dynamic assembly emitting techniques can be used to create new classes or data types in PowerShell. Trick is that right permission needs to be set so that data types created in dynamic assembly

Channel 9 Chat with Scott Hanselman

A while ago I had the great pleasure to interview Scott Hanselman for Channel 9.about a wide range of topics. It was a blast. Think of it as the geek equivalent of My Dinner with Andre . Ok well neither of us are as interesting as that but Scott comes

IPCONFIG/All

While using CMD.exe, I got into a number of bad habits. One of those is the habit of eliminating whitespace for various commands. The problem is that that causes problems with PowerShell. More precisely stated – it doesn't work. Here is what you get:

PowerShell Analyzer: The Video

If you haven't already installed PowerShell analyzer, you can now check out want it does by watching the video. Karl Prosser recently released a 7 minute video showing you a run-through (as opposed to a walk-through) of its features. Now that fact that

Custom Alias Listing

When you run Get-Alias, it shows you all the aliases currently available. You might want to know which aliases were Custom aliases. That is to say, which aliases did not come built in with PowerShell. So what does it take to answer this question? We already

Managing Processes in PowerShell

Several people have asked recently about how to manage processes in PowerShell. This blog post should answer a number of those questions. As one might expect from the "shell" part of PowerShell, you don't have to do special anything to start a process

Difficulties Reading Our Blog

Kjartan posted the comment: I really like reading your blog and have done so for a long time now, but since I mostly read blogs with the RSS-reader in IE7 the styling of the code samples makes the posts harder to read, for some reason IE7 (at least the

Set-Alias-Strict

I picked up Jerry Lee Ford's book Microsoft Windows PowerShell Programming for the absolute beginner . In the section on aliases, he warns users that Set-Alias does not verify the validity of the alias assignment. That is a good point. Here is a function

Accessing data past the end of an array

In the newsgroup Microsoft.Public.Windows.PowerShell Marco Shaw asked about accessing data past the end of a defined array. He wondered why he didn't get an error. As a general rule in PowerShell, when you ask for something that doesn't exist, you get

Sorting out -GroupBy

Did you realize that Format-Table had a parameter -GroupBy? This tells Format-Table to generate a series of tables instead of a single table. The best way to get this in focus is to show an example. For the purposes of this blog entry, I'm going to use

Behind PowerShell Installer (for Windows XP / Windows Server 2003):

The information here relates to Windows PowerShell 1.0 installer on downlevel platforms (XP SP2, W2K3 SP1 and above). The job of installers is to create an environment on a user’s machine, so that the underlying software works seamlessly on the machine.

2 + 2 equals "Monday Evening"

I wanted to follow up on Jeffrey's post and one of the comments. It has to do with this example: PS> [int]1/2 0.5 The reason that we get a double rather than an int is because of precedence. The conversion has a higher precedence than the division

Two plus two equals "Monday" ?

In PowerShell, two plus two does not always equal four. Why? Because there are twos and there are twos. Let me explain. PowerShell does a ton of work on your behalf so you can think about what you want to do and not how to do it. Think about the difference

Windows PowerShell for Testers

The PowerShell team is very much into unit testing so, when I ran into this blog by Adam Geras today, I found it very interesting. All its entries are on using PowerShell for testing. I especially liked this entry on using PowerShell and Excel for data

"PowerShell ... is there anything it CAN'T do?"

This weekend my wife was searching for some stuff and came across the following photo on Flickr : http://www.flickr.com/photos/windbag/167080724/ Apparently someone had taken a photo of the one of the slides during my TechEd talk. I just loved the comment.

Yet Another Freakishly PowerFul PowerShell One-liner

MOW has done it again. Check out http://thepowershellguy.com/blogs/posh/archive/2007/01/06/it-is-to-me.aspx for another one of MOW's freakishly powerful PowerShell one-liners. It is so powerful and pithy that makes my head spin. Enjoy! Jeffrey Snover

Cliff Notes of ConvertTo-Html & Other Language Blogs

I just saw a PowerShell blog entry on spaces ( http://hung-yuwu.spaces.live.com/Blog/cns!744FB258BF8C8020!1291.entry ) but it was in a language I don't read (I think it was Japanese)*. I thought I would check it out for yucks and was delighted to realizes

Hyphens in Command Names

In my previous blog entry , I talked about how Michael Fisher had blogged his intial impressions about PowerShell . One of the things that Michael did not like was the hyphenated command names. A discussion about the Pros/Cons of hyphens isn't actionable

Blog Your Initial PowerShell Experiences

Michael Fisher has just started using PowerShell and is blogging his impressions. You can see them at http://fastdad.wordpress.com/2007/01/05/windows-powershell-10/ . 10,000 thanks Michael! I can't tell you how valuable we find it when people do this!

Cliff Notes for PowerShell Functions

A PowerShell User (BS) has started a new blog with a very nice,pithy set of examples showing the range of capabilities of PowerShell Functions. Think of this as the Cliff Notes for PowerShell Functions. Check it out at: http://mybsinfo.blogspot.com/2007/01/beginning-and-end-process-to.html

More PowerShell Training Available

Don Jones and Jeffery Hicks (co-authors of the Windows PowerShell: TFM book) will be offering PowerShell Training in the following cities: Atlanta, GA Chicago, IL Dallas, TX Las Vegas, NV Omaha, NE Philadelphia, PA Toronto, ON Check out details and dates

On Scripting Languages

There is an interesting blog entry On Scripting Languages over an the AdminSpotting site . One statement was so absolutely spot-on that I plan on stealing it and using it often, "What the Programmers call 'Dynamic Languages', the Admins call 'Scripting

The Admin Development Model and Send-Snippet

One of the things that motivated us to develop PowerShell was the belief that we (Microsoft) had been doing a poor job supporting the Admin Development Model. All the effort seemed to have gone into treating Admins as GUI-only users or as though they
 
Page view tracker