Launcher redirect script

I have a script and I each change I version it in the filename (as we may have one or more versions in-play at any one time). e.g. “myscript v1.ps1” “myscript v2.ps1” etc However I want another script “myscript” that I can tell everyone to call if they just want to call the latest tested and complete version.

These scripts have a load of parameters defined (which may change over time) and ideally I would just like this “myscript” to pass through all and any parameters straight through so that I can set it up and forget about it.

I’ve tried splatting with @psBoundParameters but I think I need to define the params to make that work in a script which is going to add additional maintenance overhead.

Is what I’m after possible at all in PS and if not what would be the best compromise?

Thanks for any insights!

If maintaining this script requires version control, you should really consider using a source control or subversion (SVN) solution to track the script(s), who changed them, auto-versioning, etc.rather than attempting to manage it with file names. There are many free solutions and if you buy Powershell editors from products like Sapien (Powershell Studio or PrimalScript), they may have those features included.

For the variables, you always have the ability to keep the variables segregated in an outside file that maintains the variables outside of the script. If you need to maintain the data type, you should look at exporting it as XML (Export-CliXML) or you could use CSV if the values are all strings. To use it as a splat, just import the file and convert it to a hash table and reference it like you normally would. This would keep variable maintenance outside of script.

Thanks Rob. Of course this is the best solution. One which I couldn’t do very easily originally but now I can thanks to Nuget and a bit of creativity.

I guess the answer to my underlying question above is “no there isn’t a way to dynamically pass through arguments”… which is what I thought but posted just in case I’d missed something. An alias is the closest thing but wouldn’t work in the scenario I was working in.


Brett, it seems like you could do what you want by using DynamicParam{}. You would have to get the parameters from the latest version of your script and then use the DynamicParam block to built and display those parameters.

Here is a good article about using DynamicParam