PowerShell Team

Automating the world one-liner at a time…

Another Holiday Gift from the PowerShell Team: PowerShell 3.0 CTP2 – Getting Started with Windows PowerShell Workflow

After delivering the Thanksgiving Gift this year, it’s time for a Holiday Gift …. No not as big as the one we had about 3 years ago …!! Today, we published the “Getting Started with Windows PowerShell Workflow” document on the CTP2 download page, just look for “WMF3 CTP2 Windows PowerShell Workflow.pdf&...

V2 Quick Tips: Finding Extra Outputs From Your Script

One of the nifty features of functions in PowerShell is that they can return as many results from as many places as you’d like.  In fact, any method or cmdlet that would give you an output if you try it on the command line will also return values from a function.  While this can give you a lot of powerful capabilities (like easily ...

Do PowerShell Demos in the ISE

Jeffry Snover and many other have used Start-Demo in powershell.exehttp://blogs.msdn.com/powershell/archive/2007/03/03/start-demo-help-doing-demos-using-powershell.aspx Continuing the tradition, we now have ISEDemo.psm1 To use it, start ISE and runImport-Module ISEDemo.psm1 #(attached)Start-Demo c:\path\to\demofile.txt Demo files look ...

Image Manipulation in PowerShell

The other week, I showed a Get-ProgID function that I used to help someone at Microsoft Research find a good object to talk to images.  A few comments jumped to one of the possible solutions, which is to use the .NET Drawing assembly (which I have to load first).  I wanted to be reasonably sure that the way to get at the image ...

Get closure with GetNewClosure

Have you ever created scriptblocks on the fly, say in a foreach loop, and they totally mess up because they all have the same value? This is something sort of advanced, and typically used when you’re proxying an object. The most basic example would be, taken from (http://www.powershellcommunity.org/Forums/tabid/54/aff/1/aft/2506/afv/topic/...

Tied Variables in PowerShell

With Add-Type and $executioncontext you can add special varibles that have tied values. I made $random, and $now add-type @"using System;using System.Management.Automation;public class RandomVariable : PSVariable{Random r;public RandomVariable ()  : base("Random", 0, ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope)  {r = new...