-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcluster.ps1
41 lines (35 loc) · 996 Bytes
/
cluster.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env pwsh
#Requires -Version 7
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[String]$Action
)
dynamicparam {
$importedModule = Import-Module -Name ([IO.Path]::Combine($PSScriptRoot, 'powershell', 'cluedin.psm1')) -PassThru
$scriptParams = $MyInvocation.MyCommand.Parameters.Keys
$ciAction = Get-CluedInDynamicAction -Action $Action -Context 'cluster' -ExistingParams $scriptParams
if($ciAction) {
return $ciAction.DynamicParams
}
}
begin {
if($ciAction) {
foreach($boundParam in $PSBoundParameters.Keys) {
if(-not ($ciAction.ParamNames -contains $boundParam)){
$PSBoundParameters.Remove($boundParam) > $null
}
}
}
}
process {
if(-not $ciAction) {
Write-Error "Unrecognised action: $Action"
} else {
Write-Output $ciAction.Header
& $ciAction.Command @PSBoundParameters
}
}
end {
Remove-Module -ModuleInfo $importedModule -Verbose:$false
}