Add module-level default parameter assignment support to PSDefaultParameterValues - by Kirk Munro

Status : 


Sign in
to vote
ID 844699 Comments
Status Active Workarounds
Type Suggestion Repros 1
Opened 4/1/2014 7:57:59 AM
Access Restriction Public


As PowerShell evolves, more patterns develop.  With those patterns, you may have multiple modules that use the same pattern against different targets. For example, the SMA module has a WebServicesEndpoint common parameter that can be used to remotely manage SMA.  Rather than using a variable or entering this all the time, it is easier to use PSDefaultParameterValues.  Unfortunately, that either means setting the default value for WebServicesEndpoint for all cmdlets (global assignments should be discouraged) or setting it atomically on each cmdlet (which means updated versions of the module with new commands mean you need to revisit the assignments and add some for the new commands).  I'm working on a module that will use WebServicesEndpoint as a parameter as well.  With these patterns in mind, it becomes very important to allow PSDefaultParameterValues to be used to assign a default value to a single parameter across all commands that are part of a specific module.  This way you can avoid the complexity and error that comes with atomic assignments while also avoiding the issues that come with global assignments.

I propose a syntax that leverages the fully-qualified command name format, as follows:

$PSDefaultParameterValues['Microsoft.SystemCenter.ServiceManagementAutomation\*:WebServicesEndpoint'] = ''

This would also fix the issue with fully-qualified command names not being supported by this feature.

Sign in to post a comment.