-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGet-AzDoProject.ps1
95 lines (82 loc) · 2.57 KB
/
Get-AzDoProject.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function Get-AzDoProject {
<#
.SYNOPSIS
Gets information about projects in Azure DevOps.
.DESCRIPTION
Gets information about all the projects in Azure DevOps.
.EXAMPLE
$Params = @{
CollectionUri = "https://dev.azure.com/contoso"
}
Get-AzDoProject @params
This example will List all the projects contained in the collection ('https://dev.azure.com/contoso').
.EXAMPLE
$Params = @{
CollectionUri = "https://dev.azure.com/contoso"
ProjectName = 'Project1'
}
Get-AzDoProject @params
This example will get the details of 'Project1' contained in the collection ('https://dev.azure.com/contoso').
.EXAMPLE
$params = @{
collectionuri = "https://dev.azure.com/contoso"
}
$somedifferentobject = [PSCustomObject]@{
ProjectName = 'Project1'
}
$somedifferentobject | Get-AzDoProject @params
This example will get the details of 'Project1' contained in the collection ('https://dev.azure.com/contoso').
.EXAMPLE
$params = @{
collectionuri = "https://dev.azure.com/contoso"
}
@(
'Project1',
'Project2'
) | Get-AzDoProject @params
This example will get the details of 'Project1' contained in the collection ('https://dev.azure.com/contoso').
.OUTPUTS
PSObject with repo(s).
.NOTES
#>
[CmdletBinding(SupportsShouldProcess)]
param (
# Collection Uri of the organization
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string]
$CollectionUri,
# Project where the Repos are contained
[Parameter(ValueFromPipelineByPropertyName, ValueFromPipeline)]
[string[]]
$ProjectName
)
begin {
Write-Verbose "Starting function: Get-AzDoProject"
}
process {
$params = @{
uri = "$CollectionUri/_apis/projects"
version = "7.1-preview.4"
method = 'GET'
}
if ($PSCmdlet.ShouldProcess($CollectionUri, "Get Project(s)")) {
$result = (Invoke-AzDoRestMethod @params).value | Where-Object { -not $ProjectName -or $_.Name -in $ProjectName }
} else {
Write-Verbose "Calling Invoke-AzDoRestMethod with $($params| ConvertTo-Json -Depth 10)"
}
}
end {
if ($result) {
$result | ForEach-Object {
[PSCustomObject]@{
CollectionURI = $CollectionUri
ProjectName = $_.name
ProjectID = $_.id
ProjectURL = $_.url
ProjectVisibility = $_.visibility
State = $_.state
}
}
}
}
}