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”. This will help… Read more

Update-TypeData, ISE CTP3 vs ISE RC, and Teched2009 Demos

There were quite a few name changes in the ISE Object Model from CTP3 to RC Using Update-TypeData, we can achieve some parity between the two We can add aliases to the CTP3 version to make it look like the RC Version  For example,         <Name>System.Management.Automation.Host.PSGHost</Name>        <Members>            <AliasProperty>                <Name>CurrentPowerShellTab</Name>                <ReferencedMemberName>CurrentOpenedRunspace</ReferencedMemberName>            </AliasProperty> Will make $psISE.CurrentPowerShellTab point… Read more

V2 Quick Tip: Starting a new elevated process from a PowerShell script

One of the systems administration hurdles of the post-Vista world is figuring out how to make a script run as an administrator. In PowerShell V2, using the Start-Process cmdlet, this is a one liner that will get the job done: Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList ‘-command "Get-Process"’ Hope this Helps, James Brundage [MSFT]… Read more

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 Type enter to execute the command once its finished typing You can escape to clear and type some other command To get the next command again, execute a… Read more

Differences between the ISE and PowerShell console

Here is a collection of differences between the PowerShell_ise.exe and PowerShell.exe, as well as workaroundsand suggestion if you need them (assuming we have them :)) Limited support for interactive console apps, try cmd.exe, then try cmd.exe /k cmd.exe /c dir still works though, and more information is available herehttp://blogs.msdn.com/powershell/archive/2009/02/04/console-application-non-support-in-the-ise.aspx Console Application output is not colorful… Read more

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… Read more

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/Default.aspx) function add([int]$x) { return { param([int]$y) return… Read more

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 Random();}     public override object Value        {            get            {            return  r.Next();            }        }}“@$executioncontext.SessionState.PSVariable.Set((new-object RandomVariable))add-type @”using System;using System.Management.Automation;public class… Read more