Tickets on Sale for #pssat002

§ August 2, 2012 12:00 by beefarino |

logo_iidI am pleased to announce that tickets for PowerShell Saturday #002 in Charlotte, NC on September 15, 2012 are now on sale! 

For a paltry $10 you get a full day of learning and fun.  We have fifteen sessions across three tracks - Introductory PowerShell, Advanced PowerShell, and Applied PowerShell - there will be no shortage of useful, practical PowerShell available to you on this day.

Speakers include scripting heavyweights like Scripting Guy Ed Wilson, as well as many field-tested shell hackers looking to bring you some awesome.  Presentations cover everything from getting started to managing enterprise systems, virtualization farms, Windows Server 2012, Active Directory, and Sharepoint from the shell. 

In addition – and I’m a little excited about this one - you'll have a chance to compete for the first-ever Iron Scripter award and claim the title Iron Scripter - PowerShell Saturday #002, and walk away with a very special and unique prize...

For more information about the event, please see the event site at

To get tickets for the event, please register at

Here's hoping to see you there!

beefycode | query: powershell command parameter issue

query: powershell command parameter issue

§ December 13, 2010 02:52 by beefarino |

Hey PowerShell gurus – I’ve got a strange one for you. 

In the process of creating and running commands programatically, I’ve hit a very frustrating scenario.  I’m attempting to invoke new-item by creating an instance of a Command with parameters specified in the Parameters collection:

1 string command = "new-item"; 2 var inputs = new Dictionary<string, object>() 3 { 4 {"Value", value.ToString()}, 5 {"Path", "function:" + functionName} 6 }; 7 var cmd = new Command(command, true); 8 inputs.ToList().ForEach( 9 pair => cmd.Parameters.Add( 10 pair.Key, pair.Value 11 ) 12 ); 13 14 var pipe = _runspace.CreatePipeline(); 15 pipe.Commands.Add(cmd); 16 pipe.Invoke();

In this case I’m attempting to create a function.  When I invoke this pipeline, I expect the Path and Value command parameters I’ve specified to be used to resolve the required fields of the new-item cmdlet.

Instead, PowerShell prompts me for the Path parameter:

cmdlet New-Item at command pipeline position 1
Supply values for the following parameters:

If I specify a valid path value at this prompt, PowerShell raises an error that the Value parameter is null.  So it seems clear that I’m missing something in the way I’m using the Command.Parameters collection.

A few other insights:

  1. I’ve verified in the debugger that the pipeline contains the command, and that the command’s Parameters collection contains the Value and Path parameters.
  2. Specifying the parameters as part of the command string works; however I do not want to be limited to passing strings around.
  3. I’ve tried prepending the parameter names with a hyphen (-), doesn’t appear to make a difference.

Any idears out there?

UPDATE 12.14.2010

Many thanks to Oisin Grehan; he helped me solve the problem, albeit indirectly.  Another blog post is coming on that one.

The named parameters are used as expected when the isScript parameter of the Command constructor is false:

1 string command = "new-item"; 2 var inputs = new Dictionary<string, object>() 3 { 4 {"Value", value.ToString()}, 5 {"Path", "function:" + functionName} 6 }; 7 8 // set isScript to false to use parameters 9 var cmd = new Command(command, false); 10 11 inputs.ToList().ForEach( 12 pair => cmd.Parameters.Add( 13 pair.Key, pair.Value 14 ) 15 ); 16 17 var pipe = _runspace.CreatePipeline(); 18 pipe.Commands.Add(cmd); 19 pipe.Invoke();

View all posts by beefarino →

blog comments powered by Disqus