|
11 | 11 | .Link |
12 | 12 | https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/lists/delete |
13 | 13 | #> |
14 | | - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] |
| 14 | + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] |
15 | 15 | [OutputType([Nullable], [Hashtable])] |
16 | 16 | param( |
17 | | - # The Organization. |
18 | | - [Parameter(Mandatory,ValueFromPipelineByPropertyName)] |
19 | | - [Alias('Org')] |
20 | | - [string] |
21 | | - $Organization, |
22 | | - |
23 | | - # The PicklistID. |
24 | | - [Parameter(Mandatory,ValueFromPipelineByPropertyName, |
25 | | - ParameterSetName='work/processes/lists/{PicklistId}')] |
26 | | - [string] |
27 | | - $PicklistID, |
28 | | - |
29 | | - # A list of items to remove. |
30 | | - # If this parameter is provided, the picklist items will be removed, and the picklist will not be deleted. |
31 | | - # If this parameter is not provided, the picklist will not be deleted. |
32 | | - [Parameter(ParameterSetName='work/processes/lists/{PicklistId}')] |
33 | | - [Alias('Value', 'Items','Values')] |
34 | | - [string[]] |
35 | | - $Item, |
36 | | - |
37 | | - # The server. By default https://dev.azure.com/. |
38 | | - # To use against TFS, provide the tfs server URL (e.g. http://tfsserver:8080/tfs). |
39 | | - [Parameter(ValueFromPipelineByPropertyName)] |
40 | | - [uri] |
41 | | - $Server = "https://dev.azure.com/", |
42 | | - |
43 | | - # The api version. By default, 5.1-preview. |
44 | | - # If targeting TFS, this will need to change to match your server version. |
45 | | - # See: https://docs.microsoft.com/en-us/azure/devops/integrate/concepts/rest-api-versioning?view=azure-devops |
46 | | - [string] |
47 | | - $ApiVersion = "5.1-preview" |
| 17 | + # The Organization. |
| 18 | + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] |
| 19 | + [Alias('Org')] |
| 20 | + [string] |
| 21 | + $Organization, |
| 22 | + |
| 23 | + # The PicklistID. |
| 24 | + [Parameter(Mandatory, ValueFromPipelineByPropertyName, |
| 25 | + ParameterSetName = 'work/processes/lists/{PicklistId}')] |
| 26 | + [string] |
| 27 | + $PicklistID, |
| 28 | + |
| 29 | + # A list of items to remove. |
| 30 | + # If this parameter is provided, the picklist items will be removed, and the picklist will not be deleted. |
| 31 | + # If this parameter is not provided, the picklist will not be deleted. |
| 32 | + [Parameter(ParameterSetName = 'work/processes/lists/{PicklistId}')] |
| 33 | + [Alias('Value', 'Items', 'Values')] |
| 34 | + [string[]] |
| 35 | + $Item, |
| 36 | + |
| 37 | + # The server. By default https://dev.azure.com/. |
| 38 | + # To use against TFS, provide the tfs server URL (e.g. http://tfsserver:8080/tfs). |
| 39 | + [Parameter(ValueFromPipelineByPropertyName)] |
| 40 | + [uri] |
| 41 | + $Server = "https://dev.azure.com/", |
| 42 | + |
| 43 | + # The api version. By default, 5.1-preview. |
| 44 | + # If targeting TFS, this will need to change to match your server version. |
| 45 | + # See: https://docs.microsoft.com/en-us/azure/devops/integrate/concepts/rest-api-versioning?view=azure-devops |
| 46 | + [string] |
| 47 | + $ApiVersion = "5.1-preview" |
48 | 48 | ) |
49 | 49 |
|
50 | 50 | dynamicParam { . $GetInvokeParameters -DynamicParameter } |
|
56 | 56 | } |
57 | 57 |
|
58 | 58 | process { |
| 59 | + if ($ApiVersion -like '5.*') { |
| 60 | + Write-Warning "The API version '$ApiVersion' may not be compatible with field operations. Consider using '7.0' or later." |
| 61 | + } |
| 62 | + |
59 | 63 | $ParameterSet = $psCmdlet.ParameterSetName |
60 | | - $q.Enqueue(@{ParameterSet=$ParameterSet} + $PSBoundParameters) |
| 64 | + $q.Enqueue(@{ParameterSet = $ParameterSet } + $PSBoundParameters) |
61 | 65 | } |
62 | 66 | end { |
63 | 67 | $c, $t, $id = 0, $q.Count, [Random]::new().Next() |
|
67 | 71 |
|
68 | 72 |
|
69 | 73 | $uri = # The URI is comprised of: |
70 | | - @( |
71 | | - "$server".TrimEnd('/') # the Server (minus any trailing slashes), |
72 | | - $Organization # the Organization, |
73 | | - '_apis' # the API Root ('_apis'), |
74 | | - (. $ReplaceRouteParameter $ParameterSet) |
75 | | - # and any parameterized URLs in this parameter set. |
76 | | - ) -as [string[]] -ne '' -join '/' |
| 74 | + @( |
| 75 | + "$server".TrimEnd('/') # the Server (minus any trailing slashes), |
| 76 | + $Organization # the Organization, |
| 77 | + '_apis' # the API Root ('_apis'), |
| 78 | + (. $ReplaceRouteParameter $ParameterSet) |
| 79 | + # and any parameterized URLs in this parameter set. |
| 80 | + ) -as [string[]] -ne '' -join '/' |
77 | 81 |
|
78 | 82 | $uri += '?' # The URI has a query string containing: |
79 | 83 | $uri += @( |
80 | 84 | if ($Server -ne 'https://dev.azure.com/' -and |
81 | 85 | -not $PSBoundParameters.ApiVersion) { |
82 | 86 | $ApiVersion = '2.0' |
83 | 87 | } |
84 | | - if ($ApiVersion) { # the api-version |
| 88 | + if ($ApiVersion) { |
| 89 | + # the api-version |
85 | 90 | "api-version=$apiVersion" |
86 | 91 | } |
87 | 92 | ) -join '&' |
88 | 93 |
|
89 | 94 | $c++ |
90 | | - Write-Progress "Removing $($Item -join ' ')" "[$c/$t] $uri" -Id $id -PercentComplete ($c * 100/$t) |
| 95 | + Write-Progress "Removing $($Item -join ' ')" "[$c/$t] $uri" -Id $id -PercentComplete ($c * 100 / $t) |
91 | 96 |
|
92 | 97 | $invokeParams.Uri = $uri |
93 | 98 |
|
|
98 | 103 | $getPicklistSplat.Remove('Name') |
99 | 104 | $getPicklistSplat.Remove('Item') |
100 | 105 | $picklistItems = Get-ADOPicklist @getPicklistSplat |
101 | | - $picklistItems.items = @( |
| 106 | + $picklistItems.items = @( |
102 | 107 | $picklistItems.items | |
103 | | - Where-Object { |
104 | | - foreach ($i in $item) { |
105 | | - if ( $_ -like $i) { return } |
106 | | - } |
107 | | - $_ |
108 | | - }) |
| 108 | + Where-Object { |
| 109 | + foreach ($i in $item) { |
| 110 | + if ( $_ -like $i) { return } |
| 111 | + } |
| 112 | + $_ |
| 113 | + }) |
109 | 114 | $invokeParams.body = $picklistItems |
110 | 115 | $invokeParams.pstypename = "$Organization.Picklist.Detail", "PSDevOps.Picklist.Detail" |
111 | | - } else { |
112 | | - $invokeParams.Method = 'DELETE' |
| 116 | + } |
| 117 | + else { |
| 118 | + $invokeParams.Method = 'DELETE' |
113 | 119 | } |
114 | 120 | if ($WhatIfPreference) { |
115 | 121 | $invokeParams.Remove('PersonalAccessToken') |
116 | 122 | $invokeParams |
117 | 123 | continue |
118 | 124 | } |
119 | | - if (-not $psCmdlet.ShouldProcess("$($invokeParams.Method) $($item -join ' ') $($invokeParams.uri)")) {continue } |
| 125 | + if (-not $psCmdlet.ShouldProcess("$($invokeParams.Method) $($item -join ' ') $($invokeParams.uri)")) { continue } |
120 | 126 | Invoke-ADORestAPI @invokeParams |
121 | 127 | } |
122 | 128 |
|
|
0 commit comments