-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGet-AzDoProjectProperties.ps1
More file actions
73 lines (61 loc) · 2.37 KB
/
Get-AzDoProjectProperties.ps1
File metadata and controls
73 lines (61 loc) · 2.37 KB
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
function Get-AzDoProjectProperties {
<#
.SYNOPSIS
Retrieves properties of specified Azure DevOps projects.
.DESCRIPTION
The Get-AzDoProjectProperties function retrieves properties of specified Azure DevOps projects within a given collection URI. It supports pipeline input for project names and collection URI.
.EXAMPLE
$Params = @{
CollectionUri = "https://dev.azure.com/organization"
ProjectName = "Project1"
}
Get-AzDoProjectProperties @Params
This example retrieves properties of the project named "Project1" in the specified Azure DevOps organization.
.EXAMPLE
$Params = @{
CollectionUri = "https://dev.azure.com/organization"
}
"Project1", "Project2" | Get-AzDoProjectProperties @Params
This example retrieves properties of multiple projects ("Project1" and "Project2") in the specified Azure DevOps organization.
.NOTES
This function requires the Validate-CollectionUri and Invoke-AzDoRestMethod helper functions to be defined in the scope.
.LINK
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/get-project-properties?view=azure-devops-rest-7.1&tabs=HTTP
#>
[CmdletBinding(SupportsShouldProcess)]
param (
# Collection Uri of the organization
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[ValidateScript({ Validate-CollectionUri -CollectionUri $_ })]
[string]
$CollectionUri,
# Project where the Repos are contained
[Parameter(ValueFromPipelineByPropertyName, ValueFromPipeline)]
[string]
$ProjectName
)
begin {
Write-Verbose "Starting function: Get-AzDoProjectProperties"
}
process {
# somehow it will not work on project name, but will work like this:
$ProjectId = (Get-AzDoProject -CollectionUri $CollectionUri -ProjectName $ProjectName).ProjectID
$params = @{
uri = "$CollectionUri/_apis/projects/$ProjectId/Properties"
version = "7.2-preview.1"
method = 'GET'
}
if ($PSCmdlet.ShouldProcess($CollectionUri, "Get project $ProjectName properties")) {
$result = (Invoke-AzDoRestMethod @params).value
} else {
Write-Verbose "Calling Invoke-AzDoRestMethod with $($params| ConvertTo-Json -Depth 10)"
}
if ($result) {
[PSCustomObject]@{
CollectionURI = $CollectionUri
ProjectName = $ProjectName
Properties = $result
}
}
}
}