-
Notifications
You must be signed in to change notification settings - Fork 14
/
Get-Deployment.ps1
57 lines (52 loc) · 3.16 KB
/
Get-Deployment.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function Get-Deployment
{
<#
.Synopsis
Gets Pipeworks deployments
.Description
Gets PowerShell Pipeworks deployment
.Example
Get-Deployment
.Link
Import-Deployment
.Link
Push-Deployment
.Link
Publish-Deployment
#>
[CmdletBinding(DefaultParameterSetName='AllDeployments')]
[OutputType('Pipeworks.Deployment')]
param(
# The name of the module
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName='SpecificDeployments')]
[string[]]
$Name
)
begin {
$existingDeployments = Get-SecureSetting -Name "PipeworksDeployments" -ValueOnly
if (-not $existingDeployments) {
$existingDeployments = @{}
}
$expandDeployment = {
$deployment = New-Object PSObject -Property $_.Value
$deployment.pstypenames.clear()
$deployment.pstypenames.add('Pipeworks.Deployment')
$deployment
}
}
process {
if ($PSCmdlet.ParameterSetName -eq 'AllDeployments') {
$existingDeployments.GetEnumerator() |
Sort-Object Key |
ForEach-Object $expandDeployment
} else {
$existingDeployments.GetEnumerator() |
Where-Object {
foreach ($n in $name) {
$_.Key -like $n
}
} |
ForEach-Object $expandDeployment
}
}
}