Script Club Update

On Tuesday we had our first Script Club in Seattle. There was even mention of the Script Club on This Week on Channel 9. The night went really well. There were lots of good discussions between PowerShell experts and beginners alike.

Some people are already asking when the next meeting will be. Mark Tuesday, May 26th on your calendars. It will be at 818 Stewart in downtown Seattle at 7:00 just like last time.

Hope to see you there!


Inconsistency about parsing Mandatory Parameters

Yesterday, I came across what I thought was a bug in PowerShell. Consider the following function:

Function Demo {            
This seems quite basic. It simply returns the argument that you enter for size.

75 >  demo 5

Now if you don’t provide a value you will get a prompt,and in ISE it will prompt like this


and you get the following output

77 >  demo

Simple stuff so far. But now, check this out. PS has some built in shortcuts for KB,MB,GB, and TB

79 >  1mb

So now we can do Demo 20MB and get the following

82 >  Demo 20MB

However, if we just run Demo with no parameters and get prompted as before, we get an error if we enter 20MB

83 >  demo
Demo : Cannot process argument transformation on parameter 'size'. Cannot convert value "20MB" to type "System.Int64".

The PowerShell Team closed my bug on this and marked it “By Design.” The reasoning is around security with the following explanation:

“The prompting mechanism is inherently insecure and we do not want to introduce a code execution bug similar to the mailer bug in the old ATT UnixPC. If the user is running an application elevated which uses script and an error results in a prompt, the user's ability to exploit that prompt should be as restricted as possible.”

That is fine, but my issue is that this provides an inconsistent user experience. I would think that typing a parameter argument or entering one from an input box should provide the same result. Maybe both should error out.

PowerShell Script Club in Seattle

The first Seattle PowerShell Script Club will be held on Tuesday, April 21st from 7:00 to 9:00 PM. You can Sign up now!

What is a PowerShell Script Club?

Script Clubs are like a hands on lab with no set topic or teacher. You bring an idea for a script, and ask your fellow PowerShell users for help getting the script written.

James Brundage, from the PowerShell at team at Microsoft, will be joining us for the evening.

About Seattle PowerShell Script Club

1. You Always Talk About Script club
2. You Always Talk About Script Club
3. If Someone asks for Help, And You Can Help, You Help
4. Two People Help One Person at One Time
5. One Module Per Person Per Night
6. All Scripts, All PowerShell
7. Scripts will be as short as they can be
8. If This is your First time at Script Club, You Have to Script