forked from RamblingCookieMonster/PSDeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for using parameter sets in PSDeployScripts
- Loading branch information
1 parent
7e4206a
commit 3f1fb77
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Function Get-ParameterSetInUse { | ||
# get parameter set name to be used, based on parameters hash passed | ||
[cmdletbinding()] | ||
param( | ||
# Supply the script info object, output of Get-Command -Name <DeploymentScript>.ps1 | ||
[System.Management.Automation.ExternalScriptInfo]$ScriptInfo, | ||
|
||
# hashtable of all the parameters to be passed to the DeploymentScript | ||
[hashtable]$ParameterHash | ||
) | ||
|
||
$Metadata = [System.Management.Automation.CommandMetadata]::New($ScriptInfo) | ||
$CmdletBinding = [System.Management.Automation.ProxyCommand]::GetCmdletBindingAttribute($Metadata) | ||
$Parameters = [System.Management.Automation.ProxyCommand]::GetParamBlock($Metadata) | ||
|
||
$FunctionBody = @" | ||
$CmdletBinding | ||
param( | ||
$Parameters | ||
) | ||
return `$PSCmdlet.ParameterSetName | ||
"@ | ||
|
||
$DummyFunction = [scriptblock]::Create($FunctionBody) | ||
|
||
& $DummyFunction @ParameterHash | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters