PowerShell Team

Automating the world one-liner at a time…

Latest posts

Mar 3, 2007
Post comments count 0
Post likes count 0

Start-Demo: Help doing demos using PowerShell

PowerShell Team

A couple a weeks ago I got a call from BillG's Technical Assistant (TA) telling me that Bill and Ray (Ozzie) wanted to get a demo of the new stuff we were doing with PowerShell. The setting was Bill's conference room that would be organized with a number of Demo stations. You'd get called in and were allowed to bring one other person but then it would be Bill and Ray sitting next to you getting the demo – so you pretty much have their full attention. That's great except for the fact that I am a bad typist and make mistakes all the time. That is why PowerShell supports wildcards, parameter disambiguation and tab c...

Mar 1, 2007
Post comments count 0
Post likes count 0

Improved PowerShell grammar Documentation

PowerShell Team

Bruce Payette is a co-designer of the PowerShell language and the development lead for its implementation. From that, you might guess that his book: Windows PowerShell in Action would provide a great explanation of the language and how to use it – you'd be right. In the past, we've posted a PowerShell grammar document but a number of you have provided feedback that it wasn't as helpful as it could be. Bruce has worked with his publisher, Manning Press, to rectify that situation by posting Appendix C: The PowerShell grammar on the website (see the link above). This chapter provides the PowerShell grammar annot...

Mar 1, 2007
Post comments count 0
Post likes count 0

Year of the Pig Revisited – the magic of QL

PowerShell Team

Richard Siddaway has a blog entry showing how to calculate the Chinese Horoscope using PowerShell. His solution uses hashtables: ## create hash table $years = @{1="Rat"; 2="Ox"; 3="Tiger"; 4="Rabbit"; 5="Dragon"; 6="Snake";            7="Horse"; 8="Goat"; 9="Monkey"; 10="Rooster"; 11="Dog"; 0="Pig"} ## get the year of interest $y = Read-Host "Enter a year between 1900 and 2100 inclusive" $anml = ($y - 1899)%12 Write-Host $years[$anml] This is a perfectly fine solution and a good one to help get hashtables in focus. Hashtables are super useful in scripting so if you aren't real co...

Feb 25, 2007
Post comments count 0
Post likes count 0

Pause

PowerShell Team

In the Newsgroup Microsoft.Public.Windows.PowerShell, BJ Stigall asked what the equivalent of the batch file PAUSE function was in PowerShell. There were lots of good answers that came close but I think the one below comes the closest (and a little bit better). function Pause ($Message="Press any key to continue..."){Write-Host -NoNewLine $Message$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")Write-Host ""} Here is an example of it in use: PS> pausePress any key to continue...PS> pause "Press any key to win a million dollars..."Press any key to win a million dollars...PS> Of course you can see...

Feb 25, 2007
Post comments count 0
Post likes count 0

Supporting -Whatif, -Confirm, -Verbose – In SCRIPTS!

PowerShell Team

<This is a super-important issue so you should definitely start using this in your scripts that you share with others (that have side effects on the system). Please try it out and blog about it to others so that it becomes a community norm. Thanks-jps> One of the greatest things about PowerShell is that when you use a Cmdlet which is going to have a side effect on the system, you can always type –Whatif, -Confirm or –Verbose. Sadly, you lose this option when it comes to scripts. Over time we want to makes scripts be the semantic equivalent of Cmdlets – that is to say that a Cmdlet is a Cmdlet independent o...

Feb 25, 2007
Post comments count 0
Post likes count 0

NetBeans IDE support for PowerShell

PowerShell Team

Apparently one of the main themes of NetBeans 6.0 is going to be support for scripting languages (yet another indication of the industry wide ascendency of Scripting. It is a VERY good time to embrace scripting or "learn PowerShell and increase your integrated lifetime earnings" J). HERE is a blog entry of someone that added PowerShell support to NetBeans. Good stuff! It is awesome to see all the IDEs that now support PowerShell. I look forward to the day when I can tell you that if you want a great PowerShell IDE you can use Visual Studio. J Jeffrey Snover [MSFT]Windows PowerShell/MMC ArchitectVisit the Wi...

Feb 24, 2007
Post comments count 0
Post likes count 1

Displaying USB Devices using WMI

PowerShell Team

Over on MyItForum.com, I came upon a VBScript in a forum to find all the PNP entities associated with a USBController. I rewrote it in PowerShell and was pretty happy with the results so I thought I would share them. The first thing you need to understand is that the WMI class WIN32_USBControllerDevice describes the connection between USB controllers (The Antecedent) and their logical devices [CIM_LOGICALDEVICE] (the Dependent). Let me illustrate: PS> gwmi Win32_USBControllerDevice |fl Antecedent,DependentAntecedent : \\JPSVISTA1\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_ 8086&DEV_2...

Feb 24, 2007
Post comments count 0
Post likes count 0

Extended Types and Types.XSD

PowerShell Team

I'd like to draw your attention to a really important blog entry that Jim Truher recently made: PowerShell Extended Types (Includes a TYPES.XSD). In that entry, he talks about how powerful PowerShell's extended type system is. He is absolutely correct on this point, this is an incredibly important and powerful feature of the system that not enough people know about or are using. The basic idea is that you can have a set of XML files which add additional properties and methods to existing types. The great thing that Jim did was to take the type to create an XSD for the XML files (I know- I know – it is our bad ...

Feb 23, 2007
Post comments count 0
Post likes count 0

Time till we land …

PowerShell Team

<Today we have a guest blog entry from Ed Wilson – Author of the upcoming MSPRESS book, Microsoft Windows PowerShell Step By Step> <2/16 fixed a bug pointed out by Richard Siddaway [use TotalMinutes instead of Minutes for the out-gauge].  Thanks Richard! -jps> I was on my way to Ottawa this week, and working on a few scripts, when I realized that perhaps I might need to keep track of time. My poor old combination laptop/coffee warmer is struggling to keep up the pace, and as a result I need a good five minute warning to shut the silly thing down prior to landing. The flight attendants do not us...