AzurePipelinesPS.psm1
$Script:PSModuleRoot = $PSScriptRoot $Script:ModuleName = "AzurePipelinesPS" $Script:APAppDataPath = [Environment]::GetFolderPath('ApplicationData') $Script:ModuleDataRoot = (Join-Path -Path $Script:APAppDataPath -ChildPath $Script:ModuleName) $Script:ModuleDataPath = (Join-Path -Path $Script:ModuleDataRoot -ChildPath "ModuleData.json") if (-not (Test-Path $Script:ModuleDataRoot)) {New-Item -ItemType Directory -Path $Script:ModuleDataRoot -Force} # Imported from [D:\a\1\s\AzurePipelinesPS\Private] # Get-APAgentPackage.ps1 Function Get-APAgentPackage { <# .SYNOPSIS Returns available Azure Pipelines agent package versions download url. .DESCRIPTION Returns available Azure Pipelines agent package versions download url. The instance will provide a list of available compatible package versions and a url from which to download them. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Platform Operating system platform. .PARAMETER ApiVersion Version of the api to use. .PARAMETER Credential Specifies a user account that has permission to send the request. .INPUTS None, does not support pipeline. .OUTPUTS PSCustomObject. Get-APAgentPackage returns all compatable agent package versions. .EXAMPLE Get-APAgentPackage -Platform 'ubuntu.14.04-x64' -Credential $pscredential .EXAMPLE Returns the 'windows' agent package url. Get-APAgentPackage -Platform 'Windows' .EXAMPLE Returns the 'ubuntu.16.04-x64' agent package url. Get-APAgentPackage -Platform 'ubuntu.16.04-x64' .LINK https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=vsts #> [CmdletBinding()] Param ( [Parameter()] [string] $Instance, [Parameter(Mandatory)] [ValidateSet('Windows', 'ubuntu.16.04-x64', 'ubuntu.14.04-x64')] [string] $Platform, [Parameter()] [string] $ApiVersion, [Parameter()] [pscredential] $Credential ) begin { } Process { Switch -Regex ($ApiVersion) { '(5.|6.|7.|8.|9.|10.)' { Switch ($Platform) { 'Windows' { return 'https://vstsagentpackage.azureedge.net/agent/2.140.2/vsts-agent-win-x64-2.140.2.zip' } 'ubuntu.16.04-x64' { return 'https://vstsagentpackage.azureedge.net/agent/2.140.2/vsts-agent-linux-x64-2.140.2.tar.gz' } 'ubuntu.14.04-x64' { return 'https://vstsagentpackage.azureedge.net/agent/2.140.2/vsts-agent-linux-x64-2.140.2.tar.gz' } } } Default { $apiEndpoint = Get-APApiEndpoint -ApiType 'packages-agent' [uri] $uri = Set-APUri -Instance $Instance -ApiEndpoint $apiEndpoint $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat Switch ($Platform) { 'Windows' { return $Results.Value | Where-Object { $Psitem.Platform -eq 'win7-x64' } | Select-Object -ExpandProperty 'downloadUrl' } 'ubuntu.16.04-x64' { return $Results.Value | Where-Object { $Psitem.Platform -eq 'ubuntu.16.04-x64' } | Select-Object -ExpandProperty 'downloadUrl' } 'ubuntu.14.04-x64' { return $Results.Value | Where-Object { $Psitem.Platform -eq 'ubuntu.14.04-x64' } | Select-Object -ExpandProperty 'downloadUrl' } } } } } } # Get-APApiEndpoint.ps1 function Get-APApiEndpoint { <# .SYNOPSIS Returns the api uri endpoint. .DESCRIPTION Returns the api uri endpoint base on the api type. .PARAMETER ApiType Type of the api endpoint to use. .OUTPUTS String, The uri endpoint that will be used by Set-APUri. .EXAMPLE Returns the api endpoint for 'release-releases' Get-APApiEndpoint -ApiType release-releases .LINK https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-5.0 #> [CmdletBinding()] Param ( [Parameter(Mandatory)] [string] $ApiType ) begin { } process { Switch ($ApiType) { 'accesscontrollists-securityNamespaceId' { return '_apis/accesscontrollists/{0}' } 'accesscontrolentries-securityNamespaceId' { return '_apis/accesscontrolentries/{0}' } 'agent-agents' { return '_apis/distributedtask/pools/{0}/agents' } 'agent-agentId' { return '_apis/distributedtask/pools/{0}/agents/{1}' } 'build-builds' { return '_apis/build/builds' } 'build-buildId' { return '_apis/build/builds/{0}' } 'build-timeline' { return '_apis/build/builds/{0}/timeline' } 'build-timelineId' { return '_apis/build/builds/{0}/timeline/{1}' } 'build-definitions' { return '_apis/build/definitions' } 'build-definitionId' { return '_apis/build/definitions/{0}' } 'build-artifacts' { return '_apis/build/builds/{0}/artifacts' } 'build-workitems' { return '_apis/build/builds/{0}/workitems' } 'build-leases' { return '_apis/build/retention/leases' } 'build-leaseId' { return '_apis/build/retention/leases/{0}' } 'distributedtask-queues' { return '_apis/distributedtask/queues' } 'distributedtask-deploymentgroups' { return '_apis/distributedtask/deploymentgroups' } 'distributedtask-deploymentGroupId' { return '_apis/distributedtask/deploymentgroups/{0}' } 'distributedtask-environments' { return '_apis/distributedtask/environments' } 'distributedtask-environmentId' { return '_apis/distributedtask/environments/{0}' } 'distributedtask-targets' { return '_apis/distributedtask/deploymentgroups/{0}/targets' } 'distributedtask-targetId' { return '_apis/distributedtask/deploymentgroups/{0}/targets/{1}' } 'distributedtask-variablegroups' { return '_apis/distributedtask/variablegroups' } 'distributedtask-variablegroupId' { return '_apis/distributedtask/variablegroups/{0}' } 'dashboard-dashboards' { return '_apis/dashboard/dashboards' } 'dashboard-dashboardId' { return '_apis/dashboard/dashboards/{0}' } 'dashboard-widgets' { return '_apis/dashboard/dashboards/{0}/widgets' } 'dashboard-widgetId' { return '_apis/dashboard/dashboards/{0}/widgets/{1}' } 'extensionmanagement-installedextensions' { return '_apis/extensionmanagement/installedextensions' } 'extensionmanagement-installedextensionsbyname' { return '_apis/extensionmanagement/installedextensionsbyname/{0}/{1}' } 'extensionmanagement-collection' { return '_apis/extensionmanagement/installedextensions/{0}/{1}/Data/Scopes/{2}/{3}/Collections/{4}/Documents' } 'extensionmanagement-documentId' { return '_apis/extensionmanagement/installedextensions/{0}/{1}/Data/Scopes/{2}/{3}/Collections/{4}/Documents/{5}' } 'feed-feeds' { return '_apis/packaging/feeds' } 'feed-feedId' { return '_apis/packaging/feeds/{0}' } 'feed-packages' { return '_apis/packaging/feeds/{0}/packages' } 'feed-packageId' { return '_apis/packaging/feeds/{0}/packages/{1}' } 'feed-packageVersion' { return '_apis/packaging/feeds/{0}/nuget/packages/{1}/versions/{2}' } 'feed-RBpackageVersion' { return '_apis/packaging/feeds/{0}/nuget/RecycleBin/packages/{1}/versions/{2}' } 'feed-packageContent' { return '_apis/packaging/feeds/{0}/nuget/packages/{1}/versions/{2}/content' } 'git-repositories' { return '_apis/git/repositories' } 'git-repositoryId' { return '_apis/git/repositories/{0}' } 'git-commits' { return '_apis/git/repositories/{0}/commits' } 'git-refs' { return '_apis/git/repositories/{0}/refs' } 'git-pushes' { return '_apis/git/repositories/{0}/pushes' } 'git-pullRequests' { return '_apis/git/repositories/{0}/pullrequests' } 'git-deletedrepositories' { return '_apis/git/deletedrepositories' } 'git-recycleBin' { return '_apis/git/recycleBin/repositories' } 'git-items' { return '_apis/git/repositories/{0}/items' } 'graph-identities' { return '_apis/IdentityPicker/Identities/me/mru/common' } 'graph-userId' { return '_apis/graph/users/{0}' } 'graph-users' { return '_apis/graph/users' } 'graph-groupId' { return '_apis/graph/groups/{0}' } 'graph-groups' { return '_apis/graph/groups' } 'graph-descriptorStorageKey' { return '_apis/graph/descriptors/{0}' } 'graph-storagekeys' { return '_apis/graph/storagekeys/{0}' } 'graph-memberships' { return '_apis/graph/memberships/{0}' } 'graph-containerDescriptor' { return '_apis/graph/memberships/{0}/{1}' } 'groupentitlements-entitlements' { return '_apis/groupentitlements' } 'notification-subscriptions' { return '_apis/notification/subscriptions' } 'notification-subscriptionId' { return '_apis/notification/subscriptions/{0}' } 'notification-subscriptionTemplates' { return '_apis/notification/subscriptiontemplates' } 'operations-operationId' { return '_apis/operations/{0}' } 'packaging-feedName' { return '_packaging/{0}/nuget/v2' } 'packages-agent' { return '_apis/distributedTask/packages/agent' } 'permissions' { return '_apis/permissionsreport' } 'permissions-reportId' { return '_apis/permissionsreport/{0}' } 'permissions-download' { return '_apis/permissionsreport/{0}/download' } 'pipelines' { return '_apis/pipelines' } 'pipelines-approvals' { return '_apis/pipelines/approvals' } 'pipelines-approvalId' { return '_apis/pipelines/approvals/{0}' } 'pipelines-pipelineId' { return '_apis/pipelines/{0}' } 'pipelines-runs' { return '_apis/pipelines/{0}/runs' } 'pipelines-preview' { return '_apis/pipelines/{0}/preview' } 'pipelines-runId' { return '_apis/pipelines/{0}/runs/{1}' } 'pipelines-logs' { return '_apis/pipelines/{0}/runs/{1}/logs' } 'pipelines-logId' { return '_apis/pipelines/{0}/runs/{1}/logs/{2}' } 'pipelines-configurations' { return '_apis/pipelines/checks/configurations' } 'pipelines-endpointId' { return '_apis/pipelines/pipelinePermissions/endpoint/{0}' } 'policy-configurations' { return '_apis/policy/configurations' } 'policy-configurationId' { return '_apis/policy/configurations/{0}' } 'policy-types' { return '_apis/policy/types' } 'policy-typeId' { return '_apis/policy/types/{0}' } 'policy-evaluations' { return '_apis/policy/evaluations' } 'policy-evaluationId' { return '_apis/policy/evaluations/{0}' } 'policy-revisions' { return '_apis/policy/configurations/{0}/revisions' } 'policy-revisionId' { return '_apis/policy/configurations/{0}/revisions/{1}' } 'pool-pools' { return '_apis/distributedtask/pools' } 'pool-poolId' { return '_apis/distributedtask/pools/{0}' } 'project-projects' { return '_apis/projects' } 'project-projectId' { return '_apis/projects/{0}' } 'release-releases' { return '_apis/release/releases' } 'release-definitions' { return '_apis/release/definitions' } 'release-definitionId' { return '_apis/release/definitions/{0}' } 'release-deployments' { return '_apis/release/deployments' } 'release-releaseId' { return '_apis/release/releases/{0}' } 'release-manualInterventionId' { return '_apis/release/releases/{0}/manualinterventions/{1}' } 'release-environmentId' { return '_apis/release/releases/{0}/environments/{1}' } 'release-taskId' { return '_apis/release/releases/{0}/environments/{1}/deployPhases/{2}/tasks/{3}' } 'release-logs' { return '_apis/release/releases/{0}/environments/{1}/deployPhases/{2}/tasks/{3}/logs' } 'release-approvals' { return '_apis/release/approvals' } 'release-approvalId' { return '_apis/release/approvals/{0}' } 'serviceendpoint-endpoints' { return '_apis/serviceendpoint/endpoints' } 'serviceendpoint-endpointId' { return '_apis/serviceendpoint/endpoints/{0}' } 'serviceendpoint-types' { return '_apis/serviceendpoint/types' } 'serviceendpoint-executionhistory' { return '_apis/serviceendpoint/{0}/executionhistory' } 'serviceendpoint-endpointproxy' { return '_apis/serviceendpoint/endpointproxy' } 'serviceendpoint-endpointproxy' { return '_apis/serviceendpoint/endpointproxy' } 'securitynamespaces-securityNamespaceId' { return '_apis/securitynamespaces/{0}' } 'securefiles-secureFiles' { return '_apis/distributedtask/securefiles' } 'securefiles-secureFileId' { return '_apis/distributedtask/securefiles/{0}' } 'sourceProviders-sourceproviders' { return '_apis/sourceproviders' } 'sourceProviders-branches' { return '_apis/sourceProviders/{0}/branches' } 'taskgroup-taskgroups' { return '_apis/distributedtask/taskgroups' } 'team-teams' { return '_apis/teams' } 'team-projectId' { return '_apis/projects/{0}/teams' } 'team-teamId' { return '_apis/projects/{0}/teams/{1}' } 'team-members' { return '_apis/projects/{0}/teams/{1}/members' } 'test-runs' { return '_apis/test/runs' } 'test-runId' { return '_apis/test/runs/{0}' } 'test-statistics' { return '_apis/test/runs/{0}/statistics' } 'test-results' { return '_apis/test/Runs/{0}/results' } 'test-testCaseId' { return '_apis/test/runs/{0}/results/{1}' } 'test-testPlans' { return '_apis/testplan/plans' } 'test-testPlanId' { return '_apis/testplan/plans/{0}' } 'test-suites' { return '_apis/test/plans/{0}/suites' } 'test-suiteId' { return '_apis/test/plans/{0}/suites/{1}' } 'test-testcases' { return '_apis/test/plans/{0}/suites/{1}/testcases' } 'tokenadmin-subjectDescriptor' { return '_apis/tokenadmin/personalaccesstokens/{0}' } 'userentitlements-entitlements' { return '_apis/userentitlements' } 'wit-classificationnodes' { return '_apis/wit/classificationnodes' } 'wit-path' { return '_apis/wit/classificationnodes/{0}/{1}' } 'wit-workitemtypecategories' { return '_apis/wit/workitemtypecategories' } 'wit-queries' { return '_apis/wit/queries' } 'wit-queryId' { return '_apis/wit/queries/{0}' } 'wit-workitems' { return '_apis/wit/workitems' } 'wit-workitemId' { return '_apis/wit/workitems/{0}' } 'wit-type' { return '_apis/wit/workitems/${0}' } 'wit-wiql' { return '_apis/wit/wiql' } 'work-boards' { return '{0}/_apis/work/boards' } 'work-boardId' { return '{0}/_apis/work/boards/{1}' } 'work-plans' { return '_apis/work/plans' } 'work-planId' { return '_apis/work/plans/{0}' } 'work-processes' { return '_apis/work/processes' } 'work-lists' { return '_apis/work/processes/lists' } 'work-listId' { return '_apis/work/processes/lists/{0}' } 'work-workitemtypes' { return '_apis/work/processes/{0}/workitemtypes' } 'work-fields' { return '_apis/work/processes/{0}/workitemtypes/{1}/fields' } 'work-fields' { return '_apis/work/processes/{0}/workitemtypes/{1}/fields' } 'work-teamsettings' { return '{0}/_apis/work/teamsettings' } 'work-teamfieldvalues' { return '{0}/_apis/work/teamsettings/teamfieldvalues' } default { Write-Error "[$($MyInvocation.MyCommand.Name)]: [$ApiType] is not supported" -ErrorAction Stop } } } end { } } # Set-APAuthenticationType.ps1 function Set-APAuthenticationType { <# .SYNOPSIS Sets the authentication type used by Invoke-APRestMethod. .DESCRIPTION Sets the authentication type used by Invoke-APRestMethod. Default authentication will use the pesonal access token that is stored in session data, unless a credential is provided. .PARAMETER InputObject The splat parameters used by Invoke-APRestMethod. .PARAMETER Credential Specifies a user account that has permission to send the request. .OUTPUTS PSObject, The modifed inputobject. .EXAMPLE Set-APAuthenticationType -InputObject $inputObject .EXAMPLE Sets the AP authentication to the credential provided for the input object. Set-APAuthenticationType -InputObject $inputObject -Credential $pscredential .EXAMPLE Sets the AP authentication to the personal access token provided for the input object. Set-APAuthenticationType -InputObject $inputObject -PersonalAccessToken $mySecureToken .LINK https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/authentication-guidance?view=vsts #> [CmdletBinding()] param ( [Parameter(Mandatory)] [PSObject] $InputObject, [Parameter()] [Security.SecureString] $PersonalAccessToken, [Parameter()] [pscredential] $Credential ) begin { } process { If ($Credential) { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Authenticating with the provided credential." $InputObject.Credential = $Credential } elseIf ($PersonalAccessToken) { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Authenticating with the stored personal access token." $PersonalAccessTokenToken = Unprotect-APSecurePersonalAccessToken -PersonalAccessToken $PersonalAccessToken $encodedPersonalAccessToken = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$PersonalAccessTokenToken")) $InputObject.Headers = @{Authorization = "Basic $encodedPersonalAccessToken" } } else { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Authenticating with default credentials" $InputObject.UseDefaultCredentials = $true } } end { return $InputObject } } # Set-APQueryParameters.ps1 function Set-APQueryParameters { <# .SYNOPSIS Returns the formated query parameter string. .DESCRIPTION Returns the formated query parameter string. .PARAMETER InputObject The PS bound parameters. .PARAMETER SplitProperties Switch, splits the properties array into multiple property queries. Example: Get-APIdentityList .OUTPUTS String, The formated query parameter string. .EXAMPLE Sets the AP query parameters for the input object. Set-APQueryParameters -InputObject $PSBoundParameters .LINK https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-5.0 #> [CmdletBinding()] Param ( [Parameter()] [object] $InputObject, [Parameter()] [switch] $SplitProperties ) begin { } process { $nonQueryParams = @( 'Instance' 'Collection' 'Project' 'ApiVersion' 'PersonalAccessToken' 'Session' 'Credential' 'Verbose' 'Debug' 'ErrorAction' 'WarningAction' 'InformationAction' 'ErrorVariable' 'WarningVariable' 'InformationVariable' 'OutVariable' 'OutBuffer' 'UserDescriptor' 'GroupDescriptor' 'PersonalAccessToken' 'Proxy' 'ProxyCredential' 'Body' ) $queryParams = Foreach ($key in $InputObject.Keys) { If ($nonQueryParams -contains $key) { Continue } elseIf (($key -eq 'Properties') -and $SplitProperties.IsPresent) { Foreach ($prop in $InputObject.$Key) { "$key=$prop" } } elseIf ($key -in 'Top', 'Expand', 'Mine', 'Depth', 'IncludeDeleted', 'ExpandIdentity') { "`$$($key.ToLower())=$($InputObject.$key)" } elseIf ($key -Match '[A-Za-z0-9]+_[A-Za-z0-9]+') # keys with underscores convert to dot-delimited { $fixedKey = $key.Replace("_", ".") "$fixedKey=$($InputObject.$key)" } elseIf ($InputObject.$key.count) { "$key={0}" -f ($InputObject.$key -join ',') } else { "$key=$($InputObject.$key)" } } return ($queryParams -join '&') } end { } } # Set-APUri.ps1 function Set-APUri { <# .SYNOPSIS Sets the uri used by Invoke-APRestMethod. .DESCRIPTION Sets the uri used by Invoke-APRestMethod. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER Query Url query parameter. .PARAMETER ApiEndpoint The api endpoint provided by Get-APApiEndpoint. .PARAMETER ApiVersion Version of the api to use. .OUTPUTS Uri, The uri that will be used by Invoke-APRestMethod. .EXAMPLE Set-APUri -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiEndpoint _apis/Release/releases/4 -ApiVersion '5.0-preview.6' .EXAMPLE Set-APUri -ApiEndpoint _apis/Release/releases/4 -ApiVersion '5.0-preview.6' -Query 'project=myFirstProject&isdeleted=true&expand=environments' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-5.0 #> [CmdletBinding()] Param ( [Parameter()] [uri] $Instance, [Parameter()] [string] $Collection, [Parameter()] [string] $Project, [Parameter()] [string] $Query, [Parameter(Mandatory)] [string] $ApiEndpoint, [Parameter()] [string] $ApiVersion, [Parameter()] [string] $ApiSubDomainSwitch ) begin { } process { If (($ApiVersion -match '5.*' -or $ApiVersion -match '6.*') -and ($Instance.Host -eq 'dev.azure.com' -or $Instance.Host -like '*.visualstudio.com')) { Switch ($ApiSubDomainSwitch) { # Used by release 'vsrm' { If ($Instance.AbsoluteUri -and $Collection -and $Project -and $Query) { # Append vsrm prefix to instance with query return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vsrm.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection -and $Project) { # Append vsrm prefix to instance without query return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vsrm.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $ApiVersion } } # Used by feeds 'feeds' { If ($Instance.AbsoluteUri -and $Collection -and $Query) { # Append feeds prefix to instance with query return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri.replace($Instance.Host, "feeds.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection) { # Append feeds prefix to instance without query return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri.replace($Instance.Host, "feeds.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $ApiVersion } } # Used by versions and packaging 'pkgs' { If ($Instance.AbsoluteUri -and $Collection -and $Project -And $Query) { # Append pkgs prefix to instance with query return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri.replace($Instance.Host, "pkgs.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } If ($Instance.AbsoluteUri -and $Collection) { # Append pkgs prefix to instance without query and api version return '{0}{1}/{2}' -f $Instance.AbsoluteUri.replace($Instance.Host, "pkgs.$($Instance.Host)"), $Collection, $ApiEndpoint } } # Used with graph and tokenadmin 'vssps' { If ($Instance.AbsoluteUri -and $Collection -and $Query) { # Append vssps prefix to instance with query return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vssps.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection -and $Project) { # Append vssps prefix to instance without query return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vssps.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection) { # Append vssps prefix to instance without query return '{0}{1}/{2}?api-version={3}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vssps.$($Instance.Host)"), $Collection, $ApiEndpoint, $ApiVersion } } # Used by groupentitlements and userentitlements 'vsaex' { If ($Instance.AbsoluteUri -and $Collection -and $Query) { # Append vsaex prefix to instance with query return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vsaex.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } If ($Instance.AbsoluteUri -and $Collection) { # Append vsaex prefix to instance without query return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri.replace($Instance.Host, "vsaex.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $ApiVersion } } # Used by extensionmanagement 'extmgmt' { If ($Instance.AbsoluteUri -and $Collection -and $Query) { # Append extmgmt prefix to instance with query return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri.replace($Instance.Host, "extmgmt.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection) { # Append extmgmt prefix to instance without query return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri.replace($Instance.Host, "extmgmt.$($Instance.Host)"), $Collection, $Project, $ApiEndpoint, $ApiVersion } } default { If ($Instance.AbsoluteUri -and $Collection -and $Project -and $Query) { return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri, $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } If ($Instance.AbsoluteUri -and $Collection -and $Project) { return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri, $Collection, $Project, $ApiEndpoint, $ApiVersion } If ($Instance.AbsoluteUri -and $Collection) { return '{0}{1}/{2}?api-version={3}' -f $Instance.AbsoluteUri, $Collection, $ApiEndpoint, $ApiVersion } } } } If ($Instance.AbsoluteUri -and $Collection -and $Project -and $ApiEndpoint -and $ApiVersion -and $Query) { return '{0}{1}/{2}/{3}?{4}&api-version={5}' -f $Instance.AbsoluteUri, $Collection, $Project, $ApiEndpoint, $Query, $ApiVersion } If ($Instance.AbsoluteUri -and $Collection -and $ApiEndpoint -and $ApiVersion -and $Query) { return '{0}{1}/{2}?{3}&api-version={4}' -f $Instance.AbsoluteUri, $Collection, $ApiEndpoint, $Query, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection -and $Project -and $ApiEndpoint -and $ApiVersion) { return '{0}{1}/{2}/{3}?api-version={4}' -f $Instance.AbsoluteUri, $Collection, $Project, $ApiEndpoint, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $Collection -and $ApiEndpoint -and $ApiVersion) { return '{0}{1}/{2}?api-version={3}' -f $Instance.AbsoluteUri, $Collection, $ApiEndpoint, $ApiVersion } elseIf ($Instance.AbsoluteUri -and $ApiEndpoint) { return '{0}{1}' -f $Instance.AbsoluteUri, $ApiEndpoint } } end { } } # Unprotect-APSecurePersonalAccessToken.ps1 Function Unprotect-APSecurePersonalAccessToken { <# .SYNOPSIS Returns decrypted personal access token. .DESCRIPTION Returns decrypted personal access token that is stored in the session data. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .OUTPUTS String, unsecure personal access token. .EXAMPLE Unprotects the personal access token from secure string to plain text. Unprotect-SecurePersonalAccessToken -PersonalAccessToken $mySecureToken .LINK https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/authentication-guidance?view=vsts #> [CmdletBinding()] Param ( [Parameter(Mandatory)] [Security.SecureString] $PersonalAccessToken ) Process { $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PersonalAccessToken) $plainText = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) if ([environment]::OSVersion.Platform -eq "Unix") { $plainText = [System.Net.NetworkCredential]::new("", $PersonalAccessToken).Password } return $plainText } } # Imported from [D:\a\1\s\AzurePipelinesPS\Public] # Add-APDeploymentGroup.ps1 function Add-APDeploymentGroup { <# .SYNOPSIS Creates an Azure Pipeline deployment group. .DESCRIPTION Creates an Azure Pipeline deployment group. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name Name of the deployment group. .PARAMETER Description Description of the deployment group. .PARAMETER PoolId Identifier of the deployment pool in which deployment agents are registered. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines deployment group. .EXAMPLE Creates the AP deployment group 'myGroup' for the project 'myFirstProject' Add-APDeploymentGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Name 'myGroup' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/deploymentgroups/add?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [string] $Description, [Parameter()] [string] $PoolId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ Name = $Name Description = $Description PoolId = $PoolId } $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-deploymentGroupId') -f $DeploymentGroupID $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Add-APField.ps1 function Add-APField { <# .SYNOPSIS Adds an Azure Pipeline field to a work item type and process. .DESCRIPTION Adds an Azure Pipeline field to a work item type and process. The process id can be retrieved by using Get-APProcessList. Work item type reference name can be retrieved by using Get-APWorkItemTypeList .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProcessId The id of the process .PARAMETER WitRefName The reference name of the work item type. .PARAMETER AllowedGroups Allow setting field value to a group identity. Only applies to identity fields. .PARAMETER AllowedValues The list of field allowed values. .PARAMETER DefaultValue The default value of the field. .PARAMETER ReadOnly If true the field cannot be edited. .PARAMETER ReferenceName Reference name of the field. .PARAMETER Required If true the field cannot be empty. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines field(s) .EXAMPLE Adds an AP field to a work item process. Add-APField -Session $session -ProcessId $process.TypeId -WitRefName 'Microsoft.VSTS.WorkItemTypes.Bug' -ReferenceName 'Custom.ReflectedWorkItemId' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/fields/add?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProcessId, [Parameter(Mandatory)] [string] $WitRefName, [Parameter()] [bool] $AllowedGroups, [Parameter()] [string[]] $AllowedValues, [Parameter()] [string] $DefaultValue, [Parameter()] [bool] $ReadOnly, [Parameter()] [string] $ReferenceName, [Parameter()] [bool] $Required ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ allowGroups = $AllowedGroups allowedValues = $AllowedValues defaultValue = $DefaultValue readOnly = $ReadOnly referenceName = $ReferenceName required = $Required } $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-fields') -f $ProcessId, $WitRefName $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Add-APGroupMembership.ps1 function Add-APGroupMembership { <# .SYNOPSIS Create a new membership between a container and subject. .DESCRIPTION Create a new membership between a container and subject. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectDescriptor A descriptor to the child subject in the relationship. .PARAMETER ContainerDescriptor A descriptor to the container in the relationship. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines variable group. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/memberships/add?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubjectDescriptor, [Parameter(Mandatory)] [string] $ContainerDescriptor ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-containerDescriptor') -f $SubjectDescriptor, $ContainerDescriptor $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Add-APLogFile.ps1 function Add-APLogFile { <# .SYNOPSIS Pipeline invocation command used to upload and attach a file to the pipeline timeline record. .DESCRIPTION Pipeline invocation command used to upload and attach a file to the pipeline timeline record. The file shall be available for download along with task logs. .PARAMETER Path The path to the markdown file to upload to the release summary. .INPUTS None, does not support the pipline. .OUTPUTS None, does not support output. .EXAMPLE Add-APLogFile -Path '.\myFile.txt' #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string] $Path ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { If (Test-Path $Path) { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Uploading the file from [$Path] to the pipeline logs." If ($pipelineInvocation) { Write-Host "##vso[task.uploadfile]$Path" } } else { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate file at [$Path]" } } end { } } # Add-APPool.ps1 function Add-APPool { <# .SYNOPSIS Creates an Azure Pipeline agent pool. .DESCRIPTION Creates an Azure Pipeline agent pool. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name Sets name of the variable group. .PARAMETER PoolType The type of pool, automation or deployment. .PARAMETER AutoProvision Should the pool be provisioned in all the projects in the collection. .PARAMETER Scope The scope of the pool. GUID of the project collection. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines variable group. .EXAMPLE Adds a pool named 'myNewPool' Add-APPool -Session 'mySession' -Name 'myNewPool' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/pools/add?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [ValidateSet('automation', 'deployment')] [string] $PoolType, [Parameter()] [bool] $AutoProvision = $true, [Parameter()] [string] $Scope ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ name = $Name autoProvision = $AutoProvision } If ($PoolType) { $body.poolType = $PoolType } If ($Scope) { $body.scope = $Scope } $apiEndpoint = Get-APApiEndpoint -ApiType 'pool-pools' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Add-APQueue.ps1 Function Add-APQueue { <# .SYNOPSIS Adds an Azure Pipeline queue to a project. .DESCRIPTION Adds an Azure Pipeline queue to a project based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the queue. .PARAMETER Id The id of the queue. .PARAMETER Pool Pool reference for this queue. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines queue(s) .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/queues/add?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [int] $Id, [Parameter()] [string] $Pool ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ name = $Name } $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-queues' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential Body = $body ContentType = 'application/json' } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Add-APVariableGroup.ps1 function Add-APVariableGroup { <# .SYNOPSIS Creates an Azure Pipeline variable group. .DESCRIPTION Creates an Azure Pipeline variable group. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Description Sets description of the variable group. .PARAMETER Name Sets name of the variable group. .PARAMETER Variables Sets variables contained in the variable group. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines variable group. .EXAMPLE $varibales = @{ Var1 = 'updated val1' Var2 = 'updated val2' } $addAPVariableGroupSplat = @{ Description = 'my variable group' Name = 'myVariableGroup' Variables = $varibales Instance = 'https://dev.azure.com' Collection = 'myCollection' Project = 'myFirstProject' } Add-APVariableGroup @addAPVariableGroupSplat .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/variablegroups/add?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [string] $Description, [Parameter(Mandatory)] [object] $Variables ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { If ($Variables.GetType().Name -eq 'hashtable') { $_variables = @{ } Foreach ($token in $Variables.Keys) { $_variables.$token = @{ Value = $Variables.$token } } } else { $_variables = $Variables } $body = @{ Name = $Name Description = $Description Type = 'Vsts' Variables = $_variables } $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-variablegroups' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Add-APWidget.ps1 function Add-APWidget { <# .SYNOPSIS Adds an Azure Pipeline widget to a dashboard. .DESCRIPTION Adds an Azure Pipeline widget to a dashboard. The widget can object can be retrieved by using Get-APWidget and modifying the position. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Dashboard ID of the dashboard to read. .PARAMETER Widget The widget object, the object can be retrived using Get-APWidgetList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines widget. .EXAMPLE $widget = Get-APWidget -Session 'mySession' -Dashboard '51485dc189cd1-c894-41984-a77a-8sw4xc94' -Widget '580583f2-ce98-4890-a77a-853ee419c196' $widget.position.row = 2 # Update the position to an empty row Add-APWidget -Session 'mySession' -Dashboard '51485dc189cd1-c894-41984-a77a-8sw4xc94' -Widget $widget .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/widgets/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Dashboard, [Parameter(Mandatory)] [object] $Widget ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $null = $Widget.psobject.Properties.Remove('Id') $apiEndpoint = (Get-APApiEndpoint -ApiType 'dashboard-widgets') -f $Dashboard $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $Widget ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Copy-APDashboard.ps1 function Copy-APDashboard { <# .SYNOPSIS Copies an existing Azure Pipelines dashboard. **Does not copy dependent queries.** .DESCRIPTION Copies an existing Azure Pipelines dashboard by name or id. **Does not copy dependent queries.** Return a list of dashboards with Get-APDashboardList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TargetInstance The Team Services account or TFS server. .PARAMETER TargetCollection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER TargetProject Project ID or project name. .PARAMETER TargetApiVersion Version of the api to use. .PARAMETER TargetPersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER TargetCredential Specifies a user account that has permission to send the request. .PARAMETER TargetProxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER TargetProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER TargetSession Azure DevOps PS session, created by New-APSession. .PARAMETER DashboardId The id of the dashboard to copy. .PARAMETER Name The name of the dashboard. .PARAMETER NewName The name of the new dashboard. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines dashboard. .EXAMPLE Copies a dashboard with the name of 'myFirstDashboard' for 'myFirstProject' Copy-APDashboard -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Name 'myFirstDashboard' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/dashboards/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [uri] $TargetInstance, [Parameter()] [string] $TargetCollection, [Parameter()] [string] $TargetProject, [Parameter()] [string] $TargetApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $TargetPersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $TargetCredential, [Parameter()] [string] $TargetProxy, [Parameter()] [pscredential] $TargetProxyCredential, [Parameter()] [object] $TargetSession, [Parameter()] [string] $DashboardId, [Parameter()] [string] $Name, [Parameter()] [string] $NewName ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } $currentTargetSession = $TargetSession | Get-APSession If ($currentTargetSession) { $TargetInstance = $currentTargetSession.Instance $TargetCollection = $currentTargetSession.Collection $TargetProject = $currentTargetSession.Project $TargetPersonalAccessToken = $currentTargetSession.PersonalAccessToken $TargetCredential = $currentTargetSession.Credential $TargetProxy = $currentTargetSession.Proxy $TargetProxyCredential = $currentTargetSession.ProxyCredential If ($currentTargetSession.Version) { $TargetApiVersion = (Get-APApiVersion -Version $currentTargetSession.Version) } else { $TargetApiVersion = $currentTargetSession.ApiVersion } } } } process { $sourceSplat = @{ Instance = $Instance Collection = $Collection Project = $Project ApiVersion = $ApiVersion Proxy = $Proxy ProxyCredential = $ProxyCredential ErrorAction = 'Stop' } If ($PersonalAccessToken) { $sourceSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $sourceSplat.Credential = $Credential } If (-not($TargetInstance)) { $TargetInstance = $Instance } If (-not($TargetCollection)) { $TargetCollection = $Collection } If (-not($TargetProject)) { $TargetProject = $Project } If (-not($TargetApiVersion)) { $TargetApiVersion = $ApiVersion } If (-not($TargetPersonalAccessToken)) { $TargetPersonalAccessToken = $PersonalAccessToken } If (-not($TargetCredential)) { $TargetCredential = $Credential } If (-not($TargetProxy)) { $TargetProxy = $Proxy } If (-not($TargetProxyCredential)) { $TargetProxyCredential = $ProxyCredential } $targetSplat = @{ Instance = $TargetInstance Collection = $TargetCollection Project = $TargetProject ApiVersion = $TargetApiVersion Proxy = $TargetProxy ProxyCredential = $TargetProxyCredential } If ($PersonalAccessToken) { $targetSplat.PersonalAccessToken = $TargetPersonalAccessToken } If ($Credential) { $targetSplat.Credential = $TargetCredential } If ($DashboardId) { $dashboard = Get-APDashboard @sourceSplat -DashboardId $DashboardId If (-not($NewName)) { $NewName = "$($dashboard.name) Copy" } New-APDashboard @targetSplat -Name $NewName -Widget $dashboard.widgets -Owner $dashboard.ownerId -DashboardScope $dashboard.Scope -RefreshInterval $dashboard.refreshInterval } else { $dashboards = Get-APDashboardList @sourceSplat | Where-Object { $PSItem.name -eq $Name } If (-not($dashboards)) { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate a dashboard named [$Name] in [$Collection]\[$Project] " -ErrorAction 'Stop' } Foreach ($dashboard in $dashboards) { If (-not($NewName)) { $NewName = "$($dashboard.name) Copy" } $dashboard = Get-APDashboard @sourceSplat -DashboardId $dashboard.Id New-APDashboard @targetSplat -Name $NewName -Widget $dashboard.widgets -Owner $dashboard.ownerId -DashboardScope $dashboard.Scope -RefreshInterval $dashboard.refreshInterval } } } end { } } # Copy-APNode.ps1 function Copy-APNode { <# .SYNOPSIS Copies an existing Azure Pipelines node. .DESCRIPTION Copies an existing Azure Pipelines node by name or id. Return a list of nodes with Get-APNodeList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TargetInstance The Team Services account or TFS server. .PARAMETER TargetCollection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER TargetProject Project ID or project name. .PARAMETER TargetApiVersion Version of the api to use. .PARAMETER TargetPersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER TargetCredential Specifies a user account that has permission to send the request. .PARAMETER TargetProxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER TargetProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER TargetSession Azure DevOps PS session, created by New-APSession. .PARAMETER StructureGroup Structure group of the classification node. Options are areas or iterations. .PARAMETER NodeId The id of the node to copy. .PARAMETER Path Path of the classification node to copy. Do not include the name of the project or structure group in the path. .PARAMETER TargetPath The name target node path. Do not include the name of the project or structure group in the path. .PARAMETER Depth Depth of the children to fetch. .PARAMETER UpdateExisting Will update the existing node. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines node. .EXAMPLE Copies the iteration node at path 'Iteration 1' to the target path 'Team 3'. Copy-APNode -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Path 'Iteration 1' -TargetPath 'Team 3' -Depth 2 -StructureGroup 'iterations' .EXAMPLE Copies all the iterations from 'myFirstProject' to the 'mySecondProject' in the same instance. Copy-APNode -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -TargetProject 'mySecondProject' -Depth 3 -StructureGroup 'iterations' .LINK Get AP node https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/get?view=azure-devops-rest-6.0 Update AP node https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/create%20or%20update?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [uri] $TargetInstance, [Parameter()] [string] $TargetCollection, [Parameter()] [string] $TargetProject, [Parameter()] [string] $TargetApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $TargetPersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $TargetCredential, [Parameter()] [string] $TargetProxy, [Parameter()] [pscredential] $TargetProxyCredential, [Parameter()] [object] $TargetSession, [Parameter(Mandatory)] [string] $StructureGroup, [Parameter()] [string] $Path, [Parameter()] [string] $NodeId, [Parameter()] [object] $TargetPath, [Parameter()] [string] $Depth, [Parameter()] [switch] $UpdateExisting ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } $currentTargetSession = $TargetSession | Get-APSession If ($currentTargetSession) { $TargetInstance = $currentTargetSession.Instance $TargetCollection = $currentTargetSession.Collection $TargetProject = $currentTargetSession.Project $TargetPersonalAccessToken = $currentTargetSession.PersonalAccessToken $TargetCredential = $currentTargetSession.Credential $TargetProxy = $currentTargetSession.Proxy $TargetProxyCredential = $currentTargetSession.ProxyCredential If ($currentTargetSession.Version) { $TargetApiVersion = (Get-APApiVersion -Version $currentTargetSession.Version) } else { $TargetApiVersion = $currentTargetSession.ApiVersion } } } } process { $sourceSplat = @{ Instance = $Instance Collection = $Collection ApiVersion = $ApiVersion Project = $Project Proxy = $Proxy ProxyCredential = $ProxyCredential ErrorAction = 'Stop' Depth = $Depth } If ($PersonalAccessToken) { $sourceSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $sourceSplat.Credential = $Credential } If (-not($TargetInstance)) { $TargetInstance = $Instance } If (-not($TargetCollection)) { $TargetCollection = $Collection } If (-not($TargetProject)) { $TargetProject = $Project } If (-not($TargetApiVersion)) { $TargetApiVersion = $ApiVersion } If (-not($TargetPersonalAccessToken)) { $TargetPersonalAccessToken = $PersonalAccessToken } If (-not($TargetCredential)) { $TargetCredential = $Credential } If (-not($TargetProxy)) { $TargetProxy = $Proxy } If (-not($TargetProxyCredential)) { $TargetProxyCredential = $ProxyCredential } $targetSplat = @{ Instance = $TargetInstance Collection = $TargetCollection Project = $TargetProject ApiVersion = $TargetApiVersion Proxy = $TargetProxy ProxyCredential = $TargetProxyCredential StructureGroup = $StructureGroup } If ($PersonalAccessToken) { $targetSplat.PersonalAccessToken = $TargetPersonalAccessToken } If ($Credential) { $targetSplat.Credential = $TargetCredential } If ($NodeId) { [array] $nodes = Get-APNodeList @sourceSplat -Ids $NodeId } elseIf ($Path) { [array] $nodes = Get-APNode @sourceSplat -StructureGroup $StructureGroup -Path $Path } else { [array] $nodes = Get-APNode @sourceSplat -StructureGroup $StructureGroup } foreach ($node in $nodes) { foreach ($child in $node.children) { $null = $PSBoundParameters.Remove('Depth') $null = $PSBoundParameters.Remove('NodeId') Copy-APNode @PSBoundParameters -NodeId $child.Id -Depth ($Depth - 1) } $split = $node.path.Split('\') # Skip copying root node If ($split.count -le 3) { Continue } $parsedPath = $split[3..($split.count - 1)] -join '\' If ($TargetPath) { $_targetPath = "{0}\{1}" -f $TargetPath, $parsedPath } else { $_targetPath = $parsedPath } $_targetSpilt = $_targetPath.Split('\') for ($i = 0; $i -le ($_targetSpilt.Count - 1); $i++) { $name = $_targetSpilt[($i)] If ($i -eq 0) { $exists = Get-APNode @targetSplat -Path $name -ErrorAction 'SilentlyContinue' If ($exists) { If ($UpdateExisting.IsPresent) { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Updating [$name] in [$TargetProject]" Update-APNode @targetSplat -Path $name -Attributes $node.attributes } else { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Located [$name] in [$TargetProject], Skipping." Continue } } else { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Creating [$name] in [$TargetProject]" New-APNode @targetSplat -Name $name -Attributes $node.attributes } } else { $searchPath = $_targetSpilt[0..($i)] -join '\' $_path = $_targetSpilt[0..($i - 1)] -join '\' $exists = Get-APNode @targetSplat -Path $searchPath -ErrorAction 'SilentlyContinue' If ($exists) { If ($UpdateExisting.IsPresent) { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Updating [$searchPath] in [$TargetProject]" Update-APNode @targetSplat -Path $searchPath -Attributes $node.attributes } else { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Located [$searchPath] in [$TargetProject], Skipping." Continue } } else { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Creating [$_path\$name] in [$TargetProject]" New-APNode @targetSplat -Name $name -Path $_path -Attributes $node.attributes } } } } } end { } } # Copy-APQuery.ps1 function Copy-APQuery { <# .SYNOPSIS Copies an existing Azure Pipelines query. **Does not copy dependent queries.** .DESCRIPTION Copies an existing Azure Pipelines query by name or id. **Does not copy dependent queries.** Return a list of querys with Get-APQueryList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TargetInstance The Team Services account or TFS server. .PARAMETER TargetCollection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER TargetProject Project ID or project name. .PARAMETER TargetApiVersion Version of the api to use. .PARAMETER TargetPersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER TargetCredential Specifies a user account that has permission to send the request. .PARAMETER TargetProxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER TargetProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER TargetSession Azure DevOps PS session, created by New-APSession. .PARAMETER ParentId The query id of the folder to copy the query to. .PARAMETER QueryId The id of the query to copy. .PARAMETER Name The name of the query. .PARAMETER NewName The name of the new query. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines query. .EXAMPLE Copies a query in the 'Shared Queries' folder named 'My Feature Query' to the Target project 'otherProject' and names it 'My Feature Query' Copy-APQuery -Session $session -QueryId 'Shared Queries/My Feature Query' -ParentId 'Shared Queries' -Name 'My Feature Query' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/query/querys/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [uri] $TargetInstance, [Parameter()] [string] $TargetCollection, [Parameter()] [string] $TargetProject, [Parameter()] [string] $TargetApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $TargetPersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $TargetCredential, [Parameter()] [string] $TargetProxy, [Parameter()] [pscredential] $TargetProxyCredential, [Parameter()] [object] $TargetSession, [Parameter(Mandatory)] [string] $QueryId, [Parameter(Mandatory)] [string] $ParentId, [Parameter()] [string] $Name ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } $currentTargetSession = $TargetSession | Get-APSession If ($currentTargetSession) { $TargetInstance = $currentTargetSession.Instance $TargetCollection = $currentTargetSession.Collection $TargetProject = $currentTargetSession.Project $TargetPersonalAccessToken = $currentTargetSession.PersonalAccessToken $TargetCredential = $currentTargetSession.Credential $TargetProxy = $currentTargetSession.Proxy $TargetProxyCredential = $currentTargetSession.ProxyCredential If ($currentTargetSession.Version) { $TargetApiVersion = (Get-APApiVersion -Version $currentTargetSession.Version) } else { $TargetApiVersion = $currentTargetSession.ApiVersion } } } } process { $sourceSplat = @{ Instance = $Instance Collection = $Collection Project = $Project ApiVersion = $ApiVersion Proxy = $Proxy ProxyCredential = $ProxyCredential ErrorAction = 'Stop' } If ($PersonalAccessToken) { $sourceSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $sourceSplat.Credential = $Credential } If (-not($TargetInstance)) { $TargetInstance = $Instance } If (-not($TargetCollection)) { $TargetCollection = $Collection } If (-not($TargetProject)) { $TargetProject = $Project } If (-not($TargetApiVersion)) { $TargetApiVersion = $ApiVersion } If (-not($TargetPersonalAccessToken)) { $TargetPersonalAccessToken = $PersonalAccessToken } If (-not($TargetCredential)) { $TargetCredential = $Credential } If (-not($TargetProxy)) { $TargetProxy = $Proxy } If (-not($TargetProxyCredential)) { $TargetProxyCredential = $ProxyCredential } $targetSplat = @{ Instance = $TargetInstance Collection = $TargetCollection Project = $TargetProject ApiVersion = $TargetApiVersion Proxy = $TargetProxy ProxyCredential = $TargetProxyCredential } If ($PersonalAccessToken) { $targetSplat.PersonalAccessToken = $TargetPersonalAccessToken } If ($Credential) { $targetSplat.Credential = $TargetCredential } $query = Get-APQuery @sourceSplat -QueryId $QueryId -Expand 'all' -Depth 2 If (-not($Name)) { $Name = "$($query.name) Copy" } If ($query.IsFolder) { New-APQuery @targetSplat -QueryId $ParentId -Name $Name -IsFolder $query.IsFolder -Children $query.Children } else { New-APQuery @targetSplat -QueryId $ParentId -Name $Name -Wiql $query.wiql } } end { } } # Copy-APTeam.ps1 function Copy-APTeam { <# .SYNOPSIS Copies an existing Azure Pipelines team. **Cross organization membership copy is not supported at this time** .DESCRIPTION Copies an existing Azure Pipelines team by name or id. **Cross organization membership copy is not supported at this time** Return a list of teams with Get-APTeamList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TargetInstance The Team Services account or TFS server. .PARAMETER TargetCollection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER TargetProject Project ID or project name. .PARAMETER TargetApiVersion Version of the api to use. .PARAMETER TargetPersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER TargetCredential Specifies a user account that has permission to send the request. .PARAMETER TargetProxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER TargetProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER TargetSession Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The id of the team to copy. .PARAMETER Name The name of the team. .PARAMETER NewName The name of the new team. .PARAMETER UpdateExisting If the team exists in the target update it. Used for syncing teams across projects. .PARAMETER ExcludeTeamSettings Exclude the team's settings. .PARAMETER ExcludeTeamFields Exclude the team's fields. .PARAMETER ExcludeTeamMembers Exclude the team's members. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines team. .EXAMPLE Copies a team with the team's backlog and iteration settings. Copy-APTeam -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Name 'myTeam' .EXAMPLE Copies a team without it's backlog and iteration settings. Copy-APTeam -Session $session -TeamId 'myTeam -ExcludeTeamSettings .EXAMPLE Copies 'myTeam' with it's settings and names the new team 'Team 1'. Copy-APTeam -Session $session -TeamId 'myTeam -NewName 'Team 1' .LINK Get AP Team https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/get?view=azure-devops-rest-5.1 Get AP Team Settings https://docs.microsoft.com/en-us/rest/api/azure/devops/work/teamsettings/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [uri] $TargetInstance, [Parameter()] [string] $TargetCollection, [Parameter()] [string] $TargetProject, [Parameter()] [string] $TargetApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $TargetPersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $TargetCredential, [Parameter()] [string] $TargetProxy, [Parameter()] [pscredential] $TargetProxyCredential, [Parameter()] [object] $TargetSession, [Parameter()] [string] $TeamId, [Parameter()] [string] $NewName, [Parameter()] [switch] $UpdateExisting, [Parameter()] [switch] $ExcludeTeamSettings, [Parameter()] [switch] $ExcludeTeamFields, [Parameter()] [switch] $ExcludeTeamMembers ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } $currentTargetSession = $TargetSession | Get-APSession If ($currentTargetSession) { $TargetInstance = $currentTargetSession.Instance $TargetCollection = $currentTargetSession.Collection $TargetProject = $currentTargetSession.Project $TargetPersonalAccessToken = $currentTargetSession.PersonalAccessToken $TargetCredential = $currentTargetSession.Credential $TargetProxy = $currentTargetSession.Proxy $TargetProxyCredential = $currentTargetSession.ProxyCredential If ($currentTargetSession.Version) { $TargetApiVersion = (Get-APApiVersion -Version $currentTargetSession.Version) } else { $TargetApiVersion = $currentTargetSession.ApiVersion } } } } process { $sourceSplat = @{ Instance = $Instance Collection = $Collection Project = $Project Proxy = $Proxy ProxyCredential = $ProxyCredential ErrorAction = 'Stop' } If ($PersonalAccessToken) { $sourceSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $sourceSplat.Credential = $Credential } If (-not($TargetInstance)) { $TargetInstance = $Instance } If (-not($TargetCollection)) { $TargetCollection = $Collection } If (-not($TargetProject)) { $TargetProject = $Project } If (-not($TargetApiVersion)) { $TargetApiVersion = $ApiVersion } If (-not($TargetPersonalAccessToken)) { $TargetPersonalAccessToken = $PersonalAccessToken } If (-not($TargetCredential)) { $TargetCredential = $Credential } If (-not($TargetProxy)) { $TargetProxy = $Proxy } If (-not($TargetProxyCredential)) { $TargetProxyCredential = $ProxyCredential } $targetSplat = @{ Instance = $TargetInstance Collection = $TargetCollection Proxy = $TargetProxy ProxyCredential = $TargetProxyCredential ErrorAction = 'Stop' } If ($PersonalAccessToken) { $targetSplat.PersonalAccessToken = $TargetPersonalAccessToken } If ($Credential) { $targetSplat.Credential = $TargetCredential } If ($TeamId) { $teams = Get-APTeam @sourceSplat -TeamId $TeamId -ApiVersion $ApiVersion If (-not($NewName)) { $NewName = $TeamId } } else { $teams = Get-APTeamList @sourceSplat -ApiVersion $ApiVersion | Where-Object { $PSItem.name -eq $Name } If (-not($teams)) { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate a team named [$Name] in [$Collection]\[$Project] " -ErrorAction 'Stop' } If (-not($NewName)) { $NewName = $Name } } Foreach ($team in $teams) { If ($UpdateExisting.IsPresent) { $team = Get-APTeam @sourceSplat -TeamId $team.Id -ApiVersion $ApiVersion try { $newTeam = Get-APTeam @targetSplat -Project $TargetProject -TeamId $NewName -ApiVersion $ApiVersion } catch { $newTeam = New-APTeam @targetSplat -Project $TargetProject -ApiVersion $TargetApiVersion -Name $NewName } } else { # Append copy to new name Do { try { $null = Get-APTeam @targetSplat -Project $TargetProject -TeamId $NewName -ApiVersion $ApiVersion $foundTeam = $true $NewName = $NewName + ' Copy' } catch { $foundTeam = $false } } While ($foundTeam) $team = Get-APTeam @sourceSplat -TeamId $team.Id -ApiVersion $ApiVersion $newTeam = New-APTeam @targetSplat -Project $TargetProject -ApiVersion $TargetApiVersion -Name $NewName } $results = @{ team = $newTeam } If (-not($ExcludeTeamSettings.IsPresent)) { $teamSettings = Get-APTeamSettings @sourceSplat -TeamId $team.Id -ApiVersion $ApiVersion If ($teamSettings.BacklogIteration.Path) { $targetBacklogIteration = Get-APNode @targetSplat -Project $targetProject -Path $teamSettings.BacklogIteration.Path -ApiVersion 6.0 -StructureGroup 'Iterations' } If ($teamSettings.DefaultIteration.Path) { $targetDefaultIteration = Get-APNode @targetSplat -Project $targetProject -Path $teamSettings.DefaultIteration.Path -ApiVersion 6.0 -StructureGroup 'Iterations' } If ($teamSettings.DefaultIterationMacro) { $newTeamSettings = Update-APTeamSettings @targetSplat -Project $TargetProject -ApiVersion $TargetApiVersion -TeamId $newTeam.Id -BacklogIteration $targetBacklogIteration.identifier -DefaultIterationMacro $teamSettings.DefaultIterationMacro -BugsBehavior $teamSettings.BugsBehavior -BacklogVisibilities $teamSettings.BacklogVisibilities -WorkingDays $teamSettings.WorkingDays } else { $newTeamSettings = Update-APTeamSettings @targetSplat -Project $TargetProject -ApiVersion $TargetApiVersion -TeamId $newTeam.Id -BacklogIteration $targetBacklogIteration.identifier -DefaultIteration $targetDefaultIteration.identifier -BugsBehavior $teamSettings.BugsBehavior -BacklogVisibilities $teamSettings.BacklogVisibilities -WorkingDays $teamSettings.WorkingDays } $results.settings = $newTeamSettings } If (-not($ExcludeTeamFields.IsPresent)) { $teamFieldValues = Get-APTeamFieldValues @sourceSplat -TeamId $team.Id -ApiVersion $ApiVersion If ($teamFieldValues.DefaultValue) { $defaultValueSplit = $teamFieldValues.DefaultValue.split('\') $newTeamFieldDefaultValue = "{0}\{1}" -f $defaultValueSplit[0].Replace("$Project", "$TargetProject"), ($defaultValueSplit[1..$($defaultValueSplit.count)] -join '\') $results.defaultValue = $newTeamFieldDefaultValue } If ($teamFieldValues.values) { [array] $newTeamFieldValues = Foreach ($value in $teamFieldValues.values) { $split = $value.value.split('\') @{ value = ("{0}\{1}" -f $split[0].Replace("$Project", "$TargetProject"), ($split[1..$($split.count)] -join '\')) includeChildren = $value.includeChildren } } $newTeamFields = Update-APTeamFieldValues @targetSplat -Project $TargetProject -ApiVersion $TargetApiVersion -TeamId $newTeam.Id -DefaultValue $newTeamFieldDefaultValue -Values $newTeamFieldValues $results.values = $newTeamFields } } If (-not($ExcludeTeamMembers.IsPresent)) { # Locked to a working 5.1 version $newTeamIdentity = Get-APTeam @targetSplat -Project $TargetProject -ApiVersion '5.1' -TeamId $newTeam.Id -ExpandIdentity $true $newTeamMembers = Get-APTeamMembers @sourceSplat -TeamId $team.Id -ApiVersion '5.1' $membersAdded = Foreach ($member in $newTeamMembers) { # Locked to a preview version Add-APGroupMembership @targetSplat -ContainerDescriptor $newTeamIdentity.identity.subjectDescriptor -SubjectDescriptor $member.identity.descriptor -ApiVersion '5.1-preview.1' } If ($membersAdded) { $results.membersAdded = $true } } Write-Output $results } } end { } } # Find-APPSModule.ps1 function Find-APPSModule { <# .SYNOPSIS Finds a module from an Azure Pipelines feed. .DESCRIPTION Finds a module from an Azure Pipelines feed using the personal access token from the session configuration. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name pecifies the names of modules to search for in the repository. A comma-separated list of module names is accepted. Wildcards are accepted. .PARAMETER Repository Use the Repository parameter to specify which repository is used to download and install a module. Used when multiple repositories are registered. Specifies the name of a registered repository in the Install-APPSModule command. To register a repository, use Register-APPSRepository. To display registered repositories, use Get-PSRepository. .PARAMETER RequiredVersion Specifies the exact version of a single module to install. If there is no match in the repository for the specified version, an error is displayed. If you want to install multiple modules, you cannot use RequiredVersion. .PARAMETER AllVersions Specifies to include all versions of a module in the results. You cannot use the AllVersions parameter with the RequiredVersion parameters. .PARAMETER AllowPrerelease Includes in the results modules marked as a pre-release. .PARAMETER Command Specifies an array of commands to find in modules. A command can be a function or workflow. .PARAMETER DscResource Specifies the name, or part of the name, of modules that contain DSC resources. Per PowerShell conventions, performs an OR search when you provide multiple arguments. .PARAMETER Filter Specifies a filter based on the PackageManagement provider-specific search syntax. For NuGet modules, this parameter is the equivalent of searching by using the Search bar on the PowerShell Gallery website. .PARAMETER IncludeDependencies Indicates that this operation includes all modules that are dependent upon the module specified in the Name parameter. .PARAMETER AllVersions Specifies to include all versions of a module in the results. You cannot use the AllVersions parameter with the MinimumVersion, MaximumVersion, or RequiredVersion parameters. .PARAMETER MaximumVersion Specifies the maximum, or latest, version of the module to include in the search results. MaximumVersion and RequiredVersion cannot be used in the same command. .PARAMETER MinimumVersion Specifies the minimum version of the module to include in results. MinimumVersion and RequiredVersion cannot be used in the same command. .PARAMETER Tag Specifies an array of tags. Example tags include DesiredStateConfiguration, DSC, DSCResourceKit, or PSModule. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines Module. .EXAMPLE .LINK https://docs.microsoft.com/en-us/powershell/module/powershellget/install-module?view=powershell-6 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string[]] $Name, [Parameter()] [string[]] $Repository, [Parameter()] [string] $RequiredVersion, [Parameter()] [switch] $AllVersions, [Parameter()] [switch] $AllowPrerelease, [Parameter()] [string] $Command, [Parameter()] [string] $DscResource, [Parameter()] [string] $Filter, [Parameter()] [switch] $IncludeDependencies, [Parameter()] [string] $MaximumVersion, [Parameter()] [string] $MinimumVersion, [Parameter()] [string[]] $Tag ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential } } } process { If ($PersonalAccessToken) { $Credential = [pscredential]::new('NA', $PersonalAccessToken) } $findModuleSplat = @{ Name = $Name Credential = $Credential } If ($Repository) { $findModuleSplat.Repository = $Repository } If ($Filter) { $findModuleSplat.Filter = $Filter } If ($IncludeDependencies) { $findModuleSplat.IncludeDependencies = $IncludeDependencies } If ($AllVersions) { $findModuleSplat.AllVersions = $AllVersions } If ($AllowPrerelease) { $findModuleSplat.AllowPrerelease = $AllowPrerelease } If ($Proxy) { $findModuleSplat.Proxy = $Proxy } If ($ProxyCredential) { $findModuleSplat.ProxyCredential = $ProxyCredential } If ($Command) { $findModuleSplat.Command = $Command } If ($RequiredVersion) { $findModuleSplat.RequiredVersion = $RequiredVersion } If ($MinimumVersion) { $findModuleSplat.MinimumVersion = $MinimumVersion } If ($MaximumVersion) { $findModuleSplat.MaximumVersion = $MaximumVersion } If ($DscResource) { $findModuleSplat.DscResource = $DscResource } If ($Tag) { $findModuleSplat.Tag = $Tag } Find-Module @findModuleSplat } end { } } # Format-APTemplate.ps1 Function Format-APTemplate { <# .SYNOPSIS Replaces tokens in a json template. .DESCRIPTION Replaces tokens in a json template. The json template tokens should be unique strings like '%Project%' or '__Collection__'. By passing key value pairs with the InputObject parameter @{'%Project% = 'myProject'} the tokens will be replaced with the values. Templates can be created by using Get-APBuildDefinition or Get-APReleaseDefinition and tokenizing it. .PARAMETER Path Path to the build/release json template that contains tokens. .PARAMETER InputObject Object, that contains key value pairs for token replacement. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build/release template. Pass the template to Publish-APBuild or Publish-APRelease. .EXAMPLE Replaces all instances of '%Project%' with 'myProject' for the input object. $inputObject = @{ %Project% = 'myProject' } Format-APTemplate -Path '.\myTemplate.json' -InputObject $inputObject #> Param ( [Parameter(Mandatory)] [string] $Path, [Parameter(Mandatory)] [object] $InputObject ) Begin { } Process { $templateJson = Get-Content -Path $Path -Raw $InputObject.Keys | ForEach-Object -Process { $templateJson = $templateJson -replace $_, $InputObject.Item($_) } ConvertFrom-Json -Inputobject $templateJson } } # Get-APAccessControlListList.ps1 function Get-APAccessControlListList { <# .SYNOPSIS Returns a list of access control lists. .DESCRIPTION Returns a list of access control lists based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SecurityNamespaceId Security namespace identifier. .PARAMETER Token Security token. .PARAMETER Descriptors An optional filter string containing a list of identity descriptors separated by ',' whose ACEs should be retrieved. If this is left null, entire ACLs will be returned. .PARAMETER IncludeExtendedInfo If true, populate the extended information properties for the access control entries contained in the returned lists. .PARAMETER Recurse If true and this is a hierarchical namespace, return child ACLs of the specified token. .PARAMETER Token .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines security namespace(s) .EXAMPLE Returns all access control lists Get-APBuildList -Session 'mySession' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20lists/query?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SecurityNamespaceId, [Parameter()] [string] $Token, [Parameter()] [string] $Descriptors, [Parameter()] [bool] $IncludeExtendedInfo, [Parameter()] [bool] $Recurse ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'accesscontrollists-securityNamespaceId') -f $SecurityNamespaceId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APAgent.ps1 function Get-APAgent { <# .SYNOPSIS Returns Azure Pipeline agent. .DESCRIPTION Returns Azure Pipeline agent based by agent id and pool id. The agent id can be retrieved by using Get-APAgentList. The pool id can be retrieved by using Get-APPoolList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PoolId The id of the pool. .PARAMETER AgentId The id of the agent. .PARAMETER IncludeAssignedRequest Whether to include details about the agents' current work .PARAMETER IncludeCapabilities Whether to include the agents' capabilities in the response .PARAMETER IncludeLastCompletedRequest Whether to include details about the agents' most recent completed work .PARAMETER PropertyFilters Filter which custom properties will be returned .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines agent(s). .EXAMPLE Returns the agent with the id of '7' for the 'myCollection. Get-APAgent -Instance 'https://dev.azure.com' -Collection 'myCollection' -AgentId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/agents/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PoolId, [Parameter(Mandatory)] [int] $AgentId, [Parameter()] [bool] $IncludeAssignedRequest, [Parameter()] [bool] $IncludeCapabilities, [Parameter()] [bool] $IncludeLastCompletedRequest, [Parameter()] [string[]] $PropertyFilters ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'agent-agentId') -f $PoolId, $AgentId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APAgentList.ps1 function Get-APAgentList { <# .SYNOPSIS Returns a list of Azure Pipeline agents. .DESCRIPTION Returns Azure Pipeline agent list based by pool id. The pool id can be retrieved by using Get-APPoolList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PoolId The id of the pool. .PARAMETER AgentName The name of the agent to filter by. .PARAMETER Demands The type of agent to filter by. .PARAMETER IncludeAssignedRequest Whether to include details about the agents' current work .PARAMETER IncludeCapabilities Whether to include the agents' capabilities in the response .PARAMETER IncludeLastCompletedRequest Whether to include details about the agents' most recent completed work .PARAMETER PropertyFilters Filter which custom properties will be returned .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines agent(s) .EXAMPLE Returns AP agent list for 'myCollection' Get-APAgentList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/agents/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PoolId, [Parameter()] [string] $AgentName, [Parameter()] [string[]] $Demands, [Parameter()] [bool] $IncludeAssignedRequest, [Parameter()] [bool] $IncludeCapabilities, [Parameter()] [bool] $IncludeLastCompletedRequest, [Parameter()] [string[]] $PropertyFilters ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'agent-agents') -f $PoolId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APApiVersion.ps1 function Get-APApiVersion { <# .SYNOPSIS Returns the api version available for the TFS version provided. .DESCRIPTION Returns the api version available for the TFS version provided. .PARAMETER Version TFS version, this will provide the module with the api version mappings. .OUTPUTS String, The api version available for the TFS version provided. .EXAMPLE Returns the APApiVersion for 'vNext' Get-APApiVersion -Version 'vNext' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.0&viewFallbackFrom=vsts-rest-5.0#api-and-tfs-version-mapping #> [CmdletBinding()] Param ( [Parameter()] [string] $Version ) begin { } process { Switch ($Version) { 'vNext' { return '5.0-preview' } '2018 Update 2' { return '4.0-preview' } '2018 RTW' { return '4.0' } '2017 Update 2' { return '3.2' } '2017 Update 1' { return '3.1' } '2017 RTW' { return '3.0' } '2015 Update 4' { return '2.3' } '2015 Update 3' { return '2.3' } '2015 Update 2' { return '2.2' } '2015 Update 1' { return '2.1' } '2015 RTW' { return '2.0' } default { Write-Error "[$($MyInvocation.MyCommand.Name)]: [$Version] is not supported, run 'Save-APSession -Version' to populate module data. " -ErrorAction Stop } } } end { } } # Get-APApprovalList.ps1 function Get-APApprovalList { <# .SYNOPSIS Returns a list of Azure Pipeline approvals. .DESCRIPTION Returns a list of Azure Pipeline approvals based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER AssignedToFilter Approvals assigned to this user. .PARAMETER StatusFilter Approvals with this status. Default is 'pending'. .PARAMETER ReleaseIdsFilter Approvals for release id(s) mentioned in the filter. Multiple releases can be mentioned by separating them with ',' e.g. releaseIdsFilter=1,2,3,4. .PARAMETER TypeFilter Approval with this type. .PARAMETER Top Number of approvals to get. Default is 50. .PARAMETER ContinuationToken Gets the approvals after the continuation token provided. .PARAMETER QueryOrder Gets the results in the defined order of created approvals. Default is 'descending'. .PARAMETER IncludeMyGroupApprovals 'true' to include my group approvals. Default is 'false'. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines approval(s) .EXAMPLE Returns an AP approval list for the current user in the 'myFirstProject'. Get-APApprovalList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/approvals/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $AssignedToFilter, [Parameter()] [ValidateSet('approved', 'canceled', 'pending', 'reassigned', 'rejected', 'skipped', 'undefined')] [string[]] $StatusFilter, [Parameter()] [string[]] $ReleaseIdsFilter, [Parameter()] [ValidateSet('all', 'postDeploy', 'preDeploy', 'undefined')] [string] $TypeFilter, [Parameter()] [int] $Top, [Parameter()] [int] $ContinuationToken, [Parameter()] [ValidateSet('ascending', 'descending')] [string] $QueryOrder, [Parameter()] [bool] $IncludeMyGroupApprovals ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'release-approvals' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APApprovalList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBoard.ps1 function Get-APBoard { <# .SYNOPSIS Returns Azure Pipeline board. .DESCRIPTION Returns Azure Pipeline board by board id. The id can be retrieved by using Get-APBoardList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Team The name of the team. .PARAMETER BoardId The id of the board. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines board(s). .EXAMPLE Returns a board from the project 'myFirstProject' with the id of '7'. Get-APBoard -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 6.1-preview -BoardId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/boards/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Team, [Parameter(Mandatory)] [string] $BoardId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-boardId') -f $Team, $BoardId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBoardList.ps1 function Get-APBoardList { <# .SYNOPSIS Returns a list of Azure Pipeline board(s). .DESCRIPTION Returns a list of Azure Pipeline board(s). .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Team The name of the team. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines board(s). .EXAMPLE Tetruns a list of Azure Pipelines boards for 'myFirstProject' Get-APBoardList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/boards/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Team ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-boards') -f $Team $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuild.ps1 function Get-APBuild { <# .SYNOPSIS Returns Azure Pipeline build. .DESCRIPTION Returns Azure Pipeline build based by build id. The id can be retrieved by using Get-APBuildList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BuildId The id of the build. .PARAMETER PropertyFilters Undocumented .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s). .EXAMPLE Returns the build with the id of '7' for the 'myFirstProject. Get-APBuild -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 7 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $BuildId, [Parameter()] [string] $PropertyFilters ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-buildId') -f $BuildId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildArtifactList.ps1 function Get-APBuildArtifactList { <# .SYNOPSIS Returns a list of Azure Pipeline artifacts. .DESCRIPTION Returns a list of Azure Pipeline artifacts based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BuildId The id of the build. .PARAMETER ArtifactName The name of the artifact. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines artifact(s) .EXAMPLE Returns AP artifact list for 'myFirstProject' Get-APArtifactList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId '1' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/artifacts/get?view=azure-devops-rest-4.1#buildartifact #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $BuildId, [Parameter()] [string] $ArtifactName ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-artifacts') -f $BuildId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildDefinition.ps1 function Get-APBuildDefinition { <# .SYNOPSIS Returns Azure Pipeline build definitions. .DESCRIPTION Returns Azure Pipeline build definitions by definition id. The id can be retrieved by using Get-APBuildDefinitionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionID The ID of the definition. .PARAMETER Revision The revision number to retrieve. If this is not specified, the latest version will be returned. .PARAMETER MinMetricsTime If specified, indicates the date from which metrics should be included. .PARAMETER PropertyFilters A comma-delimited list of properties to include in the results. .PARAMETER IncludeLatestBuilds Indicates whether to include or exclude the latest builds. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns the build definition with the definition id of '7' for 'myFirstProject'. Get-APBuild -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionID 7 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/definitions/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DefinitionID, [Parameter()] [int] $Revision, [Parameter()] [datetime] $MinMetricsTime, [Parameter()] [string[]] $PropertyFilters, [Parameter()] [switch] $IncludeLatestBuilds ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-definitionId') -f $DefinitionID $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildDefinitionList.ps1 function Get-APBuildDefinitionList { <# .SYNOPSIS Returns a list of Azure Pipeline build definitions. .DESCRIPTION Returns a list of Azure Pipeline build definitions based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TaskIdFilter If specified, filters to definitions that use the specified task. .PARAMETER IncludeLatestBuilds Indicates whether to return the latest and latest completed builds for this definition. .PARAMETER IncludeAllProperties Indicates whether to return the latest and latest completed builds for this definition. .PARAMETER NotBuiltAfter If specified, filters to definitions that do not have builds after this date. .PARAMETER BuiltAfter If specified, filters to definitions that have builds after this date. .PARAMETER Path If specified, filters to definitions under this folder. .PARAMETER DefinitionIds A comma-delimited list that specifies the IDs of definitions to retrieve. .PARAMETER MinMetricsTime If specified, indicates the date from which metrics should be included. .PARAMETER ContinuationToken A continuation token, returned by a previous call to this method, that can be used to return the next set of definitions. .PARAMETER Top The maximum number of definitions to return. .PARAMETER QueryOrder Indicates the order in which definitions should be returned. .PARAMETER RepositoryType If specified, filters to definitions that have a repository of this type. .PARAMETER RepositoryId A repository ID. If specified, filters to definitions that use this repository. .PARAMETER Name If specified, filters to definitions whose names match this pattern. .PARAMETER YamlFilename If specified, filters to YAML definitions that match the given filename. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns the AP build definition list for 'myFirstProject'. Get-APBuildDefinitionList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/definitions/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $TaskIdFilter, [Parameter()] [bool] $IncludeLatestBuilds, [Parameter()] [bool] $IncludeAllProperties, [Parameter()] [datetime] $NotBuiltAfter, [Parameter()] [datetime] $BuiltAfter, [Parameter()] [string] $Path, [Parameter()] [int[]] $DefinitionIds, [Parameter()] [datetime] $MinMetricsTime, [Parameter()] [string] $ContinuationToken, [Parameter()] [int] $Top, [Parameter()] [string] [ValidateSet('ascending', 'descending')] $QueryOrder, [Parameter()] [string] $RepositoryType, [Parameter()] [string] $RepositoryId, [Parameter()] [string] $Name, [Parameter()] [string] $YamlFilename ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'build-definitions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APBuildDefinitionList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildLease.ps1 function Get-APBuildLease { <# .SYNOPSIS Returns Azure Pipeline build lease. .DESCRIPTION Returns Azure Pipeline build lease based by build lease id. The id can be retrieved by using Get-APBuildLeaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER LeaseId The id of the build lease. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build lease(s). .EXAMPLE Returns the build lease with the id of '7' for the 'myFirstProject. Get-APBuildLease -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -LeaseId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/leases/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $LeaseId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-leaseId') -f $LeaseId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildLeaseList.ps1 function Get-APBuildLeaseList { <# .SYNOPSIS Returns a list of Azure Pipeline build leases. .DESCRIPTION Returns a list of Azure Pipeline build leases based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionId The pipeline definition. .PARAMETER OwnerId Undocumented. .PARAMETER RunId The pipeline run. Requires definition id. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build lease(s) .EXAMPLE Returns AP build lease list for 'myFirstProject' Get-APBuildLeaseList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/leases/get%20retention%20leases%20by%20owner%20id?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $DefinitionId, [Parameter()] [string] $OwnerId, [Parameter()] [int] $RunId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'build-leases' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildList.ps1 function Get-APBuildList { <# .SYNOPSIS Returns a list of Azure Pipeline builds. .DESCRIPTION Returns a list of Azure Pipeline builds based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId If specified, filters to builds that built from this repository. .PARAMETER BuildIds A comma-delimited list that specifies the IDs of builds to retrieve. .PARAMETER BranchName If specified, filters to builds that built branches that built this branch. .PARAMETER QueryOrder The order in which builds should be returned. .PARAMETER DeletedFilter Indicates whether to exclude, include, or only return deleted builds. .PARAMETER MaxBuildsPerDefinition The maximum number of builds to return per definition. .PARAMETER ContinuationToken A continuation token, returned by a previous call to this method, that can be used to return the next set of builds. .PARAMETER Top The maximum number of builds to return. .PARAMETER Properties A comma-delimited list of properties to retrieve. .PARAMETER TagFilters A comma-delimited list of tags. If specified, filters to builds that have the specified tags. .PARAMETER ResultFilter If specified, filters to builds that match this result. .PARAMETER StatusFilter If specified, filters to builds that match this status. .PARAMETER ReasonFilter If specified, filters to builds that match this reason. .PARAMETER RequestedFor If specified, filters to builds requested for the specified user. .PARAMETER MaxTime If specified, filters to builds requested for the specified user. .PARAMETER MinTime If specified, filters to builds that finished/started/queued after this date based on the queryOrder specified. .PARAMETER BuildNumber If specified, filters to builds that match this build number. Append * to do a prefix search. .PARAMETER Queues A comma-delimited list of queue IDs. If specified, filters to builds that ran against these queues. .PARAMETER Definitions A comma-delimited list of definition IDs. If specified, filters to builds for these definitions. .PARAMETER RepositoryType If specified, filters to builds that built from repositories of this type. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP build list for 'myFirstProject' Get-APBuildList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/list?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $RepositoryId, [Parameter()] [int[]] $BuildIds, [Parameter()] [string] $BranchName, [Parameter()] [string] [ValidateSet('finishTimeAscending', 'finishTimeDescending', 'queueTimeAscending', 'queueTimeDescending', 'startTimeAscending', 'startTimeDescending')] $QueryOrder, [Parameter()] [ValidateSet('excludeDeleted', 'includeDeleted', 'onlyDeleted')] [string] $DeletedFilter, [Parameter()] [int] $MaxBuildsPerDefinition, [Parameter()] [string] $ContinuationToken, [Parameter()] [int] $Top, [Parameter()] [string[]] $Properties, [Parameter()] [string[]] $TagFilters, [Parameter()] [ValidateSet('canceled', 'failed', 'none', 'partiallySucceeded', 'succeeded')] [string] $ResultFilter, [Parameter()] [ValidateSet('all', 'cancelling', 'completed', 'inProgress', 'none', 'notStarted', 'postponed')] [string] $StatusFilter, [Parameter()] [ValidateSet('all', 'batchedCI', 'buildCompletion', 'checkInShelveset', 'individualCI', 'manual', 'none', 'pullRequest', 'schedule', 'triggered', 'userCreated', 'validateShelveset')] [string] $ReasonFilter, [Parameter()] [string] $RequestedFor, [Parameter()] [datetime] $MaxTime, [Parameter()] [datetime] $MinTime, [Parameter()] [string] $BuildNumber, [Parameter()] [int[]] $Queues, [Parameter()] [int[]] $Definitions, [Parameter()] [string] $RepositoryType ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'build-builds' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APBuildList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildTimeline.ps1 function Get-APBuildTimeline { <# .SYNOPSIS Returns Azure Pipeline build timeline. .DESCRIPTION Returns Azure Pipeline build timeline by build and timeline id. The build id can be retrieved by using Get-APBuildList. The timeline id can be retrieved by using Get-APBuildList under orchestrationPlan.planId. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BuildId The id of the build. .PARAMETER TimelineId The id of the timeline. .PARAMETER ChangeId Undocumented. .PARAMETER PlanId Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s). .EXAMPLE Returns the build timeline with the id of '7' for the 'myFirstProject. Get-APBuildTimeline -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 7 -TimelineId xxxxx-xxxxx-xxxx-xxxxx .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/timeline/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $BuildId, [Parameter(Mandatory)] [string] $TimelineId, [Parameter()] [string] $ChangeId, [Parameter()] [string] $PlanId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-timelineId') -f $BuildId, $TimelineId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APBuildWorkItemList.ps1 function Get-APBuildWorkItemList { <# .SYNOPSIS Returns a list of Azure Pipeline work items associated with a build. .DESCRIPTION Returns a list of Azure Pipeline work items associated with a build based on a build id. The id can be retrieved by using Get-APBuildList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BuildId The id of the build. .PARAMETER Top Number of work items to return. Defaults to 50. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s). .EXAMPLE Returns the work items associated with the build that has the id of '7' for the 'myFirstProject. Get-APBuildWorkItemList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/get-build-work-items-refs?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $BuildId, [Parameter()] [string] $Top ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-workitems') -f $BuildId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDashboard.ps1 function Get-APDashboard { <# .SYNOPSIS Returns Azure Pipeline dashboard. .DESCRIPTION Returns Azure Pipeline dashboard by dashboard id. The id can be retrieved by using Get-APDashboardList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DashboardId The id of the dashboard. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines dashboard(s). .EXAMPLE Returns a dashboard from the project 'myFirstProject' with the id of '7'. Get-APDashboard -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 6.1-preview -DashboardId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/dashboards/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $DashboardId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'dashboard-dashboardId') -f $DashboardId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDashboardList.ps1 function Get-APDashboardList { <# .SYNOPSIS Returns a list of Azure Pipeline dashboard(s). .DESCRIPTION Returns a list of Azure Pipeline dashboard(s). .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines dashboard(s). .EXAMPLE Tetruns a list of Azure Pipelines dashboards for 'myFirstProject' Get-APDashboardList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/dashboards/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'dashboard-dashboards' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDeletedRepository.ps1 function Get-APDeletedRepository { <# .SYNOPSIS Returns a deleted git repository. .DESCRIPTION Returns a deleted git repository based a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines git repository. .EXAMPLE Returns a list of deleted git repositories. Get-APDeletedRepository -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/repositories/get%20deleted%20repositories?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'git-deletedrepositories' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDeploymentGroup.ps1 function Get-APDeploymentGroup { <# .SYNOPSIS Returns Azure Pipeline deployment group. .DESCRIPTION Returns Azure Pipeline deployment group by deployment group id. The deployment group id can be retrieved by using Get-APDeploymentGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment group. .PARAMETER ActionFilter Get the deployment group only if this action can be performed on it. .PARAMETER Expand Include these additional details in the returned objects. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines deployment group. .EXAMPLE Returns AP deployment group with the deployment group id of '6' for 'myFirstProject'. Get-APDeploymentGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/deploymentgroups/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupID, [Parameter()] [ValidateSet('manage', 'none', 'use')] [string] $ActionFilter, [Parameter()] [ValidateSet('machines', 'none', 'tags')] [string] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-deploymentGroupId') -f $DeploymentGroupID $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDeploymentGroupList.ps1 function Get-APDeploymentGroupList { <# .SYNOPSIS Returns a list of Azure Pipeline deployment groups. .DESCRIPTION Returns a list of Azure Pipeline deployment groups based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name Name of the deployment group. .PARAMETER ActionFilter Get the deployment group only if this action can be performed on it. .PARAMETER Expand Include these additional details in the returned objects. .PARAMETER Top Maximum number of deployment groups to return. Default is 1000. .PARAMETER Ids Comma separated list of IDs of the deployment groups. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines deployment group. .EXAMPLE Returns AP deployment group list for 'myFirstProject'. Get-APDeploymentGroupList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .EXAMPLE Returns AP deployment group with the name 'Dev' for 'myFirstProject'. Get-APDeploymentGroupList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Name Dev .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/deploymentgroups/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Name, [Parameter()] [ValidateSet('manage', 'none', 'use')] [string] $ActionFilter, [Parameter()] [ValidateSet('machines', 'none', 'tags')] [string] $Expand, [Parameter()] [int] $Top, [Parameter()] [int[]] $Ids ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-deploymentgroups' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDeploymentList.ps1 function Get-APDeploymentList { <# .SYNOPSIS Returns a list of Azure Pipeline deployments. .DESCRIPTION Returns a list of Azure Pipeline deployments based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER MaxStartedTime Deployments with max started time by will be returned. .PARAMETER MinStartedTime Deployments with min started time by will be returned. .PARAMETER CreatedFor Deployments with created for by will be returned. .PARAMETER ContinuationToken Gets the releases after the continuation token provided. .PARAMETER Top Number of deployments to return. Default is 50. .PARAMETER QueryOrder The order in which to return the query in. .PARAMETER LatestAttemptsOnly The latest attempt for stage will be returned. .PARAMETER OperationStatus Deployments with the operation status by will be returned. .PARAMETER DeploymentStatus Deployments with deployment status by will be returned. .PARAMETER MaxModifiedTime Deployments with max modified time by will be returned. .PARAMETER MinModifiedTime Deployments with min modified time by will be returned. .PARAMETER CreatedBy Deployments with given created by will be returned. .PARAMETER DefinitionEnvironmentId Undefined, see link for documentation .PARAMETER DefinitionId Deployments from this release definition Id. .PARAMETER SourceBranch Deployments with given source branch will be returned. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release(s) .EXAMPLE Returns AP release list for 'myFirstProject'. Get-APDeploymentList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/release/releases/list?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $MaxStartedTime, [Parameter()] [string] $MinStartedTime, [Parameter()] [string] $CreatedFor, [Parameter()] [int] $ContinuationToken, [Parameter()] [int] $Top, [Parameter()] [string] [ValidateSet('ascending', 'descending')] $QueryOrder, [Parameter()] [bool] $LatestAttemptsOnly, [Parameter()] [ValidateSet('all', 'approved', 'canceled', 'deferred', 'gateFailed', 'manualInterventionPending', 'pending', 'phaseCanceled', 'phaseFailed', 'phaseInProgress', 'phasePartiallySucceeded', 'phasedSucceeded', 'queued', 'queuedForAgent', 'queuedForPipeline', 'rejected', 'scheduled', 'undefined')] [string] $OperationStatus, [Parameter()] [ValidateSet('all', 'failed', 'inProgress', 'notDeployed', 'partiallySucceeded', 'succeeded', 'undefined')] [string] $DeploymentStatus, [Parameter()] [string] $MaxModifiedTime, [Parameter()] [string] $MinModifiedTime, [Parameter()] [string] $CreatedBy, [Parameter()] [int] $DefinitionEnvironmentId, [Parameter()] [int] $DefinitionId, [Parameter()] [string] $SourceBranch ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'release-deployments' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APDeploymentList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APDescriptor.ps1 function Get-APDescriptor { <# .SYNOPSIS Resolve a storage key to a descriptor. .DESCRIPTION Resolve a storage key to a descriptor. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER StorageKey Storage key of the subject (user, group, scope, etc.) to resolve. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns a subject descriptor of a Graph entity. Get-APDescriptor -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview -StorageKey '16c8b591-362d-4d7f-b77b-b04c2f110c52' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/descriptors/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $StorageKey ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-descriptorStorageKey') -f $StorageKey $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APEnvironment.ps1 function Get-APEnvironment { <# .SYNOPSIS Returns an Azure Pipeline environment. .DESCRIPTION Returns an Azure Pipeline environment by environment name. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EnvironmentId The id or name of the environment. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines environment. .EXAMPLE Returns an Azure DevOps environment named 'myEnvironment'. Get-APEnvironment -Session 'mySession' -EnvironmentId 'myEnvironment' .LINK Undocumented at the time this was created. #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EnvironmentId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-environmentId') -f $EnvironmentId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # Get-APEnvironmentList.ps1 function Get-APEnvironmentList { <# .SYNOPSIS Returns a list of Azure Pipeline environments. .DESCRIPTION Returns a list of Azure Pipeline environments. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines environment. .EXAMPLE Returns an Azure DevOps environment named 'myEnvironment'. Get-APEnvironmentList -Session 'mySession' .LINK Undocumented at the time this was created. #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-environments' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # Get-APFeed.ps1 function Get-APFeed { <# .SYNOPSIS Returns aa Azure Pipeline feed. .DESCRIPTION Returns an Azure Pipeline feed by feed id. The feed id can be retrieved by using Get-APFeedList. The feed id can be either the feed name or its guid id. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId Name or Id of the feed. .PARAMETER IncludeDeletedUpstreams Include upstreams that have been deleted in the response. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines feed .EXAMPLE Returns the AP feed with the feed id of 'myFeed'. Get-APFeed -Instance 'https://dev.azure.com' -Collection 'myCollection' -FeedId 'myFeed' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed%20%20management/get%20feed?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId, [Parameter()] [bool] $IncludeDeletedUpstreams ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-feedId') -f $FeedId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'feeds' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APFeedList.ps1 function Get-APFeedList { <# .SYNOPSIS Returns a list of Azure Pipeline feeds. .DESCRIPTION Returns a list of Azure Pipelin feeds based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedRole Filter by this role, either Administrator(4), Contributor(3), or Reader(2) level permissions. .PARAMETER IncludeDeletedUpstreams Include upstreams that have been deleted in the response. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines feed(s) .EXAMPLE Returns AP feed list for 'myCollection' Get-APFeedList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed%20%20management/get%20feeds?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [ValidateSet('administrator', 'collaborator', 'contributor', 'reader')] [string] $FeedRole, [Parameter()] [bool] $IncludeDeletedUpstreams ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'feed-feeds' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'feeds' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APField.ps1 function Get-APField { <# .SYNOPSIS Returns an Azure Pipeline field in a work item type and process. .DESCRIPTION Returns an Azure Pipeline fields in a work item type and process by field ref name. Field ref name can be retrieced by using Get-APFieldList. The process id can be retrieved by using Get-APProcessList. Work item type reference name can be retrieved by using Get-APWorkItemTypeList .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProcessId The id of the process .PARAMETER WitRefName The reference name of the work item type. .PARAMETER FieldRefName The name of the field to update. .PARAMETER Expand Process work item type fields to expand. Types: allowGroups allowedValues customization defaultValue description name readOnly referenceName required type url .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines field(s) .EXAMPLE Returns AP field for 'myCollection' Get-APFieldList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ProcessId 00000-000-000-00000-00000 -WitRefName 'Microsoft.VSTS.WorkItemTypes.Bug' -FieldRefName 'Custom.myField' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/fields/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProcessId, [Parameter(Mandatory)] [string] $WitRefName, [Parameter(Mandatory)] [string] $FieldRefName, [Parameter()] [ValidateSet('allowGroups', 'allowedValues', 'customization', 'defaultValue', 'description', 'name', 'readOnly', 'referenceName', 'required', 'type', 'url')] [string[]] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-fieldname') -f $ProcessId, $WitRefName, $FieldRefName $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APFieldList.ps1 function Get-APFieldList { <# .SYNOPSIS Returns a list of Azure Pipeline fields in a work item type and process. .DESCRIPTION Returns a list of Azure Pipeline fields in a work item type and process. The process id can be retrieved by using Get-APProcessList. Work item type reference name can be retrieved by using Get-APWorkItemTypeList .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProcessId The id of the process .PARAMETER WitRefName The reference name of the work item type. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines field(s) .EXAMPLE Returns AP field list for 'myCollection' Get-APFieldList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ProcessId 00000-000-000-00000-00000 -WitRefName 'Microsoft.VSTS.WorkItemTypes.Bug' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/fields/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProcessId, [Parameter(Mandatory)] [string] $WitRefName ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-fields') -f $ProcessId, $WitRefName $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGitCommitList.ps1 function Get-APGitCommitList { <# .SYNOPSIS Returns a list of Azure Pipeline git commits. .DESCRIPTION Returns a list of Azure Pipeline git commits based on a repository id. The repository id can be returned with Get-APRepositoryList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId Id of the repository. .PARAMETER Top Only return the top number of commits. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline(s) .EXAMPLE Returns a list of Azure Pipelines git commits for 'myFirstProject' with the repository id of 7. Get-APPipelineList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RepositoryId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get%20commits?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $RepositoryId, [Parameter()] [int] $Top ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-commits') -f $RepositoryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGitItem.ps1 function Get-APGitItem { <# .SYNOPSIS Returns item metadata and/or content for a single item. .DESCRIPTION Returns item metadata and/or content for a single item by repository id. The id can be retrieved by using Get-APRepository. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The id of the repository. .PARAMETER Path The item path. .PARAMETER ScopePath The path scope, defaults to null. .PARAMETER RecursionLevel The recursion level of this request, defaults to none. .PARAMETER IncludeContentMetadata Set to true to include content metadata, defaults to false. .PARAMETER LatestProcessedChange Set to true to include the latest changes, defaults to false. .PARAMETER Download Set to true to download the response as a file, defaults to false. .PARAMETER Format If specified, this overrides the HTTP Accept request header to return either 'json' or 'zip'. If $format is specified, then api-version should also be specified as a query parameter. .PARAMETER IncludeContent Set to true to include item content when requesting json, defaults to false. .PARAMETER ResolveLfs Set to true to resolve Git LFS pointer files to return actual content from Git LFS. Default is false. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, git item metadata .EXAMPLE Returns the root of the repository with the name of 'myRepository'. $session = Get-APSession -SessionName 'mySession' $repository = Get-APRepositoryList -Session $session | ? name -eq 'myRepository' $getAPGitItemSplat = @{ RepositoryId = $repository.Id Session = $session } Get-APGitItem @getAPGitItemSplat .EXAMPLE Returns all files and folders at the path of 'src/My.Project/myContacts' by using 'full' recursion. $session = Get-APSession -SessionName 'mySession' $repository = Get-APRepositoryList -Session $session | ? name -eq 'myRepository' $getAPGitItemSplat = @{ ScopePath = 'src/My.Project/myContacts' RecursionLevel = 'full' RepositoryId = $repository.Id Session = $session } Get-APGitItem @getAPGitItemSplat .EXAMPLE Returns the content of the powershell script 'myDeployment.ps1'. Save the output of Get-APGitItem and pass it to Out-File to save the content to a file. $session = Get-APSession -SessionName 'mySession' $repository = Get-APRepositoryList -Session $session | ? name -eq 'myRepository' $getAPGitItemSplat = @{ ScopePath = 'src/Deployment/myDeployment.ps1' RepositoryId = $repository.Id Session = $session } Get-APGitItem @getAPGitItemSplat .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId, [Parameter()] [string] $Path, [Parameter()] [string] $ScopePath, [Parameter()] [ValidateSet('full', 'none', 'oneLevel', 'oneLevelPlusNestedEmptyFolders')] [string] $RecursionLevel, [Parameter()] [bool] $IncludeContentMetadata, [Parameter()] [bool] $LatestProcessedChange, [Parameter()] [bool] $Download, [Parameter()] [string] $Format, [Parameter()] [bool] $IncludeContent, [Parameter()] [bool] $ResolveLfs ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-items') -f $RepositoryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGitPullRequestList.ps1 function Get-APGitPullRequestList { <# .SYNOPSIS Returns a list of pull requests. .DESCRIPTION Returns a list of pull requests matching a specified criteria.. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specify a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The repository ID of the pull request's target branch. .PARAMETER SearchCriteria_IncludeLinks Whether to include the _links field on the shallow references. .PARAMETER SearchCriteria_SourceRefName If set, search for pull requests from this branch. .PARAMETER SearchCriteria_SourceRepositoryId If set, search for pull requests whose source branch is in this repository. .PARAMETER SearchCriteria_TargetRefName If set, search for pull requests into this branch. .PARAMETER SearchCriteria_Status If set, search for pull requests that are in this state. Defaults to Active if unset. Acceptable values are (as of API version 5.1): abandoned : Pull request is abandoned. active : Pull request is active. all : Used in pull request search criterias to include all statuses. completed : Pull request is completed. notSet : Status not set. Default state. .PARAMETER SearchCriteria_ReviewerId If set, search for pull requests that have this identity as a reviewer. .PARAMETER SearchCriteria_CreatorId If set, search for pull requests that were created by this identity. .PARAMETER SearchCriteria_RepositoryId If set, search for pull requests whose target branch is in this repository. .PARAMETER Skip The number of pull requests to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. .PARAMETER Top The maximum number of pull requests to return. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, pull requests .EXAMPLE Returns all active pull requests for repositoryId 'e0eb12ee-83f2-4446-ac51-d067949e3a78' Get-APGitPullRequestList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RepositoryId 'e0eb12ee-83f2-4446-ac51-d067949e3a78' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests/get%20pull%20requests?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [Parameter(Mandatory, ParameterSetName = 'BySession')] [string] $RepositoryId, [Parameter()] [boolean] $SearchCriteria_IncludeLinks, [Parameter()] [string] $SearchCriteria_SourceRefName, [Parameter()] [string] $SearchCriteria_SourceRepositoryId, [Parameter()] [string] $SearchCriteria_TargetRefName, [Parameter()] [string] [ValidateSet('abandoned', 'active', 'all', 'completed', 'notSet')] $SearchCriteria_Status, [Parameter()] [string] $SearchCriteria_ReviewerId, [Parameter()] [string] $SearchCriteria_CreatorId, [Parameter()] [string] $SearchCriteria_RepositoryId, [Parameter()] [int] $Skip, [Parameter()] [int] $Top ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'git-pullRequests' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGitRefList.ps1 function Get-APGitRefList { <# .SYNOPSIS Queries the provided repository for its refs and returns them. .DESCRIPTION Queries the provided repository for its refs and returns them based on the repository id. The id can be retrieved by using Get-APRepositoryList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The name or ID of the repository. .PARAMETER Filter [optional] A filter to apply to the refs (starts with). .PARAMETER IncludeLinks [optional] Specifies if referenceLinks should be included in the result. default is false. .PARAMETER IncludeStatuses [optional] Includes up to the first 1000 commit statuses for each ref. The default value is false. .PARAMETER IncludeMyBranches [optional] Includes only branches that the user owns, the branches the user favorites, and the default branch. The default value is false. Cannot be combined with the filter parameter. .PARAMETER LatestStatusesOnly [optional] True to include only the tip commit status for each ref. This option requires includeStatuses to be true. The default value is false. .PARAMETER PeelTags [optional] Annotated tags will populate the PeeledObjectId property. default is false. .PARAMETER FilterContains [optional] A filter to apply to the refs (contains). .PARAMETER Top [optional] Maximum number of refs to return. It cannot be bigger than 1000. If it is not provided but continuationToken is, top will default to 100. .PARAMETER ContinuationToken The continuation token used for pagination. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines ref(s). .EXAMPLE Returns all the refs for a repository named 'myRepository'. Get-APGitRefList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RepositoryId 'myRepository' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId, [Parameter()] [string] $Filter, [Parameter()] [bool] $IncludeLinks, [Parameter()] [bool] $IncludeStatuses, [Parameter()] [bool] $IncludeMyBranches, [Parameter()] [bool] $LatestStatusesOnly, [Parameter()] [bool] $PeelTags, [Parameter()] [string] $FilterContains, [Parameter()] [string] $Top, [Parameter()] [string] $ContinuationToken ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-refs') -f $RepositoryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APGitRefList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGroup.ps1 function Get-APGroup { <# .SYNOPSIS Returns an Azure Pipeline group account. .DESCRIPTION Returns Azure Pipeline group account by group descriptor. The descriptor can be retrieved by using Get-APGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER GroupDescriptor The descriptor of the desired graph group. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP group with the group descriptor of 'aad.OWRjNmIjMtZjNjY3ZDQ0LWIzOTgtZmYyMTM4N2E3NGJj' for 'myCollection'. Get-APGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview -GroupDescriptor 'aad.OWRjNmIjMtZjNjY3ZDQ0LWIzOTgtZmYyMTM4N2E3NGJj' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/groups/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $GroupDescriptor ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-groupId') -f $GroupDescriptor $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGroupEntitlementsList.ps1 function Get-APGroupEntitlementsList { <# .SYNOPSIS Returns a list of Azure Pipeline group entitlements. .DESCRIPTION Returns a list of Azure Pipeline group entitlements based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns the AP group entitlements list for 'myCollection'. Get-APGroupEntitlementsList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/group%20entitlements/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'groupentitlements-entitlements' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsaex' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGroupList.ps1 function Get-APGroupList { <# .SYNOPSIS Returns a list of Azure Pipeline group accounts. .DESCRIPTION Returns a list of Azure Pipeline group accounts based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ScopeDescriptor Specify a non-default scope (collection, project) to search for groups. .PARAMETER SubjectTypes A comma separated list of user subject subtypes to reduce the retrieved results, e.g. Microsoft.IdentityModel.Claims.ClaimsIdentity .PARAMETER ContinuationToken An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP group list for 'myCollection'. Get-APGroupList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/groups/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $ScopeDescriptor, [Parameter()] [string[]] $SubjectTypes, [Parameter()] [string] $ContinuationToken ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'graph-groups' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APGroupList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGroupMembership.ps1 function Get-APGroupMembership { <# .SYNOPSIS Returns an Azure Pipeline group account membership. .DESCRIPTION Returns Azure Pipeline group account membership by group descriptor. The descriptor can be retrieved by using Get-APGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectDescriptor A descriptor to the child subject in the relationship. .PARAMETER ContainerDescriptor A descriptor to the container in the relationship. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns the group membership between the container and the subject. $group = Get-APGroupList -Session $session | Select-Object -First 1 -Skip 1 $memberList = Get-APGroupMembershipList -Session $session -SubjectDescriptor $group.descriptor -Direction down Get-APGroupMembership -Session $session -SubjectDescriptor $memberList.memberDescriptor[0] -ContainerDescriptor $memberList.containerDescriptor[0] .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/memberships/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubjectDescriptor, [Parameter(Mandatory)] [string] $ContainerDescriptor ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-containerDescriptor') -f $SubjectDescriptor, $ContainerDescriptor $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APGroupMembershipList.ps1 function Get-APGroupMembershipList { <# .SYNOPSIS Get all the memberships where this descriptor is a member in the relationship. .DESCRIPTION Get a membership relationship between a container and subject based on a filter query. Use Get-APGroup with the descriptor to identify the group name. The default value for direction is 'up' meaning return all memberships where the subject is a member (e.g. all groups the subject is a member of). Alternatively, passing the direction as 'down' will return all memberships where the subject is a container (e.g. all members of the subject group). .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectDescriptor Fetch all direct memberships of this descriptor. .PARAMETER Direction Defaults to Up. .PARAMETER Depth The maximum number of edges to traverse up or down the membership tree. Currently the only supported value is '1'. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines installed extension(s). .EXAMPLE Returns the first groups membership. $group = Get-APGroupList -Session $session | Select-Object -First 1 $memberList = Get-APGroupMembershipList -Session $session -SubjectDescriptor $group.descriptor Get-APGroup -Session $session -GroupDescriptor $memberList.memberDescriptor .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/memberships/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubjectDescriptor, [Parameter()] [ValidateSet('up', 'down', 'unknown')] [string] $Direction, [Parameter()] [string] $Depth ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-memberships') -f $SubjectDescriptor $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APInstalledExtension.ps1 function Get-APInstalledExtension { <# .SYNOPSIS Returns Azure Pipeline installed extension. .DESCRIPTION Returns Azure Pipeline installed extension by name. The name can be retrieved by using Get-APInstalledExtensionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER AssetTypes Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension(s). .EXAMPLE Returns the WindowsServiceManager extension. Get-APInstalledExtension -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter()] [string[]] $AssetTypes ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-installedextensionsbyname') -f $PublisherName, $ExtensionName $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APInstalledExtensionData.ps1 function Get-APInstalledExtensionData { <# .SYNOPSIS Returns Azure Pipeline installed extension. .DESCRIPTION Returns Azure Pipeline installed extension by name. The name can be retrieved by using Get-APInstalledExtensionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER AssetTypes Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension(s). .EXAMPLE Returns the WindowsServiceManager extension. Get-APInstalledExtension -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter()] [string[]] $AssetTypes ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-installedextensionsbyname') -f $PublisherName, $ExtensionName $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APInstalledExtensionDocument.ps1 function Get-APInstalledExtensionDocument { <# .SYNOPSIS Returns an Azure Pipeline installed extension document by id. .DESCRIPTION Returns an Azure Pipeline installed extension document by id. The extension details can be retrieved by using Get-APInstalledExtensionList. The document id can be retrieced by using Get-APInstalledExtensionDocumentList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER ScopeType The scope of where the document is stored. Can be Default or User. .PARAMETER ScopeValue The value of the scope where the document is stored. Can be Current or Me. .PARAMETER DocumentCollection The name of the document collection. .PARAMETER DocumentId The id of the document. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension document(s). .EXAMPLE Returns the WindowsServiceManager extension document. Get-APInstalledExtensionDocument -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' -Published 'MDSolutions' -ScopeType 'Default' -ScopeValue 'Current' -DocumentId 'theDocumentGuid' .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter(Mandatory)] [ValidateSet('Default', 'User')] [string] $ScopeType, [Parameter(Mandatory)] [ValidateSet('Current', 'Me')] [string] $ScopeValue, [Parameter(Mandatory)] [string] $DocumentCollection, [Parameter(Mandatory)] [string] $DocumentId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-documentId') -f $PublisherName, $ExtensionName, $ScopeType, $ScopeValue, $DocumentCollection, $DocumentId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APInstalledExtensionDocumentList.ps1 function Get-APInstalledExtensionDocumentList { <# .SYNOPSIS Returns a list of Azure Pipeline installed extension documents. .DESCRIPTION Returns a list of Azure Pipeline installed extension documents. The extension details can be retrieved by using Get-APInstalledExtensionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER ScopeType The scope of where the document is stored. Can be Default or User. .PARAMETER ScopeValue The value of the scope where the document is stored. Can be Current or Me. .PARAMETER DocumentCollection The name of the document collection. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension document(s). .EXAMPLE Returns the WindowsServiceManager extension document list. Get-APInstalledExtensionDocumentList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' -Published 'MDSolutions' -ScopeType 'Default' -ScopeValue 'Current' .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter(Mandatory)] [ValidateSet('Default', 'User')] [string] $ScopeType, [Parameter(Mandatory)] [ValidateSet('Current', 'Me')] [string] $ScopeValue, [Parameter(Mandatory)] [string] $DocumentCollection ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-collection') -f $PublisherName, $ExtensionName, $ScopeType, $ScopeValue, $DocumentCollection $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APInstalledExtensionList.ps1 function Get-APInstalledExtensionList { <# .SYNOPSIS Returns a list of Azure Pipeline installed extensions. .DESCRIPTION Returns a list of Azure Pipeline installed extensions based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER IncludeDisabledExtensions If true (the default), include disabled extensions in the results. .PARAMETER IncludeErrors If true, include installed extensions with errors. .PARAMETER AssetTypes Undocumented. .PARAMETER IncludeInstallationIssues Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines installed extension(s). .EXAMPLE Returns AP installed extension list for 'myCollection' Get-APInstalledExtensionList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [bool] $IncludeDisabledExtensions, [Parameter()] [string[]] $AssetTypes, [Parameter()] [bool] $IncludeInstallationIssues ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'extensionmanagement-installedextensions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APList.ps1 function Get-APList { <# .SYNOPSIS Returns an Azure Pipeline list with a list id. .DESCRIPTION Returns an Azure Pipeline list with a list id. The list id can be retrieved by using Get-APListList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ListId The id of the list .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines list(s) .EXAMPLE Returns AP list for 'myCollection'. Get-APList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ListId 00000-000-000-00000-00000 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/lists/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ListId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-listId') -f $ListId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APListList.ps1 function Get-APListList { <# .SYNOPSIS Returns a list of Azure Pipeline's lists. .DESCRIPTION Returns a list of Azure Pipeline's lists. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines process(es) .EXAMPLE Returns AP list of lists for 'myCollection' Get-APListList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/lists/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'work-lists' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APNode.ps1 function Get-APNode { <# .SYNOPSIS Returns an Azure Pipeline node by structure group and path. .DESCRIPTION Returns an Azure Pipeline node by structure group and path. Reutrn the structure group and path with Get-APNodeList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER StructureGroup Structure group of the classification node. Options are areas or iterations. .PARAMETER Path Path of the classification node. .PARAMETER Depth Depth of the children to fetch. Do not include the name of the project or structure group in the path. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Returns AP node at the path of '\myProject\Area\Retrospectives\Team1'. When querying by path remember to remove the \Project\Area or \Project\Iteration section. Get-APNode -Session $session -StructureGroup 'areas' -Path '\Retrospectives\Team1' -Verbose -ov node .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [ValidateSet('areas', 'iterations')] [string] $StructureGroup, [Parameter()] [string] $Path, [Parameter()] [int] $Depth ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-path') -f $StructureGroup, $Path $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APNodeList.ps1 function Get-APNodeList { <# .SYNOPSIS Returns a list of Azure Pipeline classification nodes for a single project. .DESCRIPTION Returns a list of Azure Pipeline classification nodes for a single project. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Ids A list of integer classification nodes ids. .PARAMETER Depth Depth of children to fetch .PARAMETER ErrorPolicy Flag to handel errors in getting some nodes. Possible options are Fail and Omit. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP node list for a project named 'myProject'. Get-APNodeList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -ApiVersion 6.0 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/get%20classification%20nodes?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int[]] $Ids, [Parameter()] [int] $Depth, [Parameter()] [ValidateSet('Fail', 'Omit')] [string] $ErrorPolicy ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'wit-classificationnodes' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APNotificationSubscription.ps1 function Get-APNotificationSubscription { <# .SYNOPSIS Get a notification subscription by its id. .DESCRIPTION Get a notification subscription by its id. The id can be retrieved with Get-APSubscriptionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubscriptionId The id of the subscription. .PARAMETER QueryFlags Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines subscription list. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/notification/subscriptions/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubscriptionId, [Parameter()] [string[]] $QueryFlags ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'notification-subscriptionId') -f $SubscriptionId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APNotificationSubscriptionList.ps1 function Get-APNotificationSubscriptionList { <# .SYNOPSIS Get a list of notification subscriptions, either by subscription IDs or by all subscriptions for a given user or group. .DESCRIPTION Get a list of notification subscriptions, either by subscription IDs or by all subscriptions for a given user or group. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TargetId User or group id. .PARAMETER Ids List of subscription ids. .PARAMETER QueryFlags Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines subscription list. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/notification/subscriptions/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $TargetId, [Parameter()] [string[]] $Ids, [Parameter()] [string[]] $QueryFlags ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'notification-subscriptions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APNotificationSubscriptionTemplateList.ps1 function Get-APNotificationSubscriptionTemplateList { <# .SYNOPSIS Get available subscription templates. .DESCRIPTION Get available subscription templates. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines subscription list. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/notification/subscriptions/get%20subscription%20templates?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'notification-subscriptionTemplates' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APOperation.ps1 function Get-APOperation { <# .SYNOPSIS Returns an Azure Pipeline operation status. .DESCRIPTION Returns an Azure Pipeline operation status. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER OperationId The id of the operation to query. .PARAMETER PluginId The id of the plugin to query. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines operation. .EXAMPLE Gets an operation with the id of 'myOperationId' Get-APOperation -Session 'mySession' -OperationId 'myOperationId' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/operations/operations/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $OperationId, [Parameter()] [string] $PluginId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'operations-operationId') -f $OperationId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # Get-APPackage.ps1 function Get-APPackage { <# .SYNOPSIS Returns an of Azure Pipeline package. .DESCRIPTION Returns an Azure Pipeline package by package id. The package id can be retrieved by using Get-APPackageList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId Name or Id of the feed. .PARAMETER PackageId The package Id (GUID Id, not the package name). .PARAMETER IncludeAllVersions True to return all versions of the package in the response. Default is false (latest version only). .PARAMETER IncludeUrls True to return REST Urls with the response. Default is True. .PARAMETER IsListed Only applicable for NuGet packages, setting it for other package types will result in a 404. If false, delisted package versions will be returned. Use this to filter the response when includeAllVersions is set to true. Default is unset (do not return delisted packages). .PARAMETER IsRelease Only applicable for Nuget packages. Use this to filter the response when includeAllVersions is set to true. Default is True (only return packages without prerelease versioning). .PARAMETER IncludeDeleted Return deleted or unpublished versions of packages in the response. Default is False. .PARAMETER IncludeDescription Return the description for every version of each package in the response. Default is False. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines package .EXAMPLE Returns AP package with the feed id of 'myFeed' and the package id 'a9522a15-4318-4f82-9d87-ed926ddb5e12'. Get-APPackage -Instance 'https://dev.azure.com' -Collection 'myCollection' -FeedId 'myFeed' -PackageId 'a9522a15-4318-4f82-9d87-ed926ddb5e12' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed%20%20management/get%20feed?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId, [Parameter(Mandatory)] [string] $PackageId, [Parameter()] [bool] $IncludeAllVersions, [Parameter()] [bool] $IncludeUrls, [Parameter()] [bool] $IsListed, [Parameter()] [bool] $IsRelease, [Parameter()] [bool] $IncludeDeleted, [Parameter()] [bool] $IncludeDescription ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-packageId') -f $FeedId, $PackageId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'feeds' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPackageList.ps1 function Get-APPackageList { <# .SYNOPSIS Returns a list of Azure Pipeline packages. .DESCRIPTION Returns a list of Azure Pipelin packages based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId Name or Id of the feed. .PARAMETER IsCached [Obsolete] Used for legacy scenarios and may be removed in future versions. .PARAMETER IncludeDeleted Return deleted or unpublished versions of packages in the response. Default is False. .PARAMETER Skip Skip the first N packages (or package versions where getTopPackageVersions=true) .PARAMETER Top Get the top N packages (or package versions where getTopPackageVersions=true) .PARAMETER IncludeDescription Return the description for every version of each package in the response. Default is False. .PARAMETER IsRelease Only applicable for Nuget packages. Use this to filter the response when includeAllVersions is set to true. Default is True (only return packages without prerelease versioning). .PARAMETER GetTopPackageVersions Changes the behavior of $top and $skip to return all versions of each package up to $top. Must be used in conjunction with includeAllVersions=true .PARAMETER IsListed Only applicable for NuGet packages, setting it for other package types will result in a 404. If false, delisted package versions will be returned. Use this to filter the response when includeAllVersions is set to true. Default is unset (do not return delisted packages). .PARAMETER IncludeAllVersions True to return all versions of the package in the response. Default is false (latest version only). .PARAMETER IncludeUrls True to return REST Urls with the response. Default is True. .PARAMETER NormalizedPackageName [Obsolete] Used for legacy scenarios and may be removed in future versions. .PARAMETER PackageNameQuery Filter to packages that contain the provided string. Characters in the string must conform to the package name constraints. .PARAMETER ProtocolType One of the supported artifact package types. .PARAMETER DirectUpstreamId Filter results to return packages from a specific upstream. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines package(s) .EXAMPLE Returns AP package list with the feed id of 'myFeed'. Get-APPackageList -Instance 'https://dev.azure.com' -Collection 'myCollection' -FeedId 'myFeed' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/artifact%20%20details/get%20packages?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId, [Parameter()] [bool] $IsCached, [Parameter()] [bool] $IncludeDeleted, [Parameter()] [int] $Skip, [Parameter()] [int] $Top, [Parameter()] [bool] $IncludeDescription, [Parameter()] [bool] $IsRelease, [Parameter()] [bool] $GetTopPackageVersions, [Parameter()] [bool] $IsListed, [Parameter()] [bool] $IncludeAllVersions, [Parameter()] [bool] $IncludeUrls, [Parameter()] [string] $NormalizedPackageName, [Parameter()] [string] $PackageNameQuery, [Parameter()] [string] $ProtocolType, [Parameter()] [string] $DirectUpstreamId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-packages') -f $FeedId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'feeds' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPermissionReport.ps1 function Get-APPermissionReport { <# .SYNOPSIS Returns a an Azure Pipeline permission report. .DESCRIPTION Returns a an Azure Pipeline permission report based on report id. The report id can be returned by Get-APPermissionReportList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReportId Id (guid) of the report to get. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines permission report(s) .EXAMPLE Returns AP permission report for 'myCollection' with the id of '7'. Get-APPermissionReportList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ReportId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/permissionsreport/permissions%20report/get?view=azure-devops-rest-6.0&viewFallbackFrom=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ReportId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'permissions-reportId') -f $ReportId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPermissionReportList.ps1 function Get-APPermissionReportList { <# .SYNOPSIS Returns a list of Azure Pipeline permission reports. .DESCRIPTION Returns a list of Azure Pipeline permission reports. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines permission report(s) .EXAMPLE Returns AP permission report list for 'myCollection'. Get-APPermissionReportList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/permissionsreport/permissions%20report/list?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'permissions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPersonalAccessTokenList.ps1 function Get-APPersonalAccessTokenList { <# .SYNOPSIS Returns a list of Azure Pipeline builds. .DESCRIPTION Returns a list of Azure Pipeline builds based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectDescriptor The descriptor of the target user. .PARAMETER PageSize The maximum number of results to return on each page. .PARAMETER ContinuationToken An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. .PARAMETER IsPublic Set to false for PAT tokens and true for SSH tokens. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP build list for 'myFirstProject' Get-APPersonalAccessTokenList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/list?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubjectDescriptor, [Parameter()] [int] $PageSize, [Parameter()] [string] $ContinuationToken, [Parameter()] [bool] $IsPublic ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'tokenadmin-subjectDescriptor') -f $SubjectDescriptor $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APPersonalAccessTokenList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPipeline.ps1 function Get-APPipeline { <# .SYNOPSIS Returns an Azure Pipeline pipeline. .DESCRIPTION Returns an Azure Pipeline pipelines based on a pipeline id. The pipeline id can be returned with Get-APPipelineList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId Id of the pipeline. .PARAMETER PipelineVersion The pipeline version. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline(s) .EXAMPLE Returns a Azure Pipeline pipeline for 'myFirstProject' with the id of '7'. Get-APPipelineList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PipelineId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $PipelineId, [Parameter()] [int] $PipelineVersion ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-pipelineId') -f $PipelineId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPipelineApproval.ps1 function Get-APPipelineApproval { <# .SYNOPSIS Returns an Azure Pipeline approval. .DESCRIPTION Returns an Azure Pipeline approval based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Expand Approval details to expand. Options are none, permissions, steps. .PARAMETER ApprovalId The id of the approval. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines approval(s) .EXAMPLE Returns an AP approval. Get-APPipelineApproval -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 6.1-preview -ApprovalId 4eg5aavx-1000-4333-ba70-67d5b15f0e .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/approvals/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [ValidateSet('none', 'permissions', 'steps')] [string] $Expand, [Parameter()] [string] $ApprovalId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-approvalId') -f $ApprovalId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results) { return $results } else { return } } end { } } # Get-APPipelineApprovalList.ps1 function Get-APPipelineApprovalList { <# .SYNOPSIS Returns a list of Azure Pipeline approvals. .DESCRIPTION Returns a list of Azure Pipeline approvals based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Expand Approval details to expand. Options are none, permissions, steps. .PARAMETER ApprovalIds The id of the approval. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines approval(s) .EXAMPLE Returns an AP approval list in the 'myFirstProject'. Get-APPipelineApprovalList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 6.1-preview -ApprovalIds 4eg5aavx-1000-4333-ba70-67d5b15f0e .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/approvals/query?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Expand, [Parameter()] [string[]] $ApprovalIds ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'pipelines-approvals' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPipelineList.ps1 function Get-APPipelineList { <# .SYNOPSIS Returns a list of Azure Pipeline pipelines. .DESCRIPTION Returns a list of Azure Pipeline pipelines based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Top The maximum number of pipelines to return. .PARAMETER ContinuationToken A continuation token from a previous request, to retrieve the next page of results .PARAMETER OrderBy A sort expression. Defaults to "name asc" .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline(s) .EXAMPLE Returns a list of Azure Pipelines' pipelines for 'myFirstProject'. Get-APPipelineList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/list?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $Top, [Parameter()] [string] $ContinuationToken, [Parameter()] [string] $OrderBy ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'pipelines' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APPipelineList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPipelineLog.ps1 function Get-APPipelineLog { <# .SYNOPSIS Returns an Azure Pipeline pipeline run log. .DESCRIPTION Returns an Azure Pipeline pipeline run log based on a pipeline id, run id and log id. The pipeline id can be returned with Get-APPipelineList. The run id can be returned with Get-APPipelineRunList. The log id can be returned with Get-APPipelineLogList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId Id of the pipeline. .PARAMETER RunId Id of the pipeline run. .PARAMETER LogId Id of the log. .PARAMETER Expand Expand options, default is none. none signedContent .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline run log(s) .EXAMPLE Returns a list of Azure Pipeline pipeline runs for 'myFirstProject' with the pipeline id of 7, the run id of 8 and the log id of 9. Get-APPipelineRunList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PipelineId 7 -RunId '8' -LogId '9' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/logs/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $PipelineId, [Parameter()] [int] $RunId, [Parameter()] [int] $LogId, [Parameter()] [ValidateSet('none', 'signedContent')] [string] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-logId') -f $PipelineId, $RunId, $LogId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.logs) { return $results.logs } else { return $results } } end { } } # Get-APPipelineLogList.ps1 function Get-APPipelineLogList { <# .SYNOPSIS Returns a list of Azure Pipeline pipeline run logs. .DESCRIPTION Returns a list of Azure Pipeline pipeline run logs based on a pipeline id and run id. The pipeline id can be returned with Get-APPipelineList. The run id can be returned with Get-APPipelineRunList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId Id of the pipeline. .PARAMETER RunId Id of the pipeline run. .PARAMETER Expand Expand options, default is none. none signedContent .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline run log(s) .EXAMPLE Returns a list of Azure Pipeline pipeline runs for 'myFirstProject' with the pipeline id of 7 and the run id of 8. Get-APPipelineRunList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PipelineId 7 -RunId 8 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/list?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $PipelineId, [Parameter()] [int] $RunId, [Parameter()] [ValidateSet('none', 'signedContent')] [string] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-logs') -f $PipelineId, $RunId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.logs) { return $results.logs } else { return $results } } end { } } # Get-APPipelinePendingApprovalList.ps1 function Get-APPipelinePendingApprovalList { <# .SYNOPSIS Returns a custom list of pending Azure Pipeline approvals filtered by build properties. .DESCRIPTION Returns a custom list of pending Azure Pipeline approvals based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BranchName The name of the builds source branch. Ex: 'refs/heads/master' .PARAMETER Definitions The id of the build definition. .PARAMETER BuildIds The ids of the builds to return pending approvals for. .PARAMETER ExpandApproval Return the approval object with the pending approval list. This takes time because each approval needs to be queried. Useful for review approval details in bulk. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines approval(s) .EXAMPLE Returns a custom AP approval list. Get-APPipelineApprovalList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 5.0-preview -ApprovalId 4eg5aavx-1000-4333-ba70-6457d5b15f0e .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/approvals/query?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $BranchName, [Parameter()] [string[]] $Definitions, [Parameter()] [string[]] $BuildIds, [Parameter()] [switch] $ExpandApproval ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $RECORD_TYPES = @( 'Checkpoint' 'Checkpoint.Approval' 'Stage' ) $STATUS_FILTER = @( 'inProgress' 'notStarted' ) $splat = @{ Instance = $Instance Collection = $Collection Project = $Project Proxy = $Proxy ProxyCredential = $ProxyCredential ErrorAction = 'Stop' } If ($PersonalAccessToken) { $splat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $splat.Credential = $Credential } If ($BuildIds) { $builds = Get-APBuildList @Splat -ApiVersion '5.1' -BuildIds $BuildIds } else { $builds = Foreach ($filter in $STATUS_FILTER) { Get-APBuildList @Splat -ApiVersion '5.1' -StatusFilter $filter -BranchName $BranchName -Definitions $Definitions } } $approvalObject = Foreach ($build in $builds) { $timeline = Get-APBuildTimeline @Splat -ApiVersion '5.1' -BuildId $build.id -TimelineId $build.orchestrationPlan.planId $records = $timeline.records | Where-Object { $RECORD_TYPES -contains $PSitem.Type} $approvals = $records.Where( {$PSitem.type -eq 'Checkpoint.Approval' -and $PSitem.state -eq 'inprogress'} ) foreach ($approval in $approvals) { $checkpoint = $records.Where( {$Psitem.id -eq $approval.parentId} ) $stage = $records.Where( {$Psitem.id -eq $checkpoint.parentId} ) If ($ExpandApproval.IsPresent) { $approvalLookup = Get-APPipelineApproval @Splat -ApiVersion '6.1-preview' -ApprovalId $approval.Id [pscustomObject]@{ pipelineDefinitionName = $build.definition.Name pipelineDefinitionId = $build.definition.id pipelineRunId = $build.id pipelineUrl = $build._links.web.href sourceBranch = $build.sourceBranch stageName = $stage.name stageIdentifier = $stage.identifier approvalId = $approval.id approval = $approvalLookup } } else { [pscustomObject]@{ pipelineDefinitionName = $build.definition.Name pipelineDefinitionId = $build.definition.id pipelineRunId = $build.id pipelineUrl = $build._links.web.href sourceBranch = $build.sourceBranch stageName = $stage.name stageIdentifier = $stage.identifier approvalId = $approval.id } } } } if ($approvalObject) { return $approvalObject } } end { } } # Get-APPipelineRun.ps1 function Get-APPipelineRun { <# .SYNOPSIS Returns an Azure Pipeline pipeline run. .DESCRIPTION Returns an Azure Pipeline pipeline run based on a pipeline id and a run id. The pipeline id can be returned with Get-APPipelineList. The run id can be returned with Get-APPipelineRunList .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId Id of the pipeline. .PARAMETER RunId Id of the run. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline run(s) .EXAMPLE Returns a Azure Pipeline pipeline run for 'myFirstProject' with the pipeline id of '7' and the run id of '8'. Get-APPipelineList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PipelineId 7 -RunId 8 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $PipelineId, [Parameter()] [int] $RunId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-runId') -f $PipelineId, $RunId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPipelineRunList.ps1 function Get-APPipelineRunList { <# .SYNOPSIS Returns a list of Azure Pipeline pipeline runs. .DESCRIPTION Returns a list of Azure Pipeline pipeline runs based on a pipeline id. The pipeline id can be returned with Get-APPipelineList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId Id of the pipeline. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline run(s) .EXAMPLE Returns a list of Azure Pipeline pipeline runs for 'myFirstProject' with the id of '7'. Get-APPipelineRunList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PipelineId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/list?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $PipelineId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-runs') -f $PipelineId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPlan.ps1 function Get-APPlan { <# .SYNOPSIS Returns Azure Pipeline plan. .DESCRIPTION Returns Azure Pipeline plan based by plan id. The id can be retrieved by using Get-APPlanList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PlanId The id of the plan. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines plan(s). .EXAMPLE Returns the plan with the id of '7' for the 'myFirstProject. Get-APPlan -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PlanId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/plans/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PlanId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-planId') -f $PlanId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPlanList.ps1 function Get-APPlanList { <# .SYNOPSIS Returns a list of Azure Pipeline work plans. .DESCRIPTION Returns a list of Azure Pipeline work plans based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines work plan(s) .EXAMPLE Returns AP work plan list for 'myFirstProject'. Get-APPlanList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/plans/list?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'work-plans' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $plans = Invoke-APRestMethod @invokeAPRestMethodSplat If ($plans.value) { return $plans.value } else { return $plans } } end { } } # Get-APPolicyConfiguration.ps1 function Get-APPolicyConfiguration { <# .SYNOPSIS Returns a Azure Pipeline policy configuration. .DESCRIPTION Returns a Azure Pipeline policy configuration by configuration id. The id can be retrieved by using Get-APPolicyConfigurationList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ConfigurationId Id of the policy configuration. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy configuration(s) .EXAMPLE Returns policy configuration with the id of '7'. Get-APPolicyConfiguration -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ConfigurationId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $ConfigurationId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-configurationId') -f $ConfigurationId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyConfigurationList.ps1 function Get-APPolicyConfigurationList { <# .SYNOPSIS Returns a list of Azure Pipeline policy configurations. .DESCRIPTION Returns a list of Azure Pipeline policy configurations based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Scope [Provided for legacy reasons] The scope on which a subset of policies is defined. .PARAMETER PolicyType Filter returned policies to only this type. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy configuration(s) .EXAMPLE Returns policy configuration list for 'myFirstProject'. Get-APPolicyConfigurationList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Scope, [Parameter()] [string] $PolicyType ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'policy-configurations' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyEvaluation.ps1 function Get-APPolicyEvaluation { <# .SYNOPSIS Returns a Azure Pipeline policy evaluation. .DESCRIPTION Returns a Azure Pipeline policy evaluation by evaluation id. The id can be retrieved by using Get-APPolicyEvaluationList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EvaluationId Id of the policy evaluation. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy evaluation(s) .EXAMPLE Returns policy evaluation with the id of '7'. Get-APPolicyEvaluation -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -EvaluationId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/evaluations/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EvaluationId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-evaluationId') -f $EvaluationId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyEvaluationList.ps1 function Get-APPolicyEvaluationList { <# .SYNOPSIS Returns a list of Azure Pipeline policy evaluations. .DESCRIPTION Returns a list of Azure Pipeline policy evaluations based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ArtifactId A string which uniquely identifies the target of a policy evaluation. .PARAMETER IncludeNotApplicable Some policies might determine that they do not apply to a specific pull request. Setting this parameter to true will return evaluation records even for policies which don't apply to this pull request. .PARAMETER Top The number of policy evaluation records to retrieve. .PARAMETER Skip The number of policy evaluation records to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy evaluation(s) .EXAMPLE Returns policy evaluation list for 'myFirstProject'. Get-APPolicyEvaluationList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/evaluations/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ArtifactId, [Parameter()] [switch] $IncludeNotApplicable, [Parameter()] [int] $Top, [Parameter()] [int] $Skip ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-evaluations') -f $ArtifactId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyRevision.ps1 function Get-APPolicyRevision { <# .SYNOPSIS Returns a Azure Pipeline policy revision. .DESCRIPTION Returns a Azure Pipeline policy revision by revision id. The id can be retrieved by using Get-APPolicyRevisionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ConfigurationId The policy configuration id. .PARAMETER RevisionId Id of the policy revision. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy revision(s) .EXAMPLE Returns policy revision with the id of '7'. Get-APPolicyRevision -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RevisionId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/revisions/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ConfigurationId, [Parameter(Mandatory)] [int] $RevisionId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-revisionId') -f $RevisionId, $ConfigurationId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyRevisionList.ps1 function Get-APPolicyRevisionList { <# .SYNOPSIS Returns a list of Azure Pipeline policy revisions. .DESCRIPTION Returns a list of Azure Pipeline policy revisions based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ConfigurationId The policy configuration id. .PARAMETER Top The number of revisions to retrieve .PARAMETER Skip The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy revision(s) .EXAMPLE Returns policy revision list for 'myFirstProject'. Get-APPolicyRevisionList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/revisions/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ConfigurationId, [Parameter()] [int] $Top, [Parameter()] [int] $Skip ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-revisions') -f $ConfigurationId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyType.ps1 function Get-APPolicyType { <# .SYNOPSIS Returns a Azure Pipeline policy type. .DESCRIPTION Returns a Azure Pipeline policy type by type id. The id can be retrieved by using Get-APPolicyTypeList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TypeId Id of the policy type. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy type(s) .EXAMPLE Returns policy type with the id of '7'. Get-APPolicyType -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -TypeId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/types/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $TypeId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-typeId') -f $TypeId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPolicyTypeList.ps1 function Get-APPolicyTypeList { <# .SYNOPSIS Returns a list of Azure Pipeline policy types. .DESCRIPTION Returns a list of Azure Pipeline policy types based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy type(s) .EXAMPLE Returns policy type list for 'myFirstProject'. Get-APPolicyTypeList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/types/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'policy-types' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPool.ps1 function Get-APPool { <# .SYNOPSIS Returns Azure Pipeline pool. .DESCRIPTION Returns Azure Pipeline pool based by pool id. The id can be retrieved by using Get-APPoolList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PoolId The id of the pool. .PARAMETER ActionFilter Filter by whether the calling user has use or manage permissions. .PARAMETER Properties Agent pool properties (comma-separated). .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pool(s). .EXAMPLE Returns the pool with the id of '7' for the 'myCollection. Get-APPool -Instance 'https://dev.azure.com' -Collection 'myCollection' -PoolId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/pools/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PoolId, [Parameter()] [ValidateSet('none', 'manage', 'use')] [string] $ActionFilter, [Parameter()] [string[]] $Properties ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pool-poolId') -f $PoolId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APPoolList.ps1 function Get-APPoolList { <# .SYNOPSIS Returns a list of Azure Pipeline pools. .DESCRIPTION Returns a list of Azure Pipeline pools based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PoolName The name of the pool to filter by. .PARAMETER PoolType The type of pool to filter by. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pool(s) .EXAMPLE Returns AP pool list for 'myCollection' Get-APPoolList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/pools/get%20agent%20pools?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $PoolName, [Parameter()] [ValidateSet('none', 'elasticPool', 'preserveAgentOnJobFailure', 'singleUseAgents')] [string] $PoolType ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'pool-pools' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APProcessList.ps1 function Get-APProcessList { <# .SYNOPSIS Returns a list of Azure Pipeline's work item processes. .DESCRIPTION Returns a list of Azure Pipeline's work item processes. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines process(es) .EXAMPLE Returns AP process list for 'myCollection' Get-APProcessList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/processes/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'work-processes' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APProject.ps1 function Get-APProject { <# .SYNOPSIS Returns an Azure Pipeline project. .DESCRIPTION Returns an Azure Pipeline project by project id. The id can be retrieved with Get-APProjectList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProjectId The name or id of the project. .PARAMETER IncludeCapabilities Includes the project's capabilities. .PARAMETER IncludeHistory Includes the project's revision history. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines project. .EXAMPLE Returns the AP project named 'myFirstProject'. Get-APProject-Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/projects/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProjectId, [Parameter()] [bool] $IncludeCapabilities, [Parameter()] [bool] $IncludeHistory ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'project-projectId') -f $ProjectId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APProjectList.ps1 function Get-APProjectList { <# .SYNOPSIS Returns a list of Azure Pipeline build projects. .DESCRIPTION Returns a list of Azure Pipeline build projects based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ContinuationToken A continuation token, returned by a previous call to this method, that can be used to return the next set of definitions. .PARAMETER Top The maximum number of definitions to return. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP project list for 'myFirstProject'. Get-APProjectList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $ContinuationToken, [Parameter()] [int] $Top ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'project-projects' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APProjectList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APQuery.ps1 function Get-APQuery { <# .SYNOPSIS Returns Azure Pipeline query. .DESCRIPTION Returns Azure Pipeline query by query id. The id can be retrieved by using Get-APQueryList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER QueryId The id of the query. .PARAMETER Depth 0 - 2, the depth to query. .PARAMETER Expand Expand properites. .PARAMETER IncludeDeleted Included deleted queries. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines query(s). .EXAMPLE Returns a query from the project 'myFirstProject' with the id of '7'. Get-APQuery -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 6.1-preview -QueryId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/queries/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $QueryId, [Parameter()] [int] $Depth, [Parameter()] [ValidateSet('all', 'clauses', 'minimal', 'none', 'wiql')] [string] $Expand, [Parameter()] [bool] $IncludeDeleted ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-queryId') -f $QueryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APQueryList.ps1 function Get-APQueryList { <# .SYNOPSIS Returns a list of Azure Pipeline query(s). .DESCRIPTION Returns a list of Azure Pipeline query(s). .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Depth 0 - 2, the depth to query. .PARAMETER Expand Expand properites. .PARAMETER IncludeDeleted Included deleted queries. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines query(s). .EXAMPLE Tetruns a list of Azure Pipelines querys for 'myFirstProject' Get-APQueryList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/queries/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $Depth, [Parameter()] [ValidateSet('all', 'clauses', 'minimal', 'none', 'wiql')] [string] $Expand, [Parameter()] [bool] $IncludeDeleted ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'wit-queries' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APQueue.ps1 Function Get-APQueue { <# .SYNOPSIS Returns an Azure Pipeline queue. .DESCRIPTION Returns an Azure Pipeline queue based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER QueueName Filters queues whose names start with this prefix. .PARAMETER ActionFilter Filter Queues based on the permission mentioned. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines queue(s) .EXAMPLE Returns AP queue list for 'myFirstProject'. Get-APQueue -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .EXAMPLE Returns AP queue with queue name of 'myQueue'. Get-APQueue -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -QueueName 'myQueue' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $QueueName, [Parameter()] [ValidateSet('none', 'manage', 'use')] [string] $ActionFilter ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-queues' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APRecycleBinRepository.ps1 function Get-APRecycleBinRepository { <# .SYNOPSIS Returns a deleted git repository. .DESCRIPTION Returns a deleted git repository based a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines git repository. .EXAMPLE Returns a list of deleted git repositories. Get-APRecycleBinRepository -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/repositories/get%20deleted%20repositories?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'git-recycleBin' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APRelease.ps1 function Get-APRelease { <# .SYNOPSIS Returns Azure Pipeline release. .DESCRIPTION Returns Azure Pipeline release by release id. The id can be retrieved by using Get-APReleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseId Id of the release. .PARAMETER ApprovalFilters A filter which would allow fetching approval steps selectively based on whether it is automated, or manual. This would also decide whether we should fetch pre and post approval snapshots. Assumes All by default. .PARAMETER PropertyFilters A comma-delimited list of extended properties to be retrieved. If set, the returned Release will contain values for the specified property Ids (if they exist). If not set, properties will not be included. .PARAMETER Expand A property that should be expanded in the release. .PARAMETER TopGateRecords Number of release gate records to get. Default is 5. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release(s) .EXAMPLE Returns AP release with the release id of 7. Get-APRelease -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/get%20release?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ReleaseId, [Parameter()] [string] $ApprovalFilters, [Parameter()] [string] $PropertyFilters, [Parameter()] [string] [ValidateSet('none', 'tasks')] $Expand, [Parameter()] [int] $TopGateRecords ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-releaseId') -f $ReleaseId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APReleaseDefinition.ps1 function Get-APReleaseDefinition { <# .SYNOPSIS Returns an Azure Pipeline release definition. .DESCRIPTION Returns an Azure Pipeline release definition by definition id. The id can be retrieved by using Get-APReleaseDefinitionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionId Releases with names starting with searchText. .PARAMETER PropertyFilters The property that should be expanded in the list of releases. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release definition(s). .EXAMPLE Returns the AP release definition with the definition id of '5'. Get-APReleaseDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/definitions/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DefinitionId, [Parameter()] [string[]] $PropertyFilters ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-definitionId') -f $DefinitionId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APReleaseDefinitionList.ps1 function Get-APReleaseDefinitionList { <# .SYNOPSIS Returns a list of Azure Pipeline release definitions. .DESCRIPTION Returns a list of Azure Pipeline release definitions based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SearchText Releases with names starting with searchText. .PARAMETER Expand The property that should be expanded in the list of releases. .PARAMETER ArtifactType Release definitions with given artifactType will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. .PARAMETER Top Number of releases to get. Default is 50. .PARAMETER ContinuationToken Gets the releases after the continuation token provided. .PARAMETER QueryOrder Gets the results in the defined order of created date for releases. Default is descending. .PARAMETER Path Gets the release definitions under the specified path. .PARAMETER IsExactNameMatch Set to 'true' to get the release definitions with exact match as specified in searchText. Default is 'false'. .PARAMETER TagFilter A comma-delimited list of tags. Only releases with these tags will be returned. .PARAMETER PropertyFilters A comma-delimited list of extended properties to retrieve. .PARAMETER DefinitionIdFilter A comma-delimited list of release definitions to retrieve. .PARAMETER IsDeleted Gets the soft deleted releases, if true. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release definition(s) .EXAMPLE Returns AP release definition list for 'myFirstProject'. Get-APReleaseDefinitionList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/definitions/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $SearchText, [Parameter()] [string] [ValidateSet('approvals', 'artifacts', 'environments', 'manualInterventions', 'none', 'tags', 'variables')] $Expand, [Parameter()] [string] $ArtifactType, [Parameter()] [string] $Top, [Parameter()] [string] $ContinuationToken, [Parameter()] [string] $QueryOrder, [Parameter()] [string] $Path, [Parameter()] [string] $IsExactNameMatch, [Parameter()] [string] $TagFilter, [Parameter()] [string] $PropertyFilters, [Parameter()] [string] $DefinitionIdFilter, [Parameter()] [bool] $IsDeleted ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'release-definitions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APReleaseDefinitionList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APReleaseEnvironment.ps1 function Get-APReleaseEnvironment { <# .SYNOPSIS Returns Azure Pipeline release environment. .DESCRIPTION Returns Azure Pipeline release by release id and environment id. The release and environment id can be retrieved by using Get-APReleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseId Id of the release. .PARAMETER EnvironmentId Id of the release environment. .PARAMETER Expand A property that should be expanded in the release. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release(s) .EXAMPLE Returns AP release with the release id of 7. Get-APReleaseEnvironment -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/get%20release%20environment?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ReleaseId, [Parameter(Mandatory)] [string] $EnvironmentId, [Parameter()] [string] [ValidateSet('none', 'tasks')] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-environmentId') -f $ReleaseId, $EnvironmentId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APReleaseList.ps1 function Get-APReleaseList { <# .SYNOPSIS Returns a list of Azure Pipeline releases. .DESCRIPTION Returns a list of Azure Pipeline releases based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PropertyFilters A comma-delimited list of extended properties to retrieve. .PARAMETER TagFilter A comma-delimited list of tags. Only releases with these tags will be returned. .PARAMETER IsDeleted Gets the soft deleted releases, if true. .PARAMETER SourceBranchFilter Releases with given sourceBranchFilter will be returned. .PARAMETER ArtifactVersionId Releases with given artifactVersionId will be returned. E.g. in case of Build artifactType, it is buildId. .PARAMETER SourceId Unique identifier of the artifact used. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. .PARAMETER ArtifactTypeId Releases with given artifactTypeId will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. .PARAMETER Expand The property that should be expanded in the list of releases. .PARAMETER ContinuationToken Gets the releases after the continuation token provided. .PARAMETER Top Number of releases to get. Default is 50. .PARAMETER QueryOrder Gets the results in the defined order of created date for releases. Default is descending. .PARAMETER MaxCreatedTime Releases that were created before this time. .PARAMETER MinCreatedTime Releases that were created after this time. .PARAMETER EnvironmentStatusFilter Integer value for the status filters are below. Undefined = 0, NotStarted = 1, InProgress = 2, Succeeded = 4, Canceled = 8, Rejected = 16, Queued = 32, Scheduled = 64, PartiallySucceeded = 128 Environment Status - https://raw.githubusercontent.com/microsoft/vss-web-extension-sdk/master/typings/rmo.d.ts .PARAMETER StatusFilter Releases that have this status. .PARAMETER CreatedBy Releases created by this user. .PARAMETER SearchText Releases with names starting with searchText. .PARAMETER DefinitionEnvironmentId Undefined, see link for documentation .PARAMETER DefinitionId Releases from this release definition Id. .PARAMETER ReleaseIdFilter A comma-delimited list of releases Ids. Only releases with these Ids will be returned. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release(s) .EXAMPLE Returns AP release list for 'myFirstProject'. Get-APReleaseList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/release/releases/list?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $PropertyFilters, [Parameter()] [string] $TagFilter, [Parameter()] [bool] $IsDeleted, [Parameter()] [string] $SourceBranchFilter, [Parameter()] [string] $ArtifactVersionId, [Parameter()] [string] $SourceId, [Parameter()] [string] $ArtifactTypeId, [Parameter()] [string] [ValidateSet('approvals', 'artifacts', 'environments', 'manualInterventions', 'none', 'tags', 'variables')] $Expand, [Parameter()] [int] $ContinuationToken, [Parameter()] [int] $Top, [Parameter()] [string] [ValidateSet('ascending', 'descending')] $QueryOrder, [Parameter()] [datetime] $MaxCreatedTime, [Parameter()] [datetime] $MinCreatedTime, [Parameter()] [string] $EnvironmentStatusFilter, [Parameter()] [string] [ValidateSet('abandoned', 'active', 'draft', 'undefined')] $StatusFilter, [Parameter()] [string] $CreatedBy, [Parameter()] [string] $SearchText, [Parameter()] [int] $DefinitionEnvironmentId, [Parameter()] [int] $DefinitionId, [Parameter()] [int] $ReleaseIdFilter ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'release-releases' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APReleaseList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APReleaseTaskLog.ps1 function Get-APReleaseTaskLog { <# .SYNOPSIS Returns Azure Pipeline task log. .DESCRIPTION Returns Azure Pipeline release task log by the release id and environment id. The id can be retrieved by using Get-APReleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseId The Id of the release. .PARAMETER EnvironmentId The Id of the release environment. .PARAMETER DeployPhaseId The Id of the release environment deploy phase. .PARAMETER TaskId The Id of the release environment task. .PARAMETER StartLine Starting line number for the logs. .PARAMETER EndLine Ending line numbers for the logs. .INPUTS None, does not support pipeline. .OUTPUTS String, Azure Pipelines release task log(s). .EXAMPLE Returns the build with the id of '7' for the 'myFirstProject. Get-TaskLog -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 7 -EnvironmentId 8 -TaskId 9 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ReleaseId, [Parameter(Mandatory)] [int] $EnvironmentId, [Parameter(Mandatory)] [int] $DeployPhaseId, [Parameter(Mandatory)] [int] $TaskId, [Parameter()] [int] $StartLine, [Parameter()] [int] $EndLine ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-logs') -f $ReleaseId, $EnvironmentId, $DeployPhaseId, $TaskId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APRepository.ps1 function Get-APRepository { <# .SYNOPSIS Returns an Azure Pipeline repository. .DESCRIPTION Returns an Azure Pipeline repository by repository id. The id can be retrieved by using Get-APRepositoryList. The id can be the guid or the name of the repository. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The name or ID of the repository. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP repository with the repository id of 'myRepository'. Get-APRepository -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RepositoryId 'myRepository' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/git/repositories/get%20repository?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-repositoryId') -f $RepositoryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APRepositoryList.ps1 function Get-APRepositoryList { <# .SYNOPSIS Returns a list Azure Pipeline repositories. .DESCRIPTION Returns a list Azure Pipeline repositories. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER IncludeLinks [optional] True to include reference links. The default value is false. .PARAMETER IncludeAllUrls [optional] True to include all remote URLs. The default value is false. .PARAMETER IncludeHidden [optional] True to include hidden repositories. The default value is false. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP repository list for 'myFirstProject'. Get-APRepositoryList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/git/repositories/list?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [bool] $IncludeLinks, [Parameter()] [bool] $IncludeAllUrls, [Parameter()] [bool] $IncludeHidden ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'git-repositories' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APRootNodeList.ps1 function Get-APRootNodeList { <# .SYNOPSIS Returns a list of Azure Pipeline root nodes for a single project. .DESCRIPTION Returns a list of Azure Pipeline root nodes for a single project. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Depth Depth of children to fetch .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP node list for a project named 'myProject'. Get-APNodeList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -ApiVersion 6.0 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/get%20root%20nodes?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $Depth ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'wit-classificationnodes' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APSecureFileList.ps1 function Get-APSecureFileList { <# .SYNOPSIS Returns a list of Azure Pipeline secure files. .DESCRIPTION Returns a list of Azure Pipeline secure files based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines securefile(s) .EXAMPLE Returns AP secure file list for 'myFirstProject' Get-APSecureFileList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK Undocumented #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'securefiles-securefiles' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APSecureFileList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APSecurityNamespaceList.ps1 function Get-APSecurityNamespaceList { <# .SYNOPSIS Returns a list of security namespaces. .DESCRIPTION Returns a list of security namespaces based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SecurityNamespaceId Security namespace identifier. .PARAMETER LocalOnly If true, retrieve local security namespaces. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines security namespace(s) .EXAMPLE Returns all security namespaces Get-APBuildList -Session 'mySession' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/security/security%20namespaces/query?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $SecurityNamespaceId, [Parameter()] [bool] $LocalOnly ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'securitynamespaces-securityNamespaceId') -f $SecurityNamespaceId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APServiceEndpoint.ps1 function Get-APServiceEndpoint { <# .SYNOPSIS Returns an Azure Pipelines service endpoint details. .DESCRIPTION Returns an Azure Pipelines service endpoint details based on a the endpoint id. The id can be retrieved by using Get-APServiceEndpointList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EndpointId Id of the service endpoint. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint execution record(s) .EXAMPLE Returns a service endpoint execution records for a service endpoint with the id of '7'. Get-APServiceEndpoint -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -EndpointId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $EndpointId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'serviceendpoint-endpointId') -f $EndpointId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APServiceEndpointExecutionHistoryList.ps1 function Get-APServiceEndpointExecutionHistoryList { <# .SYNOPSIS Returns an Azure Pipelines service endpoint execution records. .DESCRIPTION Returns an Azure Pipelinesservice endpoint execution records based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EndpointId Id of the service endpoint. .PARAMETER Top Number of service endpoint execution records to get. .PARAMETER ContinuationToken A continuation token, returned by a previous call to this method, that can be used to return the next set of records .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint execution record(s) .EXAMPLE Returns a service endpoint execution records for a service endpoint with the id of '7'. Get-APServiceEndpointExecutionHistoryList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -EndpointId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/executionhistory/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $EndpointId, [Parameter()] [string] $ContinuationToken, [Parameter()] [int] $Top ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'serviceendpoint-executionhistory') -f $EndpointId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APServiceEndpointExecutionHistoryList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APServiceEndpointList.ps1 function Get-APServiceEndpointList { <# .SYNOPSIS Returns a list of Azure Pipeline service endpoints. .DESCRIPTION Returns a list of Azure Pipeline service endpoints based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Type Type of the service endpoints. .PARAMETER AuthSchemes Authorization schemes used for service endpoints. .PARAMETER EndpointIds Ids of the service endpoints. .PARAMETER Owner Owner for service endpoints. .PARAMETER IncludeFailed Failed flag for service endpoints. .PARAMETER IncludeDetails Flag to include more details for service endpoints. This is for internal use only and the flag will be treated as false for all other requests .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint(s) .EXAMPLE Returns AP service endpoint list for 'myFirstProject' Get-APServiceEndpointList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/get%20service%20endpoints?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Type, [Parameter()] [string[]] $AuthSchemes, [Parameter()] [string[]] $EndpointIds, [Parameter()] [string] $Owner, [Parameter()] [bool] $IncludeFailed, [Parameter()] [bool] $IncludeDetails ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'serviceendpoint-endpoints' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APServiceEndpointName.ps1 function Get-APServiceEndpointName { <# .SYNOPSIS Returns an Azure Pipelines service endpoint details. .DESCRIPTION Returns an Azure Pipelines service endpoint details based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EndpointNames Names of the service endpoints. .PARAMETER Type Type of the service endpoints. .PARAMETER AuthSchemes Authorization schemes used for service endpoints. .PARAMETER Owner Owner for service endpoints. .PARAMETER IncludeFailed Failed flag for service endpoints. .PARAMETER IncludeDetails Flag to include more details for service endpoints. This is for internal use only and the flag will be treated as false for all other requests .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint execution record(s) .EXAMPLE Returns a service endpoint execution records for a service endpoint with the name of 'myEndpoint'. Get-APServiceEndpointName -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -EndpointName 'myEndpoint' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/get%20service%20endpoints%20by%20names?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string[]] $EndpointNames, [Parameter()] [string] $Type, [Parameter()] [string[]] $AuthSchemes, [Parameter()] [string] $Owner, [Parameter()] [bool] $IncludeFailed, [Parameter()] [bool] $IncludeDetails ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'serviceendpoint-endpoints') -f $EndpointName $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APServiceEndpointTypeList.ps1 function Get-APServiceEndpointTypeList { <# .SYNOPSIS Returns a list of Azure Pipeline service endpoint types. .DESCRIPTION Returns a list of Azure Pipeline service endpoint types based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Type Type of service endpoint. .PARAMETER Scheme Scheme of service endpoint .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint type(s) .EXAMPLE Returns service endpoint type list for 'myCollection'. Get-APServiceEndpointTypeList -Instance 'https://dev.azure.com' -Collection 'myCollection' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/types/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Type, [Parameter()] [string] $Scheme ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'serviceendpoint-types' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APSession.ps1 Function Get-APSession { <# .SYNOPSIS Returns Azure Pipelines PS session data. .DESCRIPTION Returns Azure Pipelines PS session data that has been stored in the users local application data. Use Save-APSession to persist the session data to disk. The sensetive data is returned encrypted. .PARAMETER Id Session id. .PARAMETER SessionName The friendly name of the session. .PARAMETER Path The path where session data will be stored, defaults to $Script:ModuleDataPath. .LINK Save-APSession Remove-APSession .INPUTS None, does not support pipeline. .OUTPUTS PSObject. Get-APSession returns a PSObject that contains the following: Instance Collection PersonalAccessToken .EXAMPLE Returns all AP sessions saved or in memory. Get-APSession .EXAMPLE Returns AP session with the session name of 'myFirstSession'. Get-APSession -SessionName 'myFirstSession' #> [CmdletBinding()] Param ( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $SessionName, [Parameter(ParameterSetName = 'ById', ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $Id, [Parameter()] [string] $Path = $Script:ModuleDataPath ) Process { # Process memory sessions $_sessions = @() If ($null -ne $Global:_APSessions) { Foreach ($_memSession in $Global:_APSessions) { $_sessions += $_memSession } } # Process saved sessions If (Test-Path $Path) { $data = Get-Content -Path $Path -Raw | ConvertFrom-Json Foreach ($_data in $data.SessionData) { $_object = New-Object -TypeName PSCustomObject -Property @{ Id = $_data.Id Instance = $_data.Instance Collection = $_data.Collection Project = $_data.Project SessionName = $_data.SessionName Version = $_data.Version ApiVersion = $_data.ApiVersion Saved = $_data.Saved } If ($_data.PersonalAccessToken) { $_object | Add-Member -NotePropertyName 'PersonalAccessToken' -NotePropertyValue ($_data.PersonalAccessToken | ConvertTo-SecureString) } If ($_data.Credential) { $_psCredentialObject = [pscredential]::new($_data.Credential.Username, ($_data.Credential.Password | ConvertTo-SecureString)) $_object | Add-Member -NotePropertyName 'Credential' -NotePropertyValue $_psCredentialObject } If ($_data.Proxy) { $_object | Add-Member -NotePropertyName 'Proxy' -NotePropertyValue $_data.Proxy } If ($_data.ProxyCredential) { $_psProxyCredentialObject = [pscredential]::new($_data.ProxyCredential.Username, ($_data.ProxyCredential.Password | ConvertTo-SecureString)) $_object | Add-Member -NotePropertyName 'ProxyCredential' -NotePropertyValue $_psProxyCredentialObject } $_sessions += $_object } } If ($PSCmdlet.ParameterSetName -eq 'ById') { $_sessions = $_sessions | Where-Object { $PSItem.Id -eq $Id } } If ($SessionName) { $_sessions = $_sessions | Where-Object { $PSItem.SessionName -eq $SessionName } If (-not($_sessions)) { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate a session by the name of [$SessionName]" -ErrorAction 'Stop' } } return $_sessions } } # Get-APSourceProviderList.ps1 function Get-APSourceProviderList { <# .SYNOPSIS Returns a list of Azure Pipeline source providers. .DESCRIPTION Returns a list of Azure Pipeline source providers based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines source provider(s) .EXAMPLE Returns AP spource provider list for 'myFirstProject'. Get-APSourceProviderList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/source%20providers/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'sourceProviders-sourceproviders' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APStorageKey.ps1 function Get-APStorageKey { <# .SYNOPSIS Resolves a descriptor to a storage key. .DESCRIPTION Resolves a descriptor to a storage key by user subject descriptor. The descriptor can be retrieved by using Get-APGroupList or Get-APUserList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectDescriptor The descriptor of the desired user or group. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP strorage key with the subject descriptor of 'aad.OWRjNmIjMtZjNjY3ZDQ0LWIzOTgtZmYyMTM4N2E3NGJj' for 'myCollection'. Get-APStorageKey -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview -SubjectDescriptor 'aad.OWRjNmIjMtZjNjY3ZDQ0LWIzOTgtZmYyMTM4N2E3NGJj' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/storage%20keys/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $SubjectDescriptor ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-storagekeys') -f $SubjectDescriptor $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTarget.ps1 function Get-APTarget { <# .SYNOPSIS Returns Azure Pipeline deployment group target. .DESCRIPTION Returns Azure Pipeline deployment group target based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment target to return. .PARAMETER TargetID ID of the deployment target to return. .PARAMETER Expand Include these additional details in the returned objects. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines deployment group. .EXAMPLE Returns AP targer witht the deployment group id of '6' and the target id of '25 for 'myFirstProject'. Get-APTarget -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 -TargetId 25 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/targets/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupID, [Parameter(Mandatory)] [int] $TargetId, [Parameter(ParameterSetName = 'ByQuery')] [ValidateSet('assignedRequest', 'capabilities', 'lastCompletedRequest', 'none')] [string] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-targetId') -f $DeploymentGroupID, $TargetId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTargetList.ps1 function Get-APTargetList { <# .SYNOPSIS Returns a list of Azure Pipeline deployment group targets. .DESCRIPTION Returns a list of Azure Pipeline deployment group targets based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment group. .PARAMETER Tags Get only the deployment targets that contain all these comma separted list of tags. .PARAMETER Name Name pattern of the deployment targets to return. .PARAMETER PartialNameMatch When set to true, treats name as pattern. else treats it as absolute match. Default is false. .PARAMETER Expand Include these additional details in the returned objects. .PARAMETER AgentStatus Get only deployment targets that have this status. .PARAMETER AgentJobResult Get only deployment targets that have this last job result. .PARAMETER ContinuationToken Get deployment targets with names greater than this continuationToken lexicographically. .PARAMETER Top Maximum number of deployment targets to return. Default is 1000. .PARAMETER Enabled Get only deployment targets that are enabled or disabled. Default is 'null' which returns all the targets. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines deployment group. .EXAMPLE Returns AP target list with the deployment group id of '6 for 'myFirstProject'. Get-APTargetList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/targets/list?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupID, [Parameter()] [string[]] $Tags, [Parameter()] [string] $Name, [Parameter()] [bool] $PartialNameMatch, [Parameter()] [ValidateSet('assignedRequest', 'capabilities', 'lastCompletedRequest', 'none')] [string] $Expand, [Parameter()] [ValidateSet('all', 'offline', 'online')] [string] $AgentStatus, [Parameter()] [ValidateSet('all', 'failed', 'neverDeployed', 'passed')] [string] $AgentJobResult, [Parameter()] [string] $ContinuationToken, [Parameter()] [int] $Top, [Parameter()] [bool] $Enabled ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-targets') -f $DeploymentGroupID $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APTargetList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTaskGroupList.ps1 function Get-APTaskGroupList { <# .SYNOPSIS Returns a list of Azure Pipeline task groups. .DESCRIPTION Returns a list of Azure Pipeline task groups based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TaskGroupId Id of the task group. .PARAMETER Expanded 'true' to recursively expand task groups. Default is 'false'. .PARAMETER TaskIdFilter Guid of the taskId to filter. .PARAMETER Deleted 'true'to include deleted task groups. Default is 'false'. .PARAMETER Top Number of task groups to get. .PARAMETER ContinuationToken Gets the task groups after the continuation token provided. .PARAMETER QueryOrder Gets the results in the defined order. Default is 'CreatedOnDescending'. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP task group list for 'myFirstProject'. Get-APTaskGroupList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/taskgroups/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $TaskGroupId, [Parameter()] [bool] $Expanded, [Parameter()] [string] $TaskIdFilter, [Parameter()] [bool] $Deleted, [Parameter()] [int] $Top, [Parameter()] [string] $ContinuationToken, [Parameter()] [ValidateSet('createdOnAscending', 'createdOnDescending')] [string] $QueryOrder ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'taskgroup-taskgroups' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APTaskGroupList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTeam.ps1 function Get-APTeam { <# .SYNOPSIS Returns an Azure Pipeline team. .DESCRIPTION Returns an Azure Pipeline team based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .PARAMETER ExpandIdentity A value indicating whether or not to expand Identity information in the result WebApiTeam object. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Returns AP team named 'myTeam' for a project named 'myProject'. Get-APTeam -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -TeamId 'myTeam' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId, [Parameter()] [bool] $ExpandIdentity ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'team-teamId') -f $Project, $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTeamFieldValues.ps1 function Get-APTeamFieldValues { <# .SYNOPSIS Returns an Azure Pipeline team's field values based on the team name or id. .DESCRIPTION Returns an Azure Pipeline team's field values based on the team name or id. Return team ids with Get-APTeamList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Returns AP team field values for a team named 'myTeam' for a project named 'myProject'. Get-APTeamFieldValues -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -TeamId 'myTeam' -ApiVersion 6.0 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/teamfieldvalues/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-teamfieldvalues') -f $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } return Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Get-APTeamList.ps1 function Get-APTeamList { <# .SYNOPSIS Returns a list of Azure Pipeline teams for a single project. .DESCRIPTION Returns a list of Azure Pipeline teams for a single project based on a filter query. Use Get-APProjectList to identify the project name or id. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Mine If true return all the teams requesting user is member, otherwise return all the teams user has read access .PARAMETER Top Maximum number of teams to return. .PARAMETER Skip Number of teams to skip. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP team list for a project named 'myProject'. Get-APTeamList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/get%20teams?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [bool] $Mine, [Parameter()] [int] $Top, [Parameter()] [int] $Skip ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'team-projectId') -f $Project $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTeamListAll.ps1 function Get-APTeamListAll { <# .SYNOPSIS Returns a list of Azure Pipeline teams for all projects. .DESCRIPTION Returns a list of Azure Pipeline teams for all projects based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Mine If true return all the teams requesting user is member, otherwise return all the teams user has read access .PARAMETER Top Maximum number of teams to return. .PARAMETER Skip Number of teams to skip. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP team list for 'myCollection'. Get-APTeamList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/get%20all%20teams?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [bool] $Mine, [Parameter()] [int] $Top, [Parameter()] [int] $Skip ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'team-teams' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTeamMembers.ps1 function Get-APTeamMembers { <# .SYNOPSIS Returns an Azure Pipeline team. .DESCRIPTION Returns an Azure Pipeline team based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .PARAMETER ExpandIdentity A value indicating whether or not to expand Identity information in the result WebApiTeam object. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Returns AP team named 'myTeam' for a project named 'myProject'. Get-APTeamMembers -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -TeamId 'myTeam' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/get%20team%20members%20with%20extended%20properties?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId, [Parameter()] [bool] $ExpandIdentity ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'team-members') -f $Project, $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTeamSettings.ps1 function Get-APTeamSettings { <# .SYNOPSIS Returns an Azure Pipeline team's settings based on the team name or id. .DESCRIPTION Returns an Azure Pipeline team's settings based on the team name or id. Return team ids with Get-APTeamList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Returns AP team settings for a team named 'myTeam' for a project named 'myProject'. Get-APTeam -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -TeamId 'myTeam' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/teamsettings/get?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-teamsettings') -f $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } return Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Get-APTestPlan.ps1 function Get-APTestPlan { <# .SYNOPSIS Returns an Azure Pipeline test plan. .DESCRIPTION Returns an Azure Pipeline test plan based on a plan id. The plan id can be returned with Get-APTestPlanList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PlanId Id of the test plan to get. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test plan(s) .EXAMPLE Returns AP test plan list for 'myFirstProject' and the plan id of '8'. Get-APTestPlan -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PlanId 8 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/testplan/test%20%20plans/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PlanId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-testPlanId') -f $PlanId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $plans = Invoke-APRestMethod @invokeAPRestMethodSplat If ($plans.value) { return $plans.value } else { return $plans } } end { } } # Get-APTestPlanList.ps1 function Get-APTestPlanList { <# .SYNOPSIS Returns a list of Azure Pipeline test plans. .DESCRIPTION Returns a list of Azure Pipeline test plans based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ContinuationToken If the list of plans returned is not complete, a continuation token to query next batch of plans is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test plans. .PARAMETER FilterActivePlans Get just the active plans. .PARAMETER IncludePlanDetails Get all properties of the test plan .PARAMETER Owner Filter for test plan by owner ID or name .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test plan(s) .EXAMPLE Returns AP test plan list for 'myFirstProject'. Get-APTestPlanList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/testplan/test%20%20plans/list?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $ContinuationToken, [Parameter()] [bool] $FilterActivePlans, [Parameter()] [bool] $IncludePlanDetails, [Parameter()] [string] $Owner ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'test-testPlans' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APTestPlanList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestResult.ps1 function Get-APTestResult { <# .SYNOPSIS Returns an Azure Pipeline test result. .DESCRIPTION Returns an Azure Pipeline test result based on a test run id and a test case result id. The test run id can be returned with Get-APTestRunList. The test case result id can be returned with Get-APTestResultList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RunId Id of the run to get. .PARAMETER TestCaseResultId Id of the test case result. .PARAMETER DetailsToInclude Details to include with test results. Default is None. Other values are Iterations and WorkItems. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test result(s) .EXAMPLE Returns AP test result list for 'myFirstProject' for run with the id of '7' and test case result of '8'. Get-APTestResult -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RunId 7 -TestCaseResultId 8 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/test/results/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $RunId, [Parameter(Mandatory)] [int] $TestCaseResultId, [Parameter()] [validateSet('none', 'iterations', 'point', 'subResults', 'workItems')] [string] $DetailsToInclude ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-testCaseId') -f $RunId, $TestCaseResultId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestResultList.ps1 function Get-APTestResultList { <# .SYNOPSIS Returns a list of Azure Pipeline test results. .DESCRIPTION Returns a list of Azure Pipeline test results based on a test run id. The test run id can be returned with Get-APTestRunList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RunId Id of the run to get. .PARAMETER Skip Number of test results to skip. .PARAMETER Top The maximum number of test results to return. .PARAMETER DetailsToInclude Details to include with test results. Default is None. Other values are Iterations and WorkItems. .PARAMETER Outcomes Comma separated list of test outcomes to filter test results. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test result(s) .EXAMPLE Returns AP test result list for 'myFirstProject' for run with the id of '7' Get-APTestResultList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RunId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/test/results/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $RunId, [Parameter()] [int] $Skip, [Parameter()] [int] $Top, [Parameter()] [validateSet('none', 'iterations', 'point', 'subResults', 'workItems')] [string] $DetailsToInclude, [Parameter()] [string[]] $Outcomes ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-results') -f $RunId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestRun.ps1 function Get-APTestRun { <# .SYNOPSIS Returns a an Azure Pipeline test run. .DESCRIPTION Returns an Azure Pipeline test run based on a test run id. The test run id can be returned with Get-APTestRunList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RunId Id of the run to get. .PARAMETER IncludeDetails Defualt value is true. It includes details like run statistics, release, build, Test enviornment, Post process state and more. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test run(s) .EXAMPLE Returns AP test run for 'myFirstProject' with the id of '7'. Get-APTestRun -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RunId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/test/runs/get%20test%20run%20by%20id?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $RunId, [Parameter()] [bool] $IncludeDetails ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-runId') -f $RunId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestRunList.ps1 function Get-APTestRunList { <# .SYNOPSIS Returns a list of Azure Pipeline test runs. .DESCRIPTION Returns a list of Azure Pipeline test runs based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Skip Number of test runs to skip. .PARAMETER Top The maximum number of test runs to return. .PARAMETER Automated If true, only returns automated runs. .PARAMETER BuildUri URI of the build that the runs used. .PARAMETER IncludeRunDetails If true, include all the properties of the runs. .PARAMETER Owner Team foundation ID of the owner of the runs. .PARAMETER PlanId ID of the test plan that the runs are a part of. .PARAMETER TmiRunId Undocumented .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test run(s) .EXAMPLE Returns AP test run list for 'myFirstProject' Get-APTestRunList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/test/runs/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $Skip, [Parameter()] [int] $Top, [Parameter()] [bool] $Automated, [Parameter()] [string] $BuildUri, [Parameter()] [bool] $IncludeRunDetails, [Parameter()] [string] $Owner, [Parameter()] [int] $PlanId, [Parameter()] [string] $TmiRunId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'test-runs' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestRunStatistics.ps1 function Get-APTestRunStatistics { <# .SYNOPSIS Returns an Azure Pipeline test run statistic. .DESCRIPTION Returns an Azure Pipeline test run statistic based on a test run id. The test run id can be returned with Get-APTestRunList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RunId Id of the run to get. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test run(s) .EXAMPLE Returns AP test run for 'myFirstProject' with the id of '7'. Get-APTestRunStatistics -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RunId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/test/runs/get%20test%20run%20statistics?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $RunId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-statistics') -f $RunId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestSuiteList.ps1 function Get-APTestSuiteList { <# .SYNOPSIS Returns a list of Azure Pipeline test cases for a suite. .DESCRIPTION Returns a list of Azure Pipeline test cases for a suite based on the plan id. The plan id can be returned with Get-APTestPlanList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PlanId Id of the test plan for which suites are requested .PARAMETER Skip Number of test suites to skip. .PARAMETER Top The maximum number of test suites to return. .PARAMETER Expand Include the children suites and testers details. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test suite(s) .EXAMPLE Returns AP test suite list for 'myFirstProject' for run with the id of '7' Get-APTestSuiteList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PlanId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/test/test%20%20suites/get%20test%20suites%20for%20plan?view=azure-devops-server-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PlanId, [Parameter()] [int] $Skip, [Parameter()] [int] $Top, [Parameter()] [int] $Expand ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-suites') -f $PlanId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APTestSuiteTestCase.ps1 function Get-APTestSuiteTestCase { <# .SYNOPSIS Returns an Azure Pipeline test cases for a test suite and plan. .DESCRIPTION Returns an Azure Pipeline test plan based on a plan id. The plan id can be returned with Get-APTestPlanList. The suite id can be returned with Get-APTestSuiteList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PlanId Id of the test plan to get. .PARAMETER SuiteId Id of the test suite to get. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines test plan(s) .EXAMPLE Returns AP test plan list for 'myFirstProject' and the plan id of '8'. Get-APTestSuiteTestCases -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PlanId 8 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/testplan/test%20%20plans/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PlanId, [Parameter(Mandatory)] [int] $SuiteId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-testcases') -f $PlanId, $SuiteId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $plans = Invoke-APRestMethod @invokeAPRestMethodSplat If ($plans.value) { return $plans.value } else { return $plans } } end { } } # Get-APUser.ps1 function Get-APUser { <# .SYNOPSIS Returns an Azure Pipeline user. .DESCRIPTION Returns Azure Pipeline user by user descriptor. The descriptor can be retrieved by using Get-APUserList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER UserDescriptor The descriptor of the desired user. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP user with the user descriptor of 'aad.OWRjNmIjMtZjNjY3ZDQ0LWIzOTgtZmYyMTM4N2E3NGJj' for 'myCollection'. Get-APUser -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview -UserDescriptor 'aad.OWRjNmIjMtZjNjY3ZDQ0LWIzOTgtZmYyMTM4N2E3NGJj' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/users/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $UserDescriptor ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-userId') -f $UserDescriptor $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APUserEntitlementList.ps1 function Get-APUserEntitlementList { <# .SYNOPSIS Returns a list of Azure Pipeline user entitlements. .DESCRIPTION Returns a list of Azure Pipeline user entitlements. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectTypes A comma separated list of user subject subtypes to reduce the retrieved results, e.g. msa’, ‘aad’, ‘svc’ (service identity), ‘imp’ (imported identity), etc. .PARAMETER ContinuationToken An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP user list for 'myCollection'. Get-APUserEntitlementList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 6.1-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/users/get?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string[]] $SubjectTypes, [Parameter()] [string] $ContinuationToken ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'userentitlements-entitlements' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vsaex' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.value.continuationToken) { $results.value.members $null = $PSBoundParameters.Remove('ContinuationToken') $continuationToken = [System.Web.HttpUtility]::UrlEncode($results.value.continuationToken) Get-APUserEntitlementList @PSBoundParameters -ContinuationToken $continuationToken } elseIf ($results.value.members.count -eq 0) { return } elseIf ($results.value.members) { return $results.value.members } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APUserList.ps1 function Get-APUserList { <# .SYNOPSIS Returns a list of Azure Pipeline users. .DESCRIPTION Returns a list of Azure Pipeline users based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectTypes A comma separated list of user subject subtypes to reduce the retrieved results, e.g. msa’, ‘aad’, ‘svc’ (service identity), ‘imp’ (imported identity), etc. .PARAMETER ContinuationToken An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines account(s) .EXAMPLE Returns AP user list for 'myCollection'. Get-APUserList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/users/list?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string[]] $SubjectTypes, [Parameter()] [string] $ContinuationToken ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'graph-users' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APUserList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APVariableGroup.ps1 function Get-APVariableGroup { <# .SYNOPSIS Returns an Azure Pipeline variable group. .DESCRIPTION Returns an Azure Pipeline variable group by group id. The id can be retrieved by using Get-APVariableGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER GroupId Id of the variable group. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Returns AP variable group with group id of '7' for 'myFirstProject'. Get-APVariableGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -GroupId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $GroupId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-variablegroupId') -f $GroupId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APVariableGroupList.ps1 function Get-APVariableGroupList { <# .SYNOPSIS Returns a list of Azure Pipeline variable groups. .DESCRIPTION Returns a list of Azure Pipeline variable groups based on a filter query. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER GroupName Name of variable group. .PARAMETER ActionFilter Action filter for the variable group. It specifies the action which can be performed on the variable groups. .PARAMETER Top Number of variable groups to get. .PARAMETER ContinuationToken Gets the releases after the continuation token provided. .PARAMETER QueryOrder Gets the results in the defined order. Default is 'IdDescending'. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release definition(s) .EXAMPLE Returns AP variable group list for 'myFirstProject'. Get-APVariableGroupList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups/get%20variable%20groups?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $GroupName, [Parameter()] [string] [ValidateSet('manage', 'none', 'use')] $ActionFilter, [Parameter()] [int] $Top, [Parameter()] [int] $ContinuationToken, [Parameter()] [ValidateSet('idAscending', 'idDescending')] [string] $QueryOrder ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-variablegroups' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.continuationToken) { $results.value $null = $PSBoundParameters.Remove('ContinuationToken') Get-APVariableGroupList @PSBoundParameters -ContinuationToken $results.continuationToken } elseIf ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Get-APWidget.ps1 function Get-APWidget { <# .SYNOPSIS Returns Azure Pipeline widget from a dashboard. .DESCRIPTION Returns Azure Pipeline widget from a dashboard based by dashboard id. The id can be retrieved by using Get-APDashboardList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DashboardId ID of the dashboard to read. .PARAMETER WidgetId ID of the widget. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines widget. .EXAMPLE Returns the Azure Pipelines widget with the id of '7938afd-d935-4731-ihdo-5149849181' from the dashboard with the id of '1238afd-d935-4731-ac6e-154888894b304'. Get-APWidget -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DashboardId '1238afd-d935-4731-ac6e-154888894b304' -WidgetId '7938afd-d935-4731-ihdo-5149849181' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/widgets/get%20widget?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $DashboardId, [Parameter(Mandatory)] [string] $WidgetId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'dashboard-widgetId') -f $DashboardId, $WidgetId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APWidgetList.ps1 function Get-APWidgetList { <# .SYNOPSIS Returns a list of Azure Pipeline widgets. .DESCRIPTION Returns a list of Azure Pipeline widgets based on the dashboard id. The id can be retrieved by using Get-APWidgetList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DashboardId ID of the dashboard to read. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines widget(s). .EXAMPLE Returns a list of Azure DevOps widgets for the 'myFirstProject. Get-APWidgetList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/widgets/get%20widgets?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $DashboardId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'dashboard-widgets') -f $DashboardId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APWorkItem.ps1 function Get-APWorkItem { <# .SYNOPSIS Returns Azure Pipeline work item. .DESCRIPTION Returns Azure Pipeline work item based by work item id. The id can be retrieved by using Get-APWorkItemList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER WorkItemId The id of the work item. .PARAMETER Expand The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. .PARAMETER AsOf AsOf UTC date time string .PARAMETER Fields Comma-separated list of requested fields .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines work item(s). .EXAMPLE Returns the workitem with the id of '7' for the 'myFirstProject. Get-APWorkItem -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -WorkItemId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/get%20work%20item?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $WorkItemId, [Parameter()] [ValidateSet('all', 'fields', 'links', 'none', 'relations')] [string] $Expand, [Parameter()] [string] $AsOf, [Parameter()] [string[]] $Fields ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-workitemId') -f $WorkItemId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APWorkItemList.ps1 function Get-APWorkItemList { <# .SYNOPSIS Returns a list of Azure Pipeline work item list. .DESCRIPTION Returns a list of Azure Pipeline work item list. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Ids The comma-separated list of requested work item ids. (Maximum 200 ids allowed). .PARAMETER Expand The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. .PARAMETER AsOf AsOf UTC date time string .PARAMETER ErrorPolicy The flag to control error policy in a bulk get work items request. Possible options are {Fail, Omit}. .PARAMETER Fields Comma-separated list of requested fields Undocumented .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines work item(s). .EXAMPLE Returns the workitem with the id of '7' for the 'myFirstProject. Get-APWorkItem -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -WorkItemId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/get%20work%20item?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int[]] $Ids, [Parameter()] [ValidateSet('all', 'fields', 'links', 'none', 'relations')] [string] $Expand, [Parameter()] [string] $AsOf, [Parameter()] [ValidateSet('error', 'omit')] [string] $ErrorPolicy, [Parameter()] [string[]] $Fields ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'wit-workitems' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APWorkItemTypeCategoriesList.ps1 function Get-APWorkItemTypeCategoriesList { <# .SYNOPSIS Returns a list of Azure Pipeline work item types categories. .DESCRIPTION Returns a list of Azure Pipeline work item types categories. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines work item type categories list. .EXAMPLE Returns AP work item type category list for 'myProject' Get-APWorkItemCategoriesList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20item%20type%20categories/list?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'wit-workitemtypecategories' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Get-APWorkItemTypeList.ps1 function Get-APWorkItemTypeList { <# .SYNOPSIS Returns a list of Azure Pipeline work item types. .DESCRIPTION Returns a list of Azure Pipeline work item types based on a process id. The process id can be retrieved by using Get-APProcessList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProcessId The id of the process. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines field(s) .EXAMPLE Returns AP work item type list for 'myCollection' Get-APWorkItemTypeList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ProcessId 00000000-00000-0000-00000-0000000000 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/work%20item%20types/list?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProcessId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-workitemtypes') -f $ProcessId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Install-APAgent.ps1 Function Install-APAgent { <# .SYNOPSIS Installs a Azure Pipelines agent on the server executing the function. .DESCRIPTION Installs a Azure Pipelines agent. The agent can be configured to listen to a pool or a deployment group. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Pool The pool name. .PARAMETER DeploymentGroupName The deployment group name. .PARAMETER DeploymentGroupTag The deployment group tags. .PARAMETER Platform Operating system platform. .PARAMETER PatAuthentication Authenticate with a personal access token. .PARAMETER IntegratedAuthentication Authenticate with a integrated credentials. .PARAMETER NegotiateAuthentication Authenticate with a negotiation, this requires a credential. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to authenticate. .PARAMETER WindowsLogonCredential Specifies a user account that will run the windows service. .PARAMETER AgentWorkingFolder Agent's working directory, this must be unique to the agent, defaults to '_work'. .PARAMETER RootAgentFolder The directory where the agent will be installed, defaults to 'Agents'. .INPUTS None, does not support pipeline. .OUTPUTS String. Install-APAgent returns log from configuration. .EXAMPLE Installs a windows deployment group agent with PAT authentication. Install-Agent -PatAuthentication -PersonalAccessToken 'myToken' -DeploymentGroupName 'Dev' -DeploymentGroupTag 'myTag' -Collection 'myCollection' -TeamProject 'AzurePipelinesPS' -Platform 'Windows' .EXAMPLE Installs a linux pool agent with negotiation authentiaction. Install-Agent -NegotiateAuthentication -Credential $pscredential -Pool 'Default' -Collection 'myCollection' -TeamProject 'AzurePipelinesPS' -Platform 'Linux' .LINK https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=vsts #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [Alias('ProxyUrl')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [ValidateSet('Windows', 'ubuntu.16.04-x64', 'ubuntu.14.04-x64')] [string] $Platform, [Parameter()] [switch] $PatAuthentication, [Parameter()] [switch] $IntegratedAuthentication, [Parameter()] [switch] $NegotiateAuthentication, [Parameter()] [string] $Pool, [Parameter()] [string] $DeploymentGroupName, [Parameter()] [string[]] $DeploymentGroupTag, [Parameter()] [pscredential] $WindowsLogonCredential, [Parameter()] [string] $AgentWorkingFolder = '_work', [Parameter()] [string] $RootAgentFolder = 'C:\agents' ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $arguments = @( "--unattended" "--projectName `"{0}`"" -f $Project "--url $Instance$Collection" "--work `"{0}`"" -f $AgentWorkingFolder "--runasservice" ) If ($Pool) { $arguments += "--pool `"{0}`"" -f $Pool } If ($DeploymentGroupName) { Write-Verbose "Configuring agent for deployment group: [$DeploymentGroupName]" $arguments += "--deploymentGroup" $arguments += "--deploymentGroupName `"{0}`"" -f $DeploymentGroupName If ($DeploymentGroupTag) { Write-Verbose ("Adding the following deployment tags: [{0}]" -f ($DeploymentGroupTag -join ', ')) $arguments += "--addDeploymentGroupTags" $arguments += ("--deploymentGroupTags `"{0}`"" -f ($DeploymentGroupTag -join ', ')) } } If ($WindowsLogonCredential.UserName) { Write-Verbose "Configuring the target agent to use a windows logon account: [$($WindowsLogonCredential.Username)]" $arguments += ("--windowsLogonAccount {0}" -f $WindowsLogonCredential.UserName) $arguments += ("--windowsLogonPassword `"{0}`"" -f $WindowsLogonCredential.GetNetworkCredential().Password) } If ($PatAuthentication) { $plainTextPat = Unprotect-APSecurePersonalAccessToken -PersonalAccessToken $PersonalAccessToken If (-not($plainTextPat)) { Write-Error "[$($MyInvocation.MyCommand.Name)]: A personal access Token is required to use PAT authentications" -ErrorAction Stop } Write-Verbose "Authenticating using [PAT]" $arguments += "--auth Pat" $arguments += "--token $plainTextPat" } If ($IntegratedAuthentication) { Write-Verbose "Authenticating using [Integrated]" $arguments += "--auth integrated" } If ($NegotiateAuthentication) { Write-Verbose "Authenticating using [Negotiate]" $arguments += "--auth negotiate" $arguments += ("--userName {0}" -f $Credential.UserName) $arguments += ("--password {0}" -f $Credential.GetNetworkCredential().Password) } If ($Proxy) { Write-Verbose "Using proxy url [$Proxy]" $arguments += "--proxyurl $Proxy" } If (-not (Test-Path $RootAgentFolder)) { Write-Verbose "Creating root agent path: [$RootAgentFolder]" $null = New-Item -ItemType Directory -Path $RootAgentFolder } Set-Location $RootAgentFolder for ($i = 1; $i -lt 100; $i++) { $destFolder = 'A' + $i.ToString() if (-not (Test-Path ($destFolder))) { Write-Verbose "Creating destination folder: [$destFolder]" $null = New-Item -ItemType Directory -Path $destFolder Set-Location $destFolder break } } # Download agent $agentZip = "$PWD\agent.zip" $securityProtocol = @() $securityProtocol += [Net.ServicePointManager]::SecurityProtocol $securityProtocol += [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = $securityProtocol $WebClient = New-Object Net.WebClient $uri = Get-APAgentPackage -Platform $Platform -Instance $Instance -ApiVersion $ApiVersion If (-not($uri)) { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate package url!" -ErrorAction Stop } If ($Proxy) { $DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy $WebClient.Proxy = New-Object Net.WebProxy($DefaultProxy.GetProxy($Proxy), $True) $WebClient.Proxy.UseDefaultCredentials = $true } Write-Verbose "Downloading agent package from: [$uri]" $WebClient.DownloadFile($uri, $agentZip) Add-Type -AssemblyName System.IO.Compression.FileSystem Write-Verbose "Extracting agent package" [System.IO.Compression.ZipFile]::ExtractToDirectory( $agentZip, "$PWD") Remove-Item $agentZip Write-Verbose "Configuring agent: [$arguments]" # Configure agent $arguments += "--agent {0}-{1}" -f $env:COMPUTERNAME, $destFolder $startprocessSplat = @{ NoNewWindow = $true Wait = $true FilePath = "$RootAgentFolder\$destFolder\config.cmd" ArgumentList = $arguments WorkingDirectory = "$RootAgentFolder\$destFolder" RedirectStandardError = 'errorResults.log' RedirectStandardOutput = 'results.log' } Start-Process @startprocessSplat Get-Content .\results.log $errorResults = Get-Content .\errorResults.log If ($errorResults) { Write-Error $errorResults } } end { } } # Install-APPSModule.ps1 function Install-APPSModule { <# .SYNOPSIS Installs a module from an Azure Pipelines feed. .DESCRIPTION Installs a module from an Azure Pipelines feed using the personal access token from the session configuration. A list of modules can be retrieved with Find-APPSModule. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name Specifies the exact names of modules to install from the online gallery. A comma-separated list of module names is accepted. The module name must match the module name in the repository. Use Find-APPSModule to get a list of module names. .PARAMETER Repository Use the Repository parameter to specify which repository is used to download and install a module. Used when multiple repositories are registered. Specifies the name of a registered repository in the Install-APPSModule command. To register a repository, use Register-APPSRepository. To display registered repositories, use Get-PSRepository. .PARAMETER Scope Specifies the installation scope of the module. The acceptable values for this parameter are AllUsers and CurrentUser. .PARAMETER RequiredVersion Specifies the exact version of a single module to install. If there is no match in the repository for the specified version, an error is displayed. If you want to install multiple modules, you cannot use RequiredVersion. .PARAMETER MaximumVersion Specifies the maximum, or latest, version of the module to include in the search results. MaximumVersion and RequiredVersion cannot be used in the same command. .PARAMETER MinimumVersion Specifies the minimum version of the module to include in results. MinimumVersion and RequiredVersion cannot be used in the same command. .PARAMETER AllowClobber Overrides warning messages about installation conflicts about existing commands on a computer. Overwrites existing commands that have the same name as commands being installed by a module. .PARAMETER SkipPublisherCheck Allows you to install a newer version of a module that already exists on your computer. For example, when an existing module is digitally signed by a trusted publisher but the new version is not digitally signed by a trusted publisher. .PARAMETER Force Installs a module and overrides warning messages about module installation conflicts. If a module with the same name already exists on the computer, Force allows for multiple versions to be installed. If there is an existing module with the same name and version, Force overwrites that version. .PARAMETER AcceptLicense For modules that require a license, AcceptLicense automatically accepts the license agreement during installation. For more information, see Modules Requiring License Acceptance. .PARAMETER AllowPrerelease Includes in the results modules marked as a pre-release. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines Module. .EXAMPLE .LINK https://docs.microsoft.com/en-us/powershell/module/powershellget/install-module?view=powershell-6 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string[]] $Name, [Parameter()] [string[]] $Repository, [Parameter()] [ValidateSet('AllUsers', 'CurrentUser')] [string] $Scope, [Parameter()] [string] $RequiredVersion, [Parameter()] [string] $MinimumVersion, [Parameter()] [string] $MaximumVersion, [Parameter()] [switch] $AllowClobber, [Parameter()] [switch] $SkipPublisherCheck, [Parameter()] [switch] $Force, [Parameter()] [switch] $AllowPrerelease, [Parameter()] [switch] $AcceptLicense ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential } } } process { If ($PersonalAccessToken) { $Credential = [pscredential]::new('NA', $PersonalAccessToken) } $installModuleSplat = @{ Name = $Name Credential = $Credential } If ($Repository) { $installModuleSplat.Repository = $Repository } If ($Scope) { $installModuleSplat.Scope = $Scope } If ($Proxy) { $installModuleSplat.Proxy = $Proxy } If ($ProxyCredential) { $installModuleSplat.ProxyCredential = $ProxyCredential } If ($SkipPublisherCheck) { $installModuleSplat.SkipPublisherCheck = $SkipPublisherCheck } If ($MinimumVersion) { $installModuleSplat.MinimumVersion = $MinimumVersion } If ($MaximumVersion) { $installModuleSplat.MaximumVersion = $MaximumVersion } If ($RequiredVersion) { $installModuleSplat.Scope = $RequiredVersion } If ($AllowPrerelease) { $installModuleSplat.AllowPrerelease = $AllowPrerelease } If ($AcceptLicense) { $installModuleSplat.AcceptLicense = $AcceptLicense } If ($AllowClobber) { $installModuleSplat.AllowClobber = $AllowClobber } If ($Force) { $installModuleSplat.Force = $Force } Install-Module @installModuleSplat } end { } } # Invoke-APNugetPackageDownload.ps1 function Invoke-APNugetPackageDownload { <# .SYNOPSIS Downloads an Azure Pipeline nuget package. .DESCRIPTION Downloads an Azure Pipeline nuget package by feed id, package name and package version. The id can be retrieved by using Get-APFeedList. The package name and version can be retrieved by using Get-APPackageList. .PARAMETER Instance The Team Services account or TFS server. For Azure DevOps the value should be https://dev.azure.com/. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId The name or id of the feed. .PARAMETER PackageName The name of the package. .PARAMETER PackageVersion The version of the package. .PARAMETER Path The directory to output the file to. .INPUTS None, does not support pipeline. .OUTPUTS None, Invoke-APNugetPackageDownload does not generate any output. .EXAMPLE Returns the build with the id of '7' for the 'myFirstProject. Invoke-APNugetPackageDownload -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 7 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifactspackagetypes/nuget/download%20package?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId, [Parameter(Mandatory)] [string] $PackageName, [Parameter(Mandatory)] [string] $PackageVersion, [Parameter(Mandatory)] [string] $Path ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $_outputPath = "{0}\{1}.{2}.nuget" -f $Path, $PackageName, $PackageVersion $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-packageContent') -f $FeedId, $PackageName, $PackageVersion $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'pkgs' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential Path = $_outputPath } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Invoke-APPipeline.ps1 function Invoke-APPipeline { <# .SYNOPSIS Queues a pipeline run by pipeline id. .DESCRIPTION Queues a pipeline run by pipeline id. The id can be returned using Get-APPipelineList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId The id of an existing pipeline. .PARAMETER PipelineVersion The version of the pipeline to queue. .PARAMETER PreviewRun If true, don't actually create a new run. Instead returen the final YAML document after parsing templates. .PARAMETER Resources The resources the run requires. .PARAMETER StagesToSkip The stages to skip. .PARAMETER TemplateParameters Runtime parameters to pass to the pipeline. .PARAMETER Variables Pipeline variables. .PARAMETER YamlOverride If you use the preview run option, you may optionally supply different YAML. This allows you to preview the final YAML document without committing a changed file. .INPUTS None, does not support pipeline. .OUTPUTS None .EXAMPLE $resources = @{ repositories = @{ self = @{ refName = 'refs/heads/feature/myFeature' } } } $stagesToSkip = @( 'Test_Build' 'Test_Deployment' ) Invoke-APPipeline -Session 'mySession -PipelineId 7 -Resources $resources -StagesToSkip $stagesToSkip .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PipelineId, [Parameter()] [int] $PipelineVersion, [Parameter()] [bool] $PreviewRun, [Parameter()] [object] $Resources, [Parameter()] [string[]] $StagesToSkip, [Parameter()] [hashtable] $TemplateParameters, [Parameter()] [hashtable] $Variables, [Parameter()] [string] $YamlOverride ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ PreviewRun = $PreviewRun } If ($PipelineVersion) { $body.PipelineVersion = $PipelineVersion } If ($Resources) { $body.resources = $Resources } If ($StagesToSkip) { $body.stagesToSkip = $StagesToSkip } If ($TemplateParameters) { $body.templateParameters = $TemplateParameters } If ($Variables) { $body.variables = $Variables } If ($YamlOverride) { $body.yamlOverride = $YamlOverride } $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-runs') -f $PipelineId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Invoke-APPolicyEvaluation.ps1 function Invoke-APPolicyEvaluation { <# .SYNOPSIS Requeues a Azure Pipeline policy evaluation. .DESCRIPTION Requeues a Azure Pipeline policy evaluation by evaluation id. The id can be retrieved by using Get-APPolicyEvaluationList. Some policies define a "requeue" action which performs some policy-specific operation. You can trigger this operation by updating an existing policy evaluation and setting the PolicyEvaluationRecord.Status field to Queued. Although any policy evaluation can be requeued, at present only build policies perform any action in response. Requeueing a build policy will queue a new build to run (cancelling any existing build which is running). .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EvaluationId Id of the policy evaluation. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy evaluation(s) .EXAMPLE Requeues policy evaluation with the id of '7'. Get-APPolicyEvaluation -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -EvaluationId '7' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/evaluations/requeue%20policy%20evaluation?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EvaluationId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-evaluationId') -f $EvaluationId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Invoke-APQuery.ps1 function Invoke-APQuery { <# .SYNOPSIS Invokes an Azure Pipelines wiql query. .DESCRIPTION Creates a invoke Azure Pipelines query for the project provided. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Query The text of the WIQL query .PARAMETER Team Team ID or team name .PARAMETER Top The max number of results to return. .PARAMETER TimePrecision Whether or not to use time precision. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines query results. .EXAMPLE Invokes a wiql. $query = "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Feature'" Invoke-APQuery -Session $session -Query $query .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/wiql/query%20by%20wiql?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Query, [Parameter()] [string] $Team, [Parameter()] [int] $Top, [Parameter()] [bool] $TimePrecision ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ query = $Query } $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-wiql') -f $Query $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Invoke-APRestMethod.ps1 function Invoke-APRestMethod { <# .SYNOPSIS Invokes an Azure Pipelines PS rest method. .DESCRIPTION Invokes an Azure Pipelines PS rest method. .PARAMETER Method Specifies the method used for the web request. .PARAMETER Body Specifies the body of the request. The body is the content of the request that follows the headers. .PARAMETER ContentType Specifies the content type of the web request. If this parameter is omitted and the request method is POST, Invoke-RestMethod sets the content type to application/x-www-form-urlencoded. Otherwise, the content type is not specified in the call. .PARAMETER Uri Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent. This parameter supports HTTP, HTTPS, FTP, and FILE values. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. The default is the Personal Access Token if it is defined, otherwise it is the current user. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Path The directory to output files to. .PARAMETER Infile The fullname/path to the file that will be uploaded. .OUTPUTS System.Int64, System.String, System.Xml.XmlDocument, The output of the cmdlet depends upon the format of the content that is retrieved. .OUTPUTS PSObject, If the request returns JSON strings, Invoke-RestMethod returns a PSObject that represents the strings. .EXAMPLE Invokes AP rest method 'PATCH' against the uri 'https://dev.azure.com/release/releases?api-version=5.0-preview.6'. Invoke-APRestMethod -Method PATCH -Body $Body -ContentType 'application/json' -Uri 'https://dev.azure.com/release/releases?api-version=5.0-preview.6' .LINK https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6 #> [CmdletBinding()] Param ( [Parameter(Mandatory)] [string] $Method, [Parameter()] [object] $Body, [Parameter(Mandatory)] [uri] $Uri, [Parameter()] [string] $ContentType, [Parameter()] [Security.SecureString] $PersonalAccessToken, [Parameter()] [pscredential] $Credential, [Parameter()] [string] $Proxy, [Parameter()] [pscredential] $ProxyCredential, [Parameter()] [string] $Path, [Parameter()] [string] $InFile ) begin { } process { $invokeRestMethodSplat = @{ ContentType = $ContentType Method = $Method UseBasicParsing = $true Uri = $uri.AbsoluteUri } If ($Body) { $invokeRestMethodSplat.Body = ConvertTo-Json -InputObject $Body -Depth 20 } If ($Proxy) { $invokeRestMethodSplat.Proxy = $Proxy If ($ProxyCredential) { $invokeRestMethodSplat.ProxyCredential = $ProxyCredential } else { $invokeRestMethodSplat.ProxyUseDefaultCredentials = $true } } If ($Path) { $invokeRestMethodSplat.OutFile = $Path } If ($InFile) { $invokeRestMethodSplat.InFile = $InFile } $authenticatedRestMethodSplat = Set-APAuthenticationType -InputObject $invokeRestMethodSplat -Credential $Credential -PersonalAccessToken $PersonalAccessToken Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Invoking $($uri.AbsoluteUri)" return Invoke-RestMethod @authenticatedRestMethodSplat } end { } } # Invoke-APServiceEndpointProxyRequest.ps1 function Invoke-APServiceEndpointProxyRequest { <# .SYNOPSIS Proxy for a GET request defined by a service endpoint. .DESCRIPTION Proxy for a GET request defined by a service endpoint. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EndpointId The id of the service endpoint. .PARAMETER DataSourceDetails Gets or sets the data source details for the service endpoint request. .PARAMETER ResultTransformationDetails Gets or sets the result transformation details for the service endpoint request. .PARAMETER ServiceEndpointDetails Gets or sets the service endpoint details for the service endpoint request. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint execution record(s). .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpointproxy/execute%20service%20endpoint%20request?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EndpointId, [Parameter(Mandatory)] [object] $DataSourceDetails, [Parameter(Mandatory)] [object] $ResultTransformationDetails, [Parameter(Mandatory)] [object] $ServiceEndpointDetails ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ dataSourceDetails = $DataSourceDetails } If ($ResultTransformationDetails) { $body.resultTransformationDetails = $ResultTransformationDetails } If ($ServiceEndpointDetails) { $body.serviceEndpointDetails = $ServiceEndpointDetails } $apiEndpoint = Get-APApiEndpoint -ApiType 'serviceendpoint-endpointproxy' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential Body = $body ContentType = 'application/json' } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Invoke-APWebRequest.ps1 function Invoke-APWebRequest { <# .SYNOPSIS Invokes an Azure Pipelines PS rest method. .DESCRIPTION Invokes an Azure Pipelines PS rest method. .PARAMETER Method Specifies the method used for the web request. .PARAMETER Body Specifies the body of the request. The body is the content of the request that follows the headers. .PARAMETER ContentType Specifies the content type of the web request. If this parameter is omitted and the request method is POST, Invoke-RestMethod sets the content type to application/x-www-form-urlencoded. Otherwise, the content type is not specified in the call. .PARAMETER Uri Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent. This parameter supports HTTP, HTTPS, FTP, and FILE values. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. The default is the Personal Access Token if it is defined, otherwise it is the current user. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Path The directory to output files to. .OUTPUTS System.Int64, System.String, System.Xml.XmlDocument, The output of the cmdlet depends upon the format of the content that is retrieved. .OUTPUTS PSObject, If the request returns JSON strings, Invoke-RestMethod returns a PSObject that represents the strings. .EXAMPLE Invokes AP rest method 'PATCH' against the uri 'https://dev.azure.com/release/releases?api-version=5.0-preview.6'. Invoke-APWebRequest -Method PATCH -Body $Body -ContentType 'application/json' -Uri 'https://dev.azure.com/release/releases?api-version=5.0-preview.6' .LINK https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6 #> [CmdletBinding()] Param ( [Parameter(Mandatory)] [string] $Method, [Parameter()] [object] $Body, [Parameter(Mandatory)] [uri] $Uri, [Parameter()] [string] $ContentType, [Parameter()] [Security.SecureString] $PersonalAccessToken, [Parameter()] [pscredential] $Credential, [Parameter()] [string] $Proxy, [Parameter()] [pscredential] $ProxyCredential, [Parameter()] [string] $Path ) begin { } process { $invokeRestMethodSplat = @{ ContentType = $ContentType Method = $Method UseBasicParsing = $true Uri = $uri.AbsoluteUri } If ($Body) { $invokeRestMethodSplat.Body = ConvertTo-Json -InputObject $Body -Depth 20 } If ($Proxy) { $invokeRestMethodSplat.Proxy = $Proxy If ($ProxyCredential) { $invokeRestMethodSplat.ProxyCredential = $ProxyCredential } else { $invokeRestMethodSplat.ProxyUseDefaultCredentials = $true } } If ($Path) { $invokeRestMethodSplat.OutFile = $Path } $authenticatedRestMethodSplat = Set-APAuthenticationType -InputObject $invokeRestMethodSplat -Credential $Credential -PersonalAccessToken $PersonalAccessToken $results = Invoke-WebRequest @authenticatedRestMethodSplat If (@(200, 201) -contains $results.StatusCode) { $content = ($results.Content | ConvertFrom-Json) If ($content) { If ($results.Headers.'X-MS-ContinuationToken') { If ($content.value) { $continuationToken = $results.Headers.'X-MS-ContinuationToken' if ($continuationToken -is [array]) { $continuationToken = $continuationToken[0] } return @{ continuationToken = $continuationToken count = $content.count value = $content.value } } else { $continuationToken = $results.Headers.'X-MS-ContinuationToken' if ($continuationToken -is [array]) { $continuationToken = $continuationToken[0] } return @{ continuationToken = $continuationToken value = $content } } } else { If ($content.value) { return @{ count = $content.count value = $content.value } } else { return @{ value = $content } } } } else { return } } } end { } } # New-APBuild.ps1 function New-APBuild { <# .SYNOPSIS Creates an Azure Pipeline build. .DESCRIPTION Creates an Azure Pipeline build by build definition name. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the build definition to queue. .PARAMETER Path The path of the build definition to queue. .PARAMETER IgnoreWarnings Undocumented. .PARAMETER CheckInTicket Undocumented. .PARAMETER SourceBuildId Undocumented. .PARAMETER SourceBranch The branch to get sources. .PARAMETER Parameters The build parameters. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build. .EXAMPLE Queue a build named 'myBuild' with the parameter 'myParam' equal to 'myValue'. The parameter must be definied in the build definition in order to pass it a value. New-APBuild -Session 'mySession' -Name 'myBuild' -Parameters @{myParam = 'myValue'} .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [string] $Path, [Parameter()] [bool] $IgnoreWarnings, [Parameter()] [string] $CheckInTicket, [Parameter()] [int] $SourceBuildId, [Parameter()] [string] $SourceBranch, [Parameter()] [hashtable] $Parameters ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $getAPBuildDefinitionListSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion Name = $Name } If ($Credential) { $getAPBuildDefinitionListSplat.Credential = $Credential } If ($PersonalAccessToken) { $getAPBuildDefinitionListSplat.PersonalAccessToken = $PersonalAccessToken } If ($Proxy) { $getAPBuildDefinitionListSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPBuildDefinitionListSplat.ProxyCredential = $ProxyCredential } If ($Path) { $getAPBuildDefinitionListSplat.Path = $Path } $definition = Get-APBuildDefinitionList @getAPBuildDefinitionListSplat Foreach ($_definition in $definition) { $body = @{ definition = $_definition } If ($SourceBranch) { $body.SourceBranch = $SourceBranch } If ($Parameters) { $body.parameters = ($Parameters | Convertto-Json -Compress) } $apiEndpoint = Get-APApiEndpoint -ApiType 'build-builds' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } } end { } } # New-APDashboard.ps1 function New-APDashboard { <# .SYNOPSIS Creates a new Azure Pipelines dashboard. .DESCRIPTION Creates a new Azure Pipelines dashboard for the project provided. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the dashboard. .PARAMETER Widget The widget object to create the dashboard's widgets. .PARAMETER Owner The owners name. .PARAMETER RefreshInterval Interval for client to automatically refresh the dashboard. Expressed in minutes. .PARAMETER DashboardScope Entity to which the dashboard is scoped. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines dashboard. .EXAMPLE Creates a dashboard with the name of 'myFirstDashboard' for 'myFirstProject' New-APDashboard -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Name 'myFirstDashboard' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/dashboards/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [object] $Widget, [Parameter()] [string] $Owner, [Parameter()] [int] $RefreshInterval, [Parameter()] [ValidateSet('project', 'project_team', 'collection_User', '')] [string] $DashboardScope = 'project' ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ Name = $Name dashboardScope = $DashboardScope } if ($Widget) { $body.widgets = $Widget } if ($Owner) { $body.ownerId = $Owner } if ($RefreshInterval) { $body.refreshInterval = $RefreshInterval } $apiEndpoint = Get-APApiEndpoint -ApiType 'dashboard-dashboards' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APEnvironment.ps1 function New-APEnvironment { <# .SYNOPSIS Creates an Azure Pipeline environment. .DESCRIPTION Creates an Azure Pipeline environment by environment name. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the environment to create. .PARAMETER Description The description of the environment to create. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines environment. .EXAMPLE Creates an Azure DevOps environment named 'myEnvironment'. New-APEnvironment -Session 'mySession' -Name 'myEnvironment' -Description 'my environment description' .LINK Undocumented at the time this was created. #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [string] $Description ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ name = $Name description = $Description } $apiEndpoint = Get-APApiEndpoint -ApiType 'distributedtask-environments' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # New-APEnvironmentApproval.ps1 function New-APEnvironmentApproval { <# .SYNOPSIS Creates an Azure Pipeline environment approval. .DESCRIPTION Creates an Azure Pipeline environment approval based on environment id. The id can be retrieved with Get-APEnvironment. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PrincipalName The principal name of the user or group to add to the approval. .PARAMETER EnvironmentId The name or id of the environment to create the approval for. .PARAMETER TimeoutDays The number of days before the approval times out. .PARAMETER Instructions The instructions provided to the approver upon approval request. .PARAMETER ExecutionOrder The order in which the approvals should be enforced, any or specific. .PARAMETER RequiredNumberOfApprovers The number of approvers required, specify 0 to require all approvers, defaults to 1. .PARAMETER RequesterCannotBeApprover Bool, the requester cannot be approver. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines environment. .EXAMPLE Creates an Azure DevOps environment approval for 'My DisplayName'. New-APEnvironmentApproval -Session $session -DisplayName 'My DisplayName' -EnvironmentId 2 -TimeoutDays 3 -ExecutionOrder Any -RequiredNumberOfApprovers 0 -RequesterCannotBeApprover $true .LINK Undocumented at the time this was created. #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string[]] $PrincipalName, [Parameter(Mandatory)] [string] $EnvironmentId, [Parameter(Mandatory)] [ValidateRange(1, 30)] [string] $TimeoutDays, [Parameter()] [string] $Instructions, [Parameter(Mandatory)] [ValidateSet('Any', 'Specifc')] [string] $ExecutionOrder, [Parameter()] [int] $RequiredNumberOfApprovers = 1, [Parameter()] [bool] $RequesterCannotBeApprover ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { Enum executionOrder { Any = 0 Specifc = 1 } $apSplat = @{ Instance = $Instance Collection = $Collection ApiVersion = $ApiVersion ErrorAction = 'Stop' } If ($PersonalAccessToken) { $apSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $apSplat.Credential = $Credential } If ($Proxy) { $apSplat.Proxy = $Proxy } If ($ProxyCredential) { $apSplat.ProxyCredential = $ProxyCredential } $apEnvironment = Get-APEnvironment @apSplat -EnvironmentId $EnvironmentId -Project $Project $userList = Get-APUserList @apSplat | Where-Object { $PrincipalName -Contains $PSitem.principalName } [array] $approvers = Foreach ($user in $userList) { @{ displayName = $user.displayName id = (Get-APStorageKey @apSplat -SubjectDescriptor $user.descriptor) descriptor = $user.descriptor imageUrl = $user.imageUrl uniqueName = $user.principalName } } $groupList = Get-APGroupList @apSplat | Where-Object { $PrincipalName -Contains $PSitem.principalName } $approvers += Foreach ($group in $groupList) { @{ displayName = $group.displayName id = (Get-APStorageKey @apSplat -SubjectDescriptor $group.descriptor) descriptor = $group.descriptor imageUrl = $group.imageUrl uniqueName = $group.principalName } } $body = @{ settings = @{ approvers = $approvers executionOrder = [int] [executionOrder].$ExecutionOrder minRequiredApprovers = $RequiredNumberOfApprovers instructions = $Instructions requesterCannotBeApprover = $RequesterCannotBeApprover blockedApprovers = @() } type = @{ name = 'Approval' id = '8C6F20A7-A545-4486-9777-F762FAFE0D4D' } resource = @{ type = 'environment' id = $apEnvironment.Id name = $apEnvironment.Name } timeout = (New-TimeSpan -Days $TimeoutDays).TotalMinutes } $apiEndpoint = Get-APApiEndpoint -ApiType 'pipelines-configurations' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # New-APFeed.ps1 function New-APFeed { <# .SYNOPSIS Create a feed, a container for various package types. .DESCRIPTION Create a feed, a container for various package types. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name A name for the feed. feed names must follow these rules: Must not exceed 64 characters Must not contain whitespaces Must not start with an underscore or a period Must not end with a period Must not contain any of the following illegal characters: , |, /, \\, ?, :, &, $, *, \", #, [, ] ]]> .PARAMETER FeedCapabilities Supported capabilities of a feed. .PARAMETER Description A description for the feed. Descriptions must not exceed 255 characters. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines feed. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed%20%20management/create%20feed?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [ValidateSet('defaultCapabilities', 'none', 'underMaintenance', 'upstreamV2')] [string] $FeedCapabilities, [Parameter()] [string] $Description ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ Name = $Name } If ($FeedCapabilities) { $body.FeedCapabilities = $FeedCapabilities } If ($Description) { $body.Description = $Description } $apiEndpoint = Get-APApiEndpoint -ApiType 'feed-feeds' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'feeds' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APGitBranch.ps1 function New-APGitBranch { <# .SYNOPSIS Creates an Azure Pipeline Git branch. .DESCRIPTION Creates an Azure Pipeline Git branch based on the object id. The object id can be retrieved by using Get-APGitRefList. A commit is required to create a new branch so this command creates and removes a file named after a randomly generated guid. Both commits can be seen in the new branch's history. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The name or ID of the repository. .PARAMETER ObjectId The branch object id to create the new branch from. Use Get-APGitRefList to identify the object id. .PARAMETER BranchName The new branch name. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines Git ref. .EXAMPLE Creates a new git branch in the 'myRepository' with the name of 'myNewBranch' based on the branch object id of '50114dacf4ed256f37e397ded65188400d84b0831bd' New-APGitBranch -Session 'mySession' -RepositoryId 'myRepository' -BranchName 'refs/heads/myNewBranch' -OldObjectId '50114dacf4ed256f37e397ded65188400d84b0831bd' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId, [Parameter(Mandatory)] [string] $ObjectId, [Parameter(Mandatory)] [string] $BranchName ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { # Path is used to create a file at the root of the repository and then remove it. $path = "/{0}" -f (New-Guid).Guid $body = @{ refUpdates = @( @{ name = $BranchName oldObjectId = $ObjectId } ) commits = @( @{ comment = "Created a new file $path" changes = @( @{ changeType = 'add' item = @{ path = $path } newContent = @{ content = "# $BranchName" contentType = 'rawtext' } } ) } ) } $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-pushes') -f $RepositoryId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results) { $removeAPGitFileSplat = @{ Instance = $Instance Collection = $Collection Project = $Project ApiVersion = $ApiVersion RepositoryId = $RepositoryId BranchName = $BranchName ObjectId = $results.refUpdates.newObjectId Path = $path } If ($PersonalAccessToken) { $removeAPGitFileSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $removeAPGitFileSplat.Credential = $Credential } If ($Proxy) { $removeAPGitFileSplat.Proxy = $Proxy } If ($ProxyCredential) { $removeAPGitFileSplat.ProxyCredential = $ProxyCredential } Remove-APGitFile @removeAPGitFileSplat } } end { } } # New-APGitPullRequest.ps1 function New-APGitPullRequest { <# .SYNOPSIS Creates an Azure Pipeline Git Pull Request. .DESCRIPTION Creates an Azure Pipeline Git Pull Request based on the source branch. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The name or ID of the repository. .PARAMETER SourceBranchRef The source branch ref to create the new pull request from. Use Get-APGitRefList to identify the object id. .PARAMETER TargetBranchRef The target branch ref to create the new pull request to. Use Get-APGitRefList to identify the object id. .PARAMETER Title The new pull request title. .PARAMETER Description The new pull request description. .PARAMETER IsDraft The create pull request on draft mode .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines Git ref. .EXAMPLE Creates a new git pull request in the 'myRepository' with the name of 'myNewPullRequest' based on the source branch feat/new-ui to branch main New-APGitPullRequest -Session 'mySession' -RepositoryId 'myRepository' ` -SourceBranchRef 'refs/heads/feat/new-ui' -TargetBranchRef 'refs/heads/main' ` -Title "New UI" -Description "New UI for application" .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId, [Parameter(Mandatory)] [string] $SourceBranchRef, [Parameter(Mandatory)] [string] $TargetBranchRef, [Parameter(Mandatory)] [string] $Title, [string] $Description, [switch] $IsDraft ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ sourceRefName = $SourceBranchRef targetRefName = $TargetBranchRef title = $Title } If ($Description) { $body.description = $Description } If ($IsDraft) { $body.IsDraft = $true } $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-pullRequests') -f $RepositoryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APGroup.ps1 function New-APGroup { <# .SYNOPSIS Create a new Azure DevOps group or materialize an existing AAD group. .DESCRIPTION The body of the request must be a derived type of GraphGroupCreationContext: GraphGroupVstsCreationContext - Create a new Azure DevOps group that is not backed by an external provider. GraphGroupMailAddressCreationContext - Create a new group using the mail address as a reference to an existing group from an external AD or AAD backed provider. GraphGroupOriginIdCreationContext - Create a new group using the OriginID as a reference to a group from an external AD or AAD backed provider. Optionally, you can add the newly created group as a member of an existing Azure DevOps group and/or specify a custom storage key for the group. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PrincipalName The principal name of the group. .PARAMETER ScopeDescriptor A descriptor referencing the scope (collection, project) in which the group should be created. If omitted, will be created in the scope of the enclosing account or organization. Valid only for VSTS groups. .PARAMETER GroupDescriptors A comma separated list of descriptors referencing groups you want the graph group to join .PARAMETER StorageKey Optional: If provided, we will use this identifier for the storage key of the created group .PARAMETER OriginId The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. .PARAMETER DisplayName The displayname of the group. .PARAMETER Description The description of the group. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines variable group. .EXAMPLE Gets Azure AD group and creates the group in Azure DevOps. $adGroup = Get-AzureADGroup -SearchString 'ADO_IntegrationServices_PreDeploymentApproval' New-APGroup -Session 'mySession' -OriginId $adGroup.ObjectId -Verbose .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/groups/create?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $PrincipalName, [Parameter()] [string] $ScopeDescriptor, [Parameter()] [string[]] $GroupDescriptors, [Parameter()] [string] $StorageKey, [Parameter()] [string] $OriginId, [Parameter()] [string] $DisplayName, [Parameter()] [string] $Description ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ } If ($PrincipalName) { $body.principalName = $PrincipalName } If ($StorageKey) { $body.StorageKey = $StorageKey } If ($OriginId) { $body.originId = $OriginId } If ($DisplayName) { $body.displayName = $DisplayName } If ($Description) { $body.description = $Description } $apiEndpoint = Get-APApiEndpoint -ApiType 'graph-groups' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APGroupMembershipReport.ps1 Function New-APGroupMembershipReport { <# .SYNOPSIS Returns all members for a group(s). .DESCRIPTION Returns all members for a group(s), based on a filter. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Filter A where object filter to filter all groups. $Filter = { $PSitem.principalName -match '_Administrators' } .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Group and it's members .EXAMPLE New-APGroupMembershipReport -Session 'mySession' -Filter { $_.principalname -like '*Project Administrators' } -Verbose #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [scriptblock] $Filter ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $splat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion } If ($Credential) { $splat.Credential = $Credential } If ($PersonalAccessToken) { $splat.PersonalAccessToken = $PersonalAccessToken } If ($Proxy) { $splat.Proxy = $Proxy } If ($ProxyCredential) { $splat.ProxyCredential = $ProxyCredential } $allGroups = Get-APGroupList @splat $allUsers = Get-APUserList @splat if ($Filter) { $groups = $allGroups | Where-Object -FilterScript $Filter | Sort-Object -Property 'principalName' } else { $groups = $allGroups } Foreach ($group in $groups) { Write-Verbose "[$($MyInvocation.MyCommand.Name)]: Processing [$($group.principalName)]" $members = Get-APGroupMembershipList @splat -SubjectDescriptor $group.descriptor -Direction down $groupMembers = Foreach ($member in $members) { If ($member.memberDescriptor) { Switch -Wildcard ($member.memberDescriptor) { 'aad.*' { $memberName = $allUsers.Where( { $PSitem.descriptor -eq $member.memberDescriptor }).principalName break } '*gp.*' { $memberName = $allGroups.Where( { $PSitem.descriptor -eq $member.memberDescriptor }).principalName break } Default { Write-Warning "[$($MyInvocation.MyCommand.Name)]: [$($member.memberDescriptor)] did not match." } } $memberName } } @{ Group = $group.principalName Members = $groupMembers } } } end { } } # New-APInstalledExtensionDocument.ps1 function New-APInstalledExtensionDocument { <# .SYNOPSIS Creates an Azure Pipeline installed extension document. .DESCRIPTION Creates an Azure Pipeline installed extension document, that is stored as json. The extension details can be retrieved by using Get-APInstalledExtensionList. The document id can be retrieced by using Get-APInstalledExtensionDocumentList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER ScopeType The scope of where the document is stored. Can be Default or User. .PARAMETER ScopeValue The value of the scope where the document is stored. Can be Current or Me. .PARAMETER DocumentCollection The name of the document collection. .PARAMETER InputObject The document object to be added. Converted and stored as json. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension document(s). .EXAMPLE Creates the WindowsServiceManager extension document. Get-APInstalledExtensionDocument -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' -Published 'MDSolutions' -ScopeType 'Default' -ScopeValue 'Current' -InputObject @{key1:value1;key2:value2} .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter(Mandatory)] [ValidateSet('Default', 'User')] [string] $ScopeType, [Parameter(Mandatory)] [ValidateSet('Current', 'Me')] [string] $ScopeValue, [Parameter(Mandatory)] [string] $DocumentCollection, [Parameter(Mandatory)] [object] $InputObject ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $InputObject $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-collection') -f $PublisherName, $ExtensionName, $ScopeType, $ScopeValue, $DocumentCollection $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential Body = $body ContentType = 'application/json' } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APNode.ps1 function New-APNode { <# .SYNOPSIS Creates an Azure Pipeline node. .DESCRIPTION Creates an Azure Pipeline node by node name. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The new node's name. .PARAMETER StructureGroup Structure group of the classification node. Options are areas or iterations. .PARAMETER Path Path of the classification node. .PARAMETER Attributes Dictionary that has node attributes like start/finish date for iteration nodes. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines node. .EXAMPLE Creates a new node named 'myNode' for a project named 'myProject' New-APNode -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -Name 'myNode' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/create%20or%20update?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter(Mandatory)] [ValidateSet('areas', 'iterations')] [string] $StructureGroup, [Parameter()] [string] $Path, [Parameter()] [object] $Attributes ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ name = $Name } If ($Attributes) { $body.attributes = $Attributes } $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-path') -f $StructureGroup, $Path $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # New-APNotificationSubscription.ps1 function New-APNotificationSubscription { <# .SYNOPSIS Creates a new notification subscription. .DESCRIPTION Creates a new notification subscription. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubscriberFlags The flags that determine the type of notification delivery. .PARAMETER Template The template provided by Get-APNotificationSubscriptionList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines subscription list. .EXAMPLE Creates a 'build failure' subscription for a list of teams. The subscription will send a notification to the entire team if a build fails. # Gets a list of teams and outputs it to grid view, the grid view acts as pick list. $teams = (Get-APTeamList -Session $session | Out-GridView -PassThru) Foreach ($_team in $teams) { # Get the build fails notification subscription template. $template = Get-APNotificationSubscriptionTemplateList -Session $session | Where-Object { $PSitem.Description -match 'build fails' } # Add the team as the subscription subscriber to the template. $template | Add-Member -NotePropertyName 'Subscriber' -NotePropertyValue $_team # Add the teams project id as the scope id to the template. $template | Add-Member -NotePropertyName 'Scope' -NotePropertyValue @{ Id = $_team.ProjectId } # Add the channel type to the template. $template | Add-Member -NotePropertyName 'Channel' -NotePropertyValue @{type = 'Group'; useCustomAddress = $false } # Create the notification subscription from the template with the 'isTeam' flag. New-APNotificationSubscription -Session $session -Template $template -SubscriberFlags 'isTeam' } .EXAMPLE Creates a 'build failure' subscription for a list of teams. The subscription will send a notification to the members of the team's role. Roles: Last changes by Requested by Requested for Deleted by # Gets a list of teams and outputs it to grid view, the grid view acts as pick list. $teams = (Get-APTeamList -Session $session | Out-GridView -PassThru) Foreach ($_team in $teams) { # Get the build fails notification subscription template. $template = Get-APNotificationSubscriptionTemplateList -Session $session | Where-Object { $PSitem.Description -match 'build fails' } # Add the team as the subscription subscriber to the template. $template | Add-Member -NotePropertyName 'Subscriber' -NotePropertyValue $_team # Add the teams project id as the scope id to the template. $template | Add-Member -NotePropertyName 'Scope' -NotePropertyValue @{ Id = $_team.ProjectId } # Add the channel type to the template. $template | Add-Member -NotePropertyName 'Channel' -NotePropertyValue @{type = 'User'; useCustomAddress = $false } # Updates the filter from expression to 'Actor'. $template.Filter | Add-Member -NotePropertyName 'type' -NotePropertyValue 'Actor' -Force # Updates the filter inclusions to include the roles. $template.Filter | Add-Member -NotePropertyName 'inclusions' -NotePropertyValue @("lastChangedBy", "requestedBy", "requestedFor", "deletedBy") -Force # Updates the filter exclusions to exclude none. $template.Filter | Add-Member -NotePropertyName 'exclusions' -NotePropertyValue @() -Force # Create the notification subscription from the template with the 'isTeam' flag. New-APNotificationSubscription -Session $session -Template $template -SubscriberFlags 'isTeam' } .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/notification/subscriptions/get%20subscription%20templates?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [ValidateSet('deliveryPreferencesEditable', 'isGroup', 'isTeam', 'isUser', 'none', 'supportsEachMemberDelivery', 'supportsNoDelivery', 'supportsPreferredEmailAddressDelivery')] [string] $SubscriberFlags, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $Template | Add-Member -NotePropertyName 'SubscriberFlags' -NotePropertyValue $SubscriberFlags -Force $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'notification-subscriptions' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APPermissionReport.ps1 function New-APPermissionReport { <# .SYNOPSIS Request to create an Azure Pipeline permission report. .DESCRIPTION Request to create an Azure Pipeline permission report asyncronously. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER InputObject See doucmentation for input object format: https://docs.microsoft.com/en-us/rest/api/azure/devops/permissionsreport/permissions%20report/create?view=azure-devops-rest-6.0#request-body. Example: @{ descriptors = @() reportName = 'myFirstPermissionReport' resources = @( @{ resourceId = 'myTeamProjectName/myRepoName' resourceName = 'myRepoName' resourceType = 'repo' } ) } .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build. .EXAMPLE Request a permissions report to be created. New-APPermissionReport -Session 'mySession' -InputObject @{ descriptors = @() reportName = 'myFirstPermissionReport' resources = @( @{ resourceId = 'myTeamProjectName/myRepoName' resourceName = 'myRepoName' resourceType = 'repo' } ) } .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/permissionsreport/permissions%20report/create?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [object] $InputObject ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $InputObject $apiEndpoint = Get-APApiEndpoint -ApiType 'permissions' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # New-APPipeline.ps1 function New-APPipeline { <# .SYNOPSIS Queues an Azure Pipeline pipeline run. .DESCRIPTION Queues an Azure Pipeline pipeline run based on a pipeline id. The pipeline id can be returned with Get-APPipelineList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId Id of the pipeline. .PARAMETER PipelineVersion The pipeline version. .PARAMETER PreviewRun If true, don't actually create a new run. Instead, return the final YAML document after parsing templates .PARAMETER Resources The resources the run requires. .PARAMETER StagesToSkip List of stage names to skip. .PARAMETER TemplateParameters Undocumented. .PARAMETER Variables Undocumented. .PARAMETER YamlOverride If you use the preview run option, you may optionally supply different YAML. This allows you to preview the final YAML document without committing a changed file. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines pipeline(s) .EXAMPLE Queues an Azure Pipeline pipeline run for 'myFirstProject' with the pipeline id of '7'. Get-APPipelineList -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PipelineId 7 -RunId 8 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $PipelineId, [Parameter()] [int] $PipelineVersion, [Parameter()] [switch] $PreviewRun, [Parameter()] [object] $Resources, [Parameter()] [string[]] $StagesToSkip, [Parameter()] [object] $TemplateParameters, [Parameter()] [string] $Variables, [Parameter()] [string] $YamlOverride ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ previewRun = $PreviewRun.IsPresent resources = $Resources stagesToSkip = $StagesToSkip templateParameters = $TemplateParameters variables = $Variables yamlOverride = $yamlOverride } $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-runs') -f $PipelineId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APPolicyConfiguration.ps1 function New-APPolicyConfiguration { <# .SYNOPSIS Creates an Azure Pipeline policy configuration of a given policy type. .DESCRIPTION Creates an Azure Pipeline policy configuration of a given policy type. The type can be retrieved by using Get-APPolicyTypeList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template A policy template. A modified policy type object. The policy type can be retrived with Get-APPolicyTypeList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy configuration(s) .EXAMPLE Creates a policy configuration with a single minimum reviewer. The scope will need updated to be applied to a specific repository. $session = 'mySession' $types = Get-APPolicyTypeList -Session $session $template = @{ isEnabled = $true isBlocking = $false type = $types.Where( {$PSitem.DisplayName -eq 'Minimum number of reviewers'}) | Select-Object -Property 'Id' settings = @{ minimumApproverCount = 1 creatorVoteCounts = $false scope = @( @{ repositoryId = $null refName = 'refs/heads/master' matchKind = 'exact' } ) } } New-APPolicyConfiguration -Session $Session -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/create?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [object] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'policy-configurations' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APProject.ps1 function New-APProject { <# .SYNOPSIS Queues an Azure Pipeline project to be created. .DESCRIPTION Queues an Azure Pipeline project to be created. Use the Get-APOperation or Wait-APOperation with the operation id returned from this command to periodically check for create project status. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the project to create. .PARAMETER Description The description of the project. .PARAMETER Visibility The project's visability, public or private. .PARAMETER SourceControlType The type of source control to configure the project with, git of tfvc. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines operation status. .EXAMPLE Creates a project named 'myProject' New-APBuild -Session 'mySession' -Name 'myProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/projects/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter(Mandatory)] [string] $Description, [Parameter(Mandatory)] [ValidateSet('public', 'private')] [string] $Visibility, [Parameter(Mandatory)] [ValidateSet('git', 'tfvc')] [string] $SourceControlType ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ name = $Name description = $Description visibility = $Visibility capabilities = @{ versioncontrol = @{ sourceControlType = $SourceControlType } processTemplate = @{ templateTypeId = '6b724908-ef14-45cf-84f8-768b5384da45' } } } $apiEndpoint = Get-APApiEndpoint -ApiType 'project-projects' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # New-APQuery.ps1 function New-APQuery { <# .SYNOPSIS Creates a new Azure Pipelines query. .DESCRIPTION Creates a new Azure Pipelines query for the project provided. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER QueryId The parent id or path under which the query is to be created. .PARAMETER Name The name of the query. .PARAMETER IsFolder Is the query a folder. .PARAMETER ValidateWiqlOnly If you only want to validate your WIQL query without actually creating one, set it to true. Default is false. .PARAMETER Wiql The WIQL text of the query. .PARAMETER QueryType The type of query, flat, oneHop or tree. .PARAMETER Children The child query items inside a query folder. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines query. .EXAMPLE Creates a query folder under the 'Shared Queries' folder. New-APQuery -Session $session -QueryId 'Shared Queries' -Name 'New Query Folder' -IsFolder $true .EXAMPLE Validate wiql only. $wiql = "a Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Feature'" New-APQuery -Session $session -QueryId 'Shared Queries' -Wiql $wiql -ValidateWiqlOnly $true .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/queries/create?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $QueryId, [Parameter()] [string] $Name, [Parameter()] [bool] $IsFolder, [Parameter()] [bool] $ValidateWiqlOnly, [Parameter()] [string] $Wiql, [Parameter()] [ValidateSet('flat', 'oneHop', 'tree')] [string] $QueryType, [Parameter()] [object] $Children ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ isFolder = $IsFolder } If ($Name) { $body.name = $Name } If ($Wiql) { $body.wiql = $Wiql } If ($QueryType) { $body.queryType = $QueryType } If ($Children) { $body.children = $Children $body.hasChildren = $true } $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-queryId') -f $QueryId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APRelease.ps1 function New-APRelease { <# .SYNOPSIS Creates an Azure Pipeline release. .DESCRIPTION Creates an Azure Pipeline release by definition id. The id can be retrieved by using Get-APReleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionId Sets definition Id to create a release. .PARAMETER BuildId Id of the build to use as the artifact source, defaults to the latest build id. The buildId parameter does not support releases with multiple artifacts. .PARAMETER Description Sets description to create a release. .PARAMETER Reason Sets reason to create a release. .PARAMETER ManualEnvironments Sets list of environments to manual as condition. .PARAMETER IsDraft Sets 'true' to create release in draft mode, 'false' otherwise, defaults to 'false'. .PARAMETER Variables Sets list of release variables to be overridden at deployment time. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines variable group. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DefinitionId, [Parameter()] [int] $BuildId, [Parameter()] [string] $Description, [Parameter()] [ValidateSet('continuousIntegration', 'manual', 'none', 'pullRequest', 'schedule')] [string] $Reason, [Parameter()] [string[]] $ManualEnvironments, [Parameter()] [string] $IsDraft = $false, [Parameter()] [hashtable] $Variables ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $getAPReleaseDefinitionSplat = @{ Collection = $Collection Project = $Project ApiVersion = $ApiVersion Instance = $Instance DefinitionId = $DefinitionId } If ($PersonalAccessToken) { $getAPReleaseDefinitionSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPReleaseDefinitionSplat.Credential = $Credential } If ($Proxy) { $getAPReleaseDefinitionSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPReleaseDefinitionSplat.ProxyCredential = $ProxyCredential } $definition = Get-APReleaseDefinition @getAPReleaseDefinitionSplat $_artifacts = @() Foreach ($artifactSource in $Definition.artifacts) { $getAPBuildDefinitionSplat = @{ Collection = $Collection Project = $Project ApiVersion = $ApiVersion Instance = $Instance Top = 1 } If ($BuildId) { $getAPBuildDefinitionSplat.BuildIds = $BuildId } else { $getAPBuildDefinitionSplat.Definitions = $artifactSource.definitionReference.definition.id } If ($PersonalAccessToken) { $getAPBuildDefinitionSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPBuildDefinitionSplat.Credential = $Credential } If ($Proxy) { $getAPBuildDefinitionSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPBuildDefinitionSplat.ProxyCredential = $ProxyCredential } $build = Get-APBuildList @getAPBuildDefinitionSplat $_artifacts += @{ alias = $artifactSource.alias instanceReference = @{ id = $build.id name = $build.buildNumber } } } $body = @{ DefinitionId = $DefinitionId Description = $Description Reason = $Reason ManualEnvironments = $ManualEnvironments isDraft = $IsDraft artifacts = $_artifacts } If ($Variables) { $_variables = @{ } Foreach ($token in $Variables.Keys) { $_variables.$token = @{ Value = $Variables.$token } } $body.Variables = $_variables } $apiEndpoint = Get-APApiEndpoint -ApiType 'release-releases' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APRepository.ps1 function New-APRepository { <# .SYNOPSIS Creates and Azure Pipeline repository. .DESCRIPTION Creates and Azure Pipeline repository. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the repository to create. .PARAMETER ParentRepository The parent repository. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Creates AP repository with the name of 'myFirstRepository' for 'myFirstProject'. New-APRepository -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Name 'myFirstRepository' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/repositories/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $getAPProjectListSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion } If ($PersonalAccessToken) { $getAPProjectListSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPProjectListSplat.Credential = $Credential } If ($Proxy) { $getAPProjectListSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPProjectListSplat.ProxyCredential = $ProxyCredential } $projectId = Get-APProjectList @getAPProjectListSplat | Where-Object { $PSItem.Name -eq $Project } | Select-Object -ExpandProperty 'id' $body = @{ name = $Name project = @{ id = $projectId } } $apiEndpoint = Get-APApiEndpoint -ApiType 'git-repositories' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APSecureFile.ps1 function New-APSecureFile { <# .SYNOPSIS Creates a new Azure DevOps secure file. .DESCRIPTION Creates a new Azure DevOps secure file. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The name of the secure file. .PARAMETER FullName The full name of the file to upload. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines secure file. .EXAMPLE Creates a secure file named settings.xml New-APSecureFile -Session 'mySession' -Name settings.xml -FullName 'c:\temp\mySettings.xml' .LINK Undocumented #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [string] $Name, [Parameter()] [string] $FullName ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'securefiles-securefiles' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken ContentType = 'application/octet-stream' Proxy = $Proxy ProxyCredential = $ProxyCredential InFile = $FullName } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APServiceEndpoint.ps1 function New-APServiceEndpoint { <# .SYNOPSIS Creates an Azure Pipeline service endpoint. .DESCRIPTION Creates an Azure Pipeline service endpoint. The type can be retrieved by using Get-APServiceEndpointTypeList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template A service endpoint template. A modified service endpoint type object. The service endpoint type can be retrived with Get-APServiceEndpointTypeList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint(s) .EXAMPLE Creates a Jenkins service endpoint called 'myNewJenkinsEndpoint' with basic authentication. $session = 'mySession' $types = Get-APServiceEndpointTypeList -Session $session $template = @{ name = 'myNewJenkinsEndpoint' description = 'My new service endpoint description' type = $types.Where( { $PSitem.DisplayName -eq 'Jenkins' }) | Select-Object -ExpandProperty 'Name' url = 'https://myJenkinsServerUrl.com' authorization = @{ scheme = 'UsernamePassword' parameters = @{ username = 'myUsername' password = 'myPassword' } } isReady = $true } New-APServiceEndpoint -Session $Session -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/create?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [object] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'serviceendpoint-endpoints' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # New-APSession.ps1 Function New-APSession { <# .SYNOPSIS Creates an Azure Pipelines session. .DESCRIPTION Creates an Azure Pipelines session. Use Save-APSession to persist the session data to disk. Save the session to a variable to pass the session to other functions. .PARAMETER SessionName The friendly name of the session. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. See example 1. .PARAMETER Project Project ID or project name. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to the project. .PARAMETER Version TFS version, this will provide the module with the api version mappings. .PARAMETER ApiVersion Version of the api to use. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Path The path where module data will be stored, defaults to $Script:ModuleDataPath. .LINK Save-APSession Remove-APSession .INPUTS None, does not support pipeline. .OUTPUTS PSObject. New-APSession returns a PSObject that contains the following: Instance Collection PersonalAccessToken .EXAMPLE Creates a session with the name of 'AzurePipelinesPS' returning it to the $session variable. $newAPSessionSplat = @{ Collection = 'myCollection' Project = 'myFirstProject' Instance = 'https://dev.azure.com/' PersonalAccessToken = 'myToken' Version = 'vNext' SessionName = 'AzurePipelinesPS' } $session = New-APSession @newAPSessionSplat .EXAMPLE Creates a session with the name of 'myFirstSession' returning it to the $session variable. Then saves the session to disk for use after the session is closed. $newAPSessionSplat = @{ Collection = 'myCollection' Project = 'myFirstProject' Instance = 'https://dev.azure.com/' PersonalAccessToken = 'myToken' Version = 'vNext' SessionName = 'myFirstSession' } $session = New-APSession @newAPSessionSplat $session | Save-APSession #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory)] [string] $SessionName, [Parameter(Mandatory)] [uri] $Instance, [Parameter(Mandatory)] [string] $Collection, [Parameter(Mandatory)] [string] $Project, [Parameter()] [ValidateSet('vNext', '2018 Update 2', '2018 RTW', '2017 Update 2', '2017 Update 1', '2017 RTW', '2015 Update 4', '2015 Update 3', '2015 Update 2', '2015 Update 1', '2015 RTW')] [Obsolete("[New-APSession]: Version has been deprecated and replaced with ApiVersion.")] [string] $Version, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [string] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter()] [string] $ApiVersion, [Parameter()] [string] $Proxy, [Parameter()] [pscredential] $ProxyCredential, [Parameter()] [string] $Path = $Script:ModuleDataPath ) Process { If ($Version) { $ApiVersion = Get-APApiVersion -Version $Version } If (-not($ApiVersion)) { Write-Error "[$($MyInvocation.MyCommand.Name)]: ApiVersion is required to create a session" -ErrorAction 'Stop' } [int] $_sessionIdcount = (Get-APSession | Sort-Object -Property 'Id' | Select-Object -Last 1 -ExpandProperty 'Id') + 1 $_session = New-Object -TypeName PSCustomObject -Property @{ Instance = $Instance Collection = $Collection Project = $Project ApiVersion = $ApiVersion SessionName = $SessionName Id = $_sessionIdcount } If ($PersonalAccessToken) { $securedPat = (ConvertTo-SecureString -String $PersonalAccessToken -AsPlainText -Force) $_session | Add-Member -NotePropertyName 'PersonalAccessToken' -NotePropertyValue $securedPat } If ($Credential) { $_session | Add-Member -NotePropertyName 'Credential' -NotePropertyValue $Credential } If ($Proxy) { $_session | Add-Member -NotePropertyName 'Proxy' -NotePropertyValue $Proxy } If ($ProxyCredential) { $_session | Add-Member -NotePropertyName 'ProxyCredential' -NotePropertyValue $ProxyCredential } If ($null -eq $Global:_APSessions) { $Global:_APSessions = @() } $Global:_APSessions += $_session return $_session } } # New-APTeam.ps1 function New-APTeam { <# .SYNOPSIS Creates an Azure Pipeline team. .DESCRIPTION Creates an Azure Pipeline team by team name. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Name The new team's name. .PARAMETER Description The decription of the team. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines team. .EXAMPLE Creates a new team named 'myTeam' for a project named 'myProject' New-APTeam -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -Name 'myTeam' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Name, [Parameter()] [string] $Description ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ name = $Name } If ($Description) { $body.description = $Description } $apiEndpoint = (Get-APApiEndpoint -ApiType 'team-projectId') -f $Project $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # New-APWorkItem.ps1 function New-APWorkItem { <# .SYNOPSIS Creates an Azure Pipeline work item. .DESCRIPTION New Azure Pipeline work item based on specific formatted body. See example for details. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Type The type of work item to create .PARAMETER Body The update patch body. See documentation for details. https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/create?view=azure-devops-rest-6.0#request-body *NOTE: body must be an array of objects* .PARAMETER Expand The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. .PARAMETER BypassRules Do not enforce the work item type rules on this update .PARAMETER SuppressNotification Do not fire any notification for this change .PARAMETER ValidateOnly Indicate if you only want to validate the changes without saving the work item. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines work item(s). .EXAMPLE New work item with the title and description defined. $body = @( @{ op = 'add' path = '/fields/System.Title' value = 'New title' } @{ op = 'add' path = '/fields/System.Description' value = 'New description' } ) New-APWorkItem -Session $session -Type 'Issue' -Body $body -Verbose .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/create?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $Type, [Parameter()] [object[]] $Body, [Parameter()] [ValidateSet('all', 'fields', 'links', 'none', 'relations')] [string] $Expand, [Parameter()] [bool] $BypassRules, [Parameter()] [bool] $SuppressNotification, [Parameter()] [bool] $ValidateOnly ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-type') -f $Type $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = [array] $Body ContentType = 'application/json-patch+json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Publish-APBuildDefinition.ps1 function Publish-APBuildDefinition { <# .SYNOPSIS Creates an Azure Pipelines build definition. .DESCRIPTION Creates an Azure Pipelines build definition by a template. A template can be retrieved by Get-APBuildDefinition. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionToCloneId Undefinied, see link for documentation. .PARAMETER DefinitionToCloneRevision Undefinied, see link for documentation. .PARAMETER ValidateProcessOnly Undefinied, see link for documentation. .PARAMETER Template The template provided by Get-APBuildDefinition. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build. .EXAMPLE Creates AP build definition from the $template provided. $template is a JSON representation of the definition that can be found in the history of the release deinifiton during editing. Publish-APBuildDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionObject $template .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/definitions/create?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter()] [int] $DefinitionToCloneId, [Parameter()] [int] $DefinitionToCloneRevision, [Parameter()] [bool] $ValidateProcessOnly, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'build-definitions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Publish-APPipelineDefinition.ps1 function Publish-APPipelineDefinition { <# .SYNOPSIS Creates an Azure Pipelines release definition. .DESCRIPTION Creates an Azure Pipelines release definition by using a template. The template can be retrieved by using Get-APPipelineDefinition. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template The template provided by Get-APPipelineDefinition. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build. .EXAMPLE Creates AP release definition from the $template provided. $template is a JSON representation of the definition that can be found in the history of the release deinifiton during editing. Publish-APPipelineDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionObject $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'pipelines' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Publish-APReleaseDefinition.ps1 function Publish-APReleaseDefinition { <# .SYNOPSIS Creates an Azure Pipelines release definition. .DESCRIPTION Creates an Azure Pipelines release definition by using a template. The template can be retrieved by using Get-APReleaseDefinition. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template The template provided by Get-APReleaseDefinition. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build. .EXAMPLE Creates AP release definition from the $template provided. $template is a JSON representation of the definition that can be found in the history of the release deinifiton during editing. Publish-APReleaseDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionObject $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/definitions/create?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'release-definitions' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Register-APPSRepository.ps1 function Register-APPSRepository { <# .SYNOPSIS Registers a PSRepository to an Azure DevOps feed. .DESCRIPTION Registers a PSRepository to an Azure DevOps feed. A list of feeds can be retrieved with Get-APFeedList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedName The name of the feed to register. .PARAMETER RepositoryName The name of the PSRepository. .PARAMETER RepositoryCredential The credential used to register the PSRepository. .PARAMETER InstallationPolicy Specifies the installation policy. Valid values are: Trusted, UnTrusted. The default value is Trusted. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines feed. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/feed/feeds/queue?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedName, [Parameter(Mandatory)] [string] $RepositoryName, [Parameter()] [pscredential] $RepositoryCredential, [Parameter()] [ValidateSet('Trusted', 'UnTrusted')] [string] $InstallationPolicy = 'Trusted' ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $getAPFeedListSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion } If ($Credential) { $getAPFeedListSplat.Credential = $Credential } If ($PersonalAccessToken) { $getAPFeedListSplat.PersonalAccessToken = $PersonalAccessToken } If ($Proxy) { $getAPFeedListSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPFeedListSplat.ProxyCredential = $ProxyCredential } $feedListObject = Get-APFeedList @getAPFeedListSplat | Where-Object { $PSItem.Name -eq $FeedName } If ($feedListObject) { $apiEndpoint = (Get-APApiEndpoint -ApiType 'packaging-feedName') -f $FeedName $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'pkgs' } [uri] $uri = Set-APUri @setAPUriSplat } else { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate a feed with the name of [$FeedName]" } If ($uri) { $registerPSRepositorySplat = @{ Name = $RepositoryName PublishLocation = $uri SourceLocation = $uri InstallationPolicy = $InstallationPolicy } If ($RepositoryCredential) { $registerPSRepositorySplat.Credential = $RepositoryCredential } If ($Proxy) { $registerPSRepositorySplat.Proxy = $Proxy } If ($ProxyCredential) { $registerPSRepositorySplat.ProxyCredential = $ProxyCredential } Register-PSRepository @registerPSRepositorySplat } } end { } } # Remove-APAgent.ps1 function Remove-APAgent { <# .SYNOPSIS Deletes an Azure Pipeline agent. .DESCRIPTION Deletes an Azure Pipeline agent by agent id. The id can be retrieved by using Get-APAgentList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PoolId The id of the pool. .PARAMETER AgentId The id of the agent to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APAgent does not generate any output. .EXAMPLE Deletes AP agent with the id of '5'. Remove-APAgent -Instance 'https://dev.azure.com' -Collection 'myCollection' -AgentId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/agents/delete?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PoolId, [Parameter(Mandatory)] [int] $AgentId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'agent-agentId') -f $PoolId, $AgentId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APBuild.ps1 function Remove-APBuild { <# .SYNOPSIS Deletes an Azure Pipeline build. .DESCRIPTION Deletes an Azure Pipeline build by build id. The id can be retrieved by using Get-APBuildList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BuildId The id of the build to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APBuild does not generate any output. .EXAMPLE Deletes AP build with the id of '5'. Remove-APBuild -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/delete?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $BuildId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-buildId') -f $BuildId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APBuildDefinition.ps1 function Remove-APBuildDefinition { <# .SYNOPSIS Deletes an Azure Pipeline build definition. .DESCRIPTION Deletes an Azure Pipeline build definition by definition id. The id can be retrieved by using Get-APBuildDefinitionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionId The ID of the definition to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APBuildDefinition does not generate any output. .EXAMPLE Deletes AP build definition with the id of '5'. Remove-APBuildDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionId 5 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/definitions/delete?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DefinitionId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-definitionId') -f $DefinitionId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APBuildLease.ps1 function Remove-APBuildLease { <# .SYNOPSIS Deletes an Azure Pipeline build lease. .DESCRIPTION Deletes an Azure Pipeline build lease by lease id. The id can be retrieved by using Get-APBuildLeaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Ids The id of the build lease to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APBuildLease does not generate any output. .EXAMPLE Deletes AP build lease with the id of '5'. Remove-APBuildLease -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -LeaseId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/leases/delete?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [Alias('LeaseIds')] [int[]] $Ids ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'build-leases' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APDashboard.ps1 function Remove-APDashboard { <# .SYNOPSIS Deletes an Azure Pipeline dashboard. .DESCRIPTION Deletes an Azure Pipeline dashboard by dashboard id. The id can be retrieved by using Get-APDashboardList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DashboardId The ID of the dashboard to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APDashboard does not generate any output. .EXAMPLE Deletes AP dashboard with the id of '5'. Remove-APDashboard -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DashboardId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/dashboard/dashboards/delete?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $DashboardId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'dashboard-dashboardId') -f $DashboardId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APDeploymentGroup.ps1 function Remove-APDeploymentGroup { <# .SYNOPSIS Deletes an Azure Pipeline deployment group. .DESCRIPTION Deletes an Azure Pipeline deployment group by deployment group id. The id can be retrieved by using Get-APDeploymentGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment group to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APDeploymentGroup does not generate any output. .EXAMPLE Deletes AP deployment group with the deployment group id of '6'. Remove-APDeploymentGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/deploymentgroups/delete?view=vsts-rest-5.0# #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-deploymentGroupId') -f $DeploymentGroupID $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APEnvironment.ps1 function Remove-APEnvironment { <# .SYNOPSIS Deletes an Azure Pipeline environment. .DESCRIPTION Deletes an Azure Pipeline environment by environment name. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EnvironmentId The id or name of the environment. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines environment. .EXAMPLE Deletes an Azure DevOps environment named 'myEnvironment'. Remove-APEnvironment -Session 'mySession' -EnvironmentId 'myEnvironment' .LINK Undocumented at the time this was created. #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EnvironmentId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-environmentId') -f $EnvironmentId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # Remove-APFeed.ps1 function Remove-APFeed { <# .SYNOPSIS Deletes an Azure Pipeline feed. .DESCRIPTION Deletes an Azure Pipeline feed and all it's packages, by feed id. The id can be retrieved by using Get-APFeedList. .PARAMETER Instance The Team Services account or TFS server. For Azure DevOps the value should be https://dev.azure.com/. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId The id of the feed to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, does not support output. .EXAMPLE Deletes AP feed with the id of '5'. Remove-APFeed -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -FeedId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed%20%20management/delete%20feed?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-feedId') -f $FeedId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'feeds' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APGitFile.ps1 function Remove-APGitFile { <# .SYNOPSIS Removes an Azure Pipeline Git file. .DESCRIPTION Removes an Azure Pipeline Git file based on the repository id the branch name and the branch object id. The repository id can be retrieved by using Get-APRepositoryList. The branch name and object id can be retrieved by using Get-APGitRefList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The name or ID of the repository. .PARAMETER ObjectId The branch object id to remove the file from. Use Get-APGitRefList to identify the object id. .PARAMETER BranchName The name of the branch to remove the file from. .PARAMETER Path The path to the file relative to the root of the repository. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines Git ref. .EXAMPLE Removes a file at '/images/people/default.jpg' from the repository named 'myRepository'. Remove-APGitFile -Session 'mySession' -BranchName 'myBranchName' -ObjectId '50114dacf4ed256f37e397ded65188400d84b0831bd' -Path '/images/people/default.jpg' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-5.0#delete_a_file #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId, [Parameter(Mandatory)] [string] $ObjectId, [Parameter(Mandatory)] [string] $BranchName, [Parameter(Mandatory)] [string] $Path ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ refUpdates = @( @{ name = $BranchName oldObjectId = $ObjectId } ) commits = @( @{ comment = "Removed file from $Path" changes = @( @{ changeType = 'delete' item = @{ path = $Path } } ) } ) } $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-pushes') -f $RepositoryId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APGroupMembership.ps1 function Remove-APGroupMembership { <# .SYNOPSIS Deletes an Azure Pipeline release. .DESCRIPTION Deletes an Azure Pipeline release by release id. The id can be retrieved by using Get-APGroupMembershipList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubjectDescriptor A descriptor to the child subject in the relationship. .PARAMETER ContainerDescriptor A descriptor to the container in the relationship. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APGroupMembership does not generate any output. .EXAMPLE The example below provides a gridview of all groups. Then the members of the groups selected. Then removes the members selected from that group. $group = Get-APGroupList -Session $session | Out-GridView -PassThru Foreach ($g in $group) { $memberList = Get-APGroupMembershipList -Session $session -SubjectDescriptor $g.descriptor -Direction down $members = Foreach ($m in $memberList.memberDescriptor) { Get-APGroup -Session $session -GroupDescriptor $m } $membersToRemove = $members | Out-GridView -PassThru Foreach ($m in $membersToRemove) { Remove-APGroupMembership -Session $session -SubjectDescriptor $m.descriptor -ContainerDescriptor $g.descriptor -Verbose } } .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/memberships/remove%20membership?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubjectDescriptor, [Parameter(Mandatory)] [string] $ContainerDescriptor ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'graph-containerDescriptor') -f $SubjectDescriptor, $ContainerDescriptor $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vssps' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APInstalledExtensionDocument.ps1 function Remove-APInstalledExtensionDocument { <# .SYNOPSIS Removes an Azure Pipeline installed extension document by id. .DESCRIPTION Removes an Azure Pipeline installed extension document by id. The extension details can be retrieved by using Get-APInstalledExtensionList. The document id can be retrieced by using Get-APInstalledExtensionDocumentList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER ScopeType The scope of where the document is stored. Can be Default or User. .PARAMETER ScopeValue The value of the scope where the document is stored. Can be Current or Me. .PARAMETER DocumentCollection The name of the document collection. .PARAMETER DocumentId The id of the document. .INPUTS None, does not support pipeline. .OUTPUTS None, does not support output. .EXAMPLE Removes the WindowsServiceManager extension document. Remove-APInstalledExtensionDocument -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' -Published 'MDSolutions' -ScopeType 'Default' -ScopeValue 'Current' -DocumentId 'theDocumentGuid' .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter(Mandatory)] [ValidateSet('Default', 'User')] [string] $ScopeType, [Parameter(Mandatory)] [ValidateSet('Current', 'Me')] [string] $ScopeValue, [Parameter(Mandatory)] [string] $DocumentCollection, [Parameter(Mandatory)] [string] $DocumentId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-documentId') -f $PublisherName, $ExtensionName, $ScopeType, $ScopeValue, $DocumentCollection, $DocumentId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APNotificationSubscription.ps1 function Remove-APNotificationSubscription { <# .SYNOPSIS Deletes a notification subscription by its id. .DESCRIPTION Deletes a notification subscription by its id. The id can be retrieved with Get-APSubscriptionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SubscriptionId The id of the subscription. .PARAMETER QueryFlags Undocumented. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines subscription list. .EXAMPLE .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/notification/subscriptions/delete?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SubscriptionId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'notification-subscriptionId') -f $SubscriptionId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $null = Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APNugetPackageVersion.ps1 function Remove-APNugetPackageVersion { <# .SYNOPSIS Removes an Azure Pipeline nuget package version from the feed and places it in the recycle bin. .DESCRIPTION Removes an Azure Pipeline nuget package version from the feed and places it in the recycle bin by feed id, package name, and package version. The id can be retrieved by using Get-APFeedList. The package name and version can be retrieved by using Get-APPackageList. .PARAMETER Instance The Team Services account or TFS server. For Azure DevOps the value should be https://dev.azure.com/. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId The id of the feed to be deleted. .PARAMETER PackageName The name of the package to be deleted. .PARAMETER PackageVersion The version of the package to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS Azure Pipelines Package, the package object that was sent to the recyle bin. .EXAMPLE Deletes AP feed with the id of '5'. Remove-APNugetPackageVersion -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -FeedId 5 -PackageName 'myPackage' -PackageVersion 'myPackageVersion' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifactspackagetypes/nuget/delete%20package%20version?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId, [Parameter(Mandatory)] [string] $PackageName, [Parameter(Mandatory)] [string] $PackageVersion ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-packageVersion') -f $FeedId, $PackageName, $PackageVersion $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'pkgs' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APNugetPackageVersionFromRecycleBin.ps1 function Remove-APNugetPackageVersionFromRecycleBin { <# .SYNOPSIS Deletes an Azure Pipeline nuget package version from the recyle bin. .DESCRIPTION Deletes an Azure Pipeline nuget package version from the recycle bin by feed id, package name, and package version. The id can be retrieved by using Get-APFeedList. The package name and version can be retrieved by using Get-APPackageList. .PARAMETER Instance The Team Services account or TFS server. For Azure DevOps the value should be https://dev.azure.com/. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER FeedId The id of the feed to be deleted. .PARAMETER PackageName The name of the package to be deleted. .PARAMETER PackageVersion The version of the package to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APNugetPackageVersionFromRecycleBin does not support output. .EXAMPLE Deletes AP feed with the id of '5' from the recycle bin. Remove-APNugetPackageVersionFromRecycleBin -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -FeedId 5 -PackageName 'myPackage' -PackageVersion 'myPackageVersion' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/artifactspackagetypes/nuget/delete%20package%20version%20from%20recycle%20bin?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $FeedId, [Parameter(Mandatory)] [string] $PackageName, [Parameter(Mandatory)] [string] $PackageVersion ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'feed-RBpackageVersion') -f $FeedId, $PackageName, $PackageVersion $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'pkgs' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APPlan.ps1 function Remove-APPlan { <# .SYNOPSIS Deletes an Azure Pipeline plan. .DESCRIPTION Deletes an Azure Pipeline plan by plan id. The id can be retrieved by using Get-APPlanList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PlanId The id of the plan to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APPlan does not generate any output. .EXAMPLE Deletes AP plan with the id of '5'. Remove-APPlan -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PlanId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/plans/delete?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PlanId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-planId') -f $PlanId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APPolicyConfiguration.ps1 function Remove-APPolicyConfiguration { <# .SYNOPSIS Deletes an Azure Pipeline policy configuration. .DESCRIPTION Deletes an Azure Pipeline policy configuration by configuration id. The id can be retrieved by using Get-APPolicyConfigurationList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ConfigurationId The id of the policy configuration to remove. .INPUTS None, does not support pipeline. .OUTPUTS None, does not support output. .EXAMPLE Deletes AP policy configuration with the id of '5'. Remove-APPolicyConfiguration -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ConfigurationId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/delete?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ConfigurationId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'policy-configurationId') -f $ConfigurationId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $null = Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APPool.ps1 function Remove-APPool { <# .SYNOPSIS Deletes an Azure Pipeline pool. .DESCRIPTION Deletes an Azure Pipeline pool by pool id. The id can be retrieved by using Get-APPoolList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PoolId The id of the pool. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APPool does not generate any output. .EXAMPLE Deletes AP pool with the id of '5'. Remove-APPool -Instance 'https://dev.azure.com' -Collection 'myCollection' -PoolId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/pools/delete?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PoolId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'pool-poolId') -f $PoolId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APProject.ps1 function Remove-APProject { <# .SYNOPSIS Deletes an Azure Pipeline project. .DESCRIPTION Deletes an Azure Pipeline project by project id. The id can be retrieved with Get-APProjectList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProjectId The id of the project. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines project status. .EXAMPLE Returns the AP project named 'myFirstProject'. Get-APProject-Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/projects/get?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProjectId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'project-projectId') -f $ProjectId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APQuery.ps1 function Remove-APQuery { <# .SYNOPSIS Deletes an Azure Pipeline query. .DESCRIPTION Deletes an Azure Pipeline query by query id. The id can be retrieved by using Get-APQueryList. .PARAMETER Instance The Team Services account or TFS server. For Azure DevOps the value should be https://dev.azure.com/. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER QueryId The id of the query to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, does not support output. .EXAMPLE Deletes the query in the Shared Queries folder named My Feature Query Remove-APQuery -Session $session -QueryId 'Shared Queries/My Feature Query' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/queries/delete?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $QueryId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-queryId') -f $QueryId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APRelease.ps1 function Remove-APRelease { <# .SYNOPSIS Deletes an Azure Pipeline release. .DESCRIPTION Deletes an Azure Pipeline release by release id. The id can be retrieved by using Get-APReleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseId The id of the release to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APRelease does not generate any output. .EXAMPLE Deletes AP release with the id of '5'. Remove-APRelease -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 5 .LINK Undocumented #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ReleaseId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-releaseId') -f $ReleaseId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APReleaseDefinition.ps1 function Remove-APReleaseDefinition { <# .SYNOPSIS Deletes an Azure Pipeline release definition. .DESCRIPTION Deletes an Azure Pipeline release definition by definition id. The id can be retrieved by using Get-APReleaseDefinitionList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DefinitionId The ID of the definition to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APReleaseDefinition does not generate any output. .EXAMPLE Deletes AP release definition with the definition id of '5'. Remove-APReleaseDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DefinitionId 5 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/release/definitions/delete?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DefinitionId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-definitionId') -f $DefinitionId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APRepository.ps1 function Remove-APRepository { <# .SYNOPSIS Deletes an Azure Pipeline repository. .DESCRIPTION Deletes an Azure Pipeline repository and all it's content, by repository id. The id can be retrieved by using Get-APRepositoryList. .PARAMETER Instance The Team Services account or TFS server. For Azure DevOps the value should be https://dev.azure.com/. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER RepositoryId The id of the repository to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, does not support output. .EXAMPLE Deletes AP repository with the id of '5'. Remove-APRepository -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -RepositoryId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/git/repositories/delete?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $RepositoryId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'git-repositoryId') -f $RepositoryId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Remove-APSecureFile.ps1 function Remove-APSecureFile { <# .SYNOPSIS Deletes an Azure Pipeline secure file. .DESCRIPTION Deletes an Azure Pipeline secure file by secure file id. The id can be retrieved by using Get-APSecureFileList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SecureFileId The id of the secure file. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APSecureFile does not generate any output. .EXAMPLE Deletes AP secure file with the id of '5'. Remove-APSecureFile -Instance 'https://dev.azure.com' -Collection 'myCollection' -SecureFileId 5 .LINK Undocumented #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SecureFileId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'securefiles-secureFileId') -f $SecureFileId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APServiceEndpoint.ps1 function Remove-APServiceEndpoint { <# .SYNOPSIS Deletes an Azure Pipeline service endpoint. .DESCRIPTION Deletes an Azure Pipeline service endpoint by service endpoint id. The id can be retrieved by using Get-APServiceEndpointList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EndpointId The id of the service endpoint to be deleted. .PARAMETER Deep Specific to AzureRM endpoint created in Automatic flow. When set to true, this will also delete corresponding AAD application in Azure. Default value is true. .INPUTS None, does not support pipeline. .OUTPUTS None, does not generate any output. .EXAMPLE Deletes AP service endpoint with the id of '5'. Remove-APServiceEndpoint -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -EndpointId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/delete?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EndpointId, [Parameter()] [bool] $Deep ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'serviceendpoint-endpointId') -f $EndpointId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APSession.ps1 Function Remove-APSession { <# .SYNOPSIS Removes an Azure Pipelines PS session. .DESCRIPTION Removes an Azure Pipelines PS session. If the session is saved, it will be removed from the saved sessions as well. .PARAMETER Id Session id. .PARAMETER Path The path where session data will be stored, defaults to $Script:ModuleDataPath. .LINK Save-APSession Remove-APSession .INPUTS PSObject. Get-APSession .OUTPUTS None. Does not supply output. .EXAMPLE Deletes AP session with the id of '2'. Remove-APSession -Id 2 .EXAMPLE Deletes all AP sessions in memory and stored on disk. Remove-APSession #> [CmdletBinding()] Param ( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $Id, [Parameter()] [string] $Path = $Script:ModuleDataPath ) Process { $sessions = Get-APSession -Id $Id Foreach ($session in $sessions) { If ($session.Saved -eq $true) { $newData = @{SessionData = @() } $data = Get-Content -Path $Path -Raw | ConvertFrom-Json Foreach ($_data in $data.SessionData) { If ($_data.Id -eq $session.Id) { Continue } else { $newData.SessionData += $_data } } $newData | ConvertTo-Json -Depth 5 | Out-File -FilePath $Path } [array] $Global:_APSessions = $Global:_APSessions | Where-Object { $PSItem.Id -ne $session.Id } } } } # Remove-APTarget.ps1 function Remove-APTarget { <# .SYNOPSIS Deletes an Azure Pipeline deployment group target. .DESCRIPTION Deletes an Azure Pipeline deployment group target by the deployment group id and the target id. The deployment group id can be retrieved by using Get-APDeploymentGroupList. The target id can be retrieved by using Get-APTargetList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment group in which deployment target is deleted. .PARAMETER TargetId ID of the deployment target to delete. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APTarget does not generate any output. .EXAMPLE Deletes AP target with the deployment group id of '6' and the target id of '25'. Remove-APTarget -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 -TargetId 25 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/targets/delete?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupId, [Parameter(Mandatory)] [int] $TargetId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-targetId') -f $DeploymentGroupID, $TargetId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APTeam.ps1 function Remove-APTeam { <# .SYNOPSIS Deletes an Azure Pipeline team. .DESCRIPTION Deletes an Azure Pipeline team by team id. The id can be retrieved by using Get-APTeamList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The id of the team to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APTeam does not generate any output. .EXAMPLE Deletes AP team with the id of 'myTeam'. Remove-APTeam -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -TeamId 'myTeam' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/delete?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'team-teamId') -f $Project, $TeamId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APTestSuite.ps1 function Remove-APTestSuite { <# .SYNOPSIS Deletes an Azure Pipeline test suite. .DESCRIPTION Deletes an Azure Pipeline test suite by plan id and suite id. The suite id can be retrieved by using Get-APTestSuiteList. The plan id can be retrieved by using Get-APTestPlanList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PlanId The id of the plan. .PARAMETER SuiteId The id of the test suite to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APTestSuite does not generate any output. .EXAMPLE Deletes AP test suite with the id of '5'. Remove-APTestSuite -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -PlanId -SuiteId 5 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/testplan/test%20%20suites/delete?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PlanId, [Parameter(Mandatory)] [string] $SuiteId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'test-suiteId') -f $PlanId, $TestSuiteId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Remove-APVariableGroup.ps1 function Remove-APVariableGroup { <# .SYNOPSIS Deletes an Azure Pipeline variable group. .DESCRIPTION Deletes an Azure Pipeline variable group by group id. The id can be retrieved by using Get-APVariableGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER GroupId The ID of the Group to be deleted. .INPUTS None, does not support pipeline. .OUTPUTS None, Remove-APVariableGroup does not generate any output. .EXAMPLE Deletes AP variable group with the group id of '5'. Remove-APVariableGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -GroupId 5 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/Variable/Groups/delete?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $GroupId ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-variablegroupId') -f $GroupId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'DELETE' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Save-APPermissionReport.ps1 function Save-APPermissionReport { <# .SYNOPSIS Returns a an Azure Pipeline permission report. .DESCRIPTION Returns a an Azure Pipeline permission report based on report id. The report id can be returned by Get-APPermissionReportList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReportId Id (guid) of the report to save. .PARAMETER OutputPath The full name path to save the report to. .PARAMETER Passthru Reads the file and outputs the results to the console. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines permission report(s) .EXAMPLE Returns AP permission report for 'myCollection' with the id of '7' to a file located at 'C:\temp\myReport.json' Save-APPermissionReportList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ReportId '7' -OutputPath 'C:\temp\myReport.json' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/permissionsreport/permissions%20report%20download/download?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ReportId, [Parameter(Mandatory)] [string] $OutputPath, [Parameter()] [Switch] $PassThru ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'permissions-download') -f $ReportId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'GET' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential Path = $OutputPath } Invoke-APRestMethod @invokeAPRestMethodSplat If ($PassThru.IsPresent) { Get-Content -Path $OutputPath -Force | ConvertFrom-Json } } end { } } # Save-APSession.ps1 Function Save-APSession { <# .SYNOPSIS Saves an Azure Pipelines PS session to disk. .DESCRIPTION Saves an Azure Pipelines PS session to disk. The sensetive data is encrypted and stored in the users local application data. These saved sessions will be available next time the module is imported. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Path The path where session data will be stored, defaults to $Script:ModuleDataPath. .PARAMETER PassThru Returns the saved session object. .INPUTS PSbject. Get-APSession, New-APSession .OUTPUTS None. Save-APSession does not generate any output. .EXAMPLE Creates a session with the name of 'myFirstSession' and saves it to disk. $newAPSession = @{ Collection = 'myCollection' Project = 'myFirstProject' Instance = 'https://dev.azure.com/' PersonalAccessToken = 'myToken' Version = 'vNext' SessionName = 'myFirstSession' } New-APSession @newAPSession | Save-APSession #> [CmdletBinding()] Param ( [Parameter(Mandatory, ValueFromPipeline)] [object] $Session, [Parameter()] [string] $Path = $Script:ModuleDataPath ) Begin { If (-not(Test-Path $Path)) { $data = @{SessionData = @() } } else { $data = Get-Content -Path $Path -Raw | ConvertFrom-Json } } Process { If ($data.SessionData.Id -notcontains $session.Id) { $_object = @{ Version = $Session.Version ApiVersion = $Session.ApiVersion Instance = $Session.Instance Id = $Session.Id SessionName = $Session.SessionName Collection = $Session.Collection Project = $Session.Project Saved = $true } If ($Session.PersonalAccessToken) { $_object.PersonalAccessToken = ($Session.PersonalAccessToken | ConvertFrom-SecureString) } If ($Session.Credential) { $_credentialObject = @{ Username = $Session.Credential.UserName Password = ($Session.Credential.GetNetworkCredential().SecurePassword | ConvertFrom-SecureString) } $_object.Credential = $_credentialObject } If ($Session.Proxy) { $_object.Proxy = $Session.Proxy } If ($Session.ProxyCredential) { $_proxyCredentialObject = @{ Username = $Session.ProxyCredential.UserName Password = ($Session.ProxyCredential.GetNetworkCredential().SecurePassword | ConvertFrom-SecureString) } $_object.ProxyCredential = $_proxyCredentialObject } $data.SessionData += $_object $session | Remove-APSession -Path $Path } } End { $data | ConvertTo-Json -Depth 5 | Out-File -FilePath $Path Write-Verbose "[$($MyInvocation.MyCommand.Name)]: [$SessionName]: Session data has been stored at [$Path]" } } # Set-APAccessControlEntries.ps1 function Set-APAccessControlEntries { <# .SYNOPSIS Add or update ACEs in the ACL for the provided token. .DESCRIPTION Add or update ACEs in the ACL for the provided token. Target token contained in the passed ACEs. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER SecurityNamespaceId Security namespace identifier. .PARAMETER Token Security token. .PARAMETER Merge Whether to combine or to replace existing ACE. .PARAMETER AccessControlEntries An array of ACEs. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines security namespace ACE(s) .EXAMPLE Returns all access control lists Set-APAccessControlEntries -Session 'mySession' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20entries/set%20access%20control%20entries?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $SecurityNamespaceId, [Parameter()] [string] $Token, [Parameter()] [bool] $Merge, [Parameter(Mandatory)] [PSCustomObject[]] $AccessControlEntries ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ token = $Token; merge = $Merge; accessControlEntries = $AccessControlEntries } $apiEndpoint = (Get-APApiEndpoint -ApiType 'accesscontrolentries-securityNamespaceId') -f $SecurityNamespaceId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Set-APBuildNumber.ps1 function Set-APBuildNumber { <# .SYNOPSIS Pipeline invocation command used to update build number for current build. .DESCRIPTION Pipeline invocation command used to update build number for current build. Pipeline invocation commands make changes during pipeline execution. If the command is excuted in a console window the command will output logging messages. .PARAMETER BuildNumber The new build number. .INPUTS None, does not support the pipline. .OUTPUTS VSO build number. .EXAMPLE Set-APBuildNumber -BuildNumber '1.0.0' #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string] $BuildNumber ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { If ($pipelineInvocation) { Write-Host "##vso[build.updatebuildnumber]$BuildNumber" } else { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Updated build number to: [$BuildNumber]" } } end { } } # Set-APReleaseName.ps1 function Set-APReleaseName { <# .SYNOPSIS Pipeline invocation command used to update the release name for the current release. .DESCRIPTION Pipeline invocation command used to update the release name for the current release Pipeline invocation commands make changes during pipeline execution. If the command is excuted in a console window the command will output logging messages. .PARAMETER ReleaseName The new release name. .INPUTS None, does not support the pipline. .OUTPUTS VSO release name. .EXAMPLE Set-APReleaseName -ReleaseName 'My New Release Name' #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string] $ReleaseName ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { If ($pipelineInvocation) { Write-Host "##vso[release.updatereleasename]$ReleaseName" } else { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Updated release name to: [$ReleaseName]" } } end { } } # Set-APTaskResult.ps1 function Set-APTaskResult { <# .SYNOPSIS Pipeline invocation command used to set the finish timeline record for current task, set task result and current operation. .DESCRIPTION Pipeline invocation command used to set the finish timeline record for current task, set task result and current operation. Pipeline invocation commands make changes during pipeline execution. If the command is excuted in a console window the command will output logging messages. .PARAMETER Message The log message. .PARAMETER Result The result of the task, defaults to Succeeded. .INPUTS None, does not support the pipline. .OUTPUTS Task result. .EXAMPLE Set-TaskResult -Message 'Done' -Result 'Succeeded' #> [CmdletBinding()] param ( [Parameter()] [string] $Message, [Parameter()] [ValidateSet('Succeeded', 'SucceededWithIssues', 'Failed', 'Canceled', 'Skipped')] [string] $Result = 'Succeeded' ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { If ($pipelineInvocation) { Write-Host "##vso[task.complete result=$Result;]$Message" } else { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Result: [$Result], Message: [$Message]" } } end { } } # Set-APVariable.ps1 function Set-APVariable { <# .SYNOPSIS Pipeline invocation command used to set a variable in the variable service of taskcontext. .DESCRIPTION Pipeline invocation command used to set a variable in the variable service of taskcontext. The first task can set a variable, and following tasks in the same phase are able to use the variable. Pipeline invocation commands make changes during pipeline execution. If the command is excuted in a console window the command will output logging messages. .PARAMETER Name The name of the variable to set. .PARAMETER Value The value of the variable. .PARAMETER IsSecret Sets the variable to a secret. When issecret is set to true, the value of the variable will be saved as secret and masked out from log. Secret variables are not passed into tasks as environment variables and must be passed as inputs. .PARAMETER IsOutput Sets the variable to an output variable. .INPUTS None, does not support the pipline. .OUTPUTS VSO release name. .EXAMPLE Set-APReleaseName -ReleaseName 'My New Release Name' #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string] $Name, [Parameter(Mandatory)] [string] $Value, [Parameter()] [switch] $IsSecret, [Parameter()] [switch] $IsOutput ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { If ($pipelineInvocation) { Write-Host "##vso[task.setvariable variable=$Name;issecret=$($IsSecret.IsPresent);isOutput=$($IsOutput.IsPresent)]$Value" } else { If ($IsSecret.IsPresent) { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Updated the variable [$Name] to the value of [*****]. IsOutput set to [$($IsOutput.IsPresent)]" } else { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Updated the variable [$Name] to the value of [$Value]. IsOutput set to [$($IsOutput.IsPresent)]" } } } end { } } # Test-APPipelineYaml.ps1 function Test-APPipelineYaml { <# .SYNOPSIS Validates a local yaml pipeline file syntax. .DESCRIPTION Validates a local yaml pipeline file syntax. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PipelineId The id of an existing pipeline. .PARAMETER FullName Path to the yaml file to use as a yaml override. .PARAMETER YamlOverride If you use the preview run option, you may optionally supply different YAML. This allows you to preview the final YAML document without committing a changed file. .PARAMETER PipelineId The id of an existing pipeline. .PARAMETER PipelineVersion The version of the pipeline to queue. .PARAMETER PreviewRun If true, don't actually create a new run. Instead returen the final YAML document after parsing templates. .PARAMETER Resources The resources the run requires. .PARAMETER StagesToSkip The stages to skip. .PARAMETER TemplateParameters Runtime parameters to pass to the pipeline. .PARAMETER Variables Pipeline variables. .INPUTS None, does not support pipeline. .OUTPUTS None .EXAMPLE .LINK https://docs.microsoft.com/en-us/azure/devops/release-notes/2020/sprint-165-update#preview-fully-parsed-yaml-document-without-committing-or-running-the-pipeline #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $PipelineId, [Parameter()] [string] $FullName, [Parameter()] [string] $YamlOverride, [Parameter()] [string[]] $StagesToSkip, [Parameter()] [object] $Resources, [Parameter()] [hashtable] $TemplateParameters, [Parameter()] [hashtable] $Variables ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ PreviewRun = $true } If ($PipelineVersion) { $body.PipelineVersion = $PipelineVersion } If ($Resources) { $body.Resources = $Resources } If ($StagesToSkip) { $body.StagesToSkip = $StagesToSkip } If ($TemplateParameters) { $body.TemplateParameters = $TemplateParameters } If ($Variables) { $body.Variables = $Variables } If ($FullName) { $YamlOverride = Get-Content -Path $FullName -Raw } If ($YamlOverride) { $body.yamlOverride = $YamlOverride } $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-preview') -f $PipelineId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APApproval.ps1 function Update-ApApproval { <# .SYNOPSIS Modifies an Azure Pipeline approval. .DESCRIPTION Modifies an Azure Pipeline deployment approval by approval id. The approval id can be retrieved by using Get-APApprovalList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ApprovalId Id of the approval. .PARAMETER Status The status for the updated approval. .PARAMETER Comment The comment for the updated approval. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, An Azure Pipelines approval. .EXAMPLE Updates AP approval with the approval id of '6' to the status of 'appoved'. Update-APApproval -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApprovalId 6 -Status 'approved' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/approvals/update?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ApprovalId, [Parameter(Mandatory)] [ValidateSet('approved', 'canceled', 'pending', 'reassigned', 'rejected', 'skipped', 'undefined')] [string] $Status, [Parameter()] [string] $Comment ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ status = $Status } If ($Comment) { $body.comment = $Comment } $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-approvalId') -f $ApprovalId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APBuild.ps1 function Update-APBuild { <# .SYNOPSIS Modifies an Azure Pipeline build. .DESCRIPTION Modifies an Azure Pipeline build by a template. A template can retrived by using Get-APBuild. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template The template provided by Get-APBuild. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build. .EXAMPLE Updates AP build definition to the $template. $template is a JSON representation of the build. Update-APBuild -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/update%20build?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-buildId') -f $body.Id $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APBuildDefinition.ps1 function Update-APBuildDefinition { <# .SYNOPSIS Modifies an Azure Pipeline build definition. .DESCRIPTION Modifies an Azure Pipeline build definition by a template. A template can retrived by using Get-APBuildDefinition. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template The template provided by Get-APBuildDefinition. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build. .EXAMPLE Updates AP build definition to the $template. $template is a JSON representation of the definition that can be found in the history of the release deinifiton during editing. Update-APBuildDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/vsts/Build/definitions/update?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = (Get-APApiEndpoint -ApiType 'build-definitionId') -f $body.Id $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APDeploymentGroup.ps1 function Update-APDeploymentGroup { <# .SYNOPSIS Modifies an Azure Pipeline deployment group. .DESCRIPTION Modifies an Azure Pipeline deployment group by deployment group id. The id can be retrieved by using Get-APDeploymentGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment. .PARAMETER Description Description of the deployment group. .PARAMETER Name Name of the deployment group. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, An Azure Pipelines deployment group. .EXAMPLE Updates AP deployment group's name with the deployment group id of '6' to 'myGroupsNewName'. Update-APDeploymentGroup -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 -Name 'myGroupsNewName' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/deploymentgroups/update?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupId, [Parameter()] [string] $Name, [Parameter()] [string] $Description ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ Name = $Name Description = $Description } $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-deploymentGroupId') -f $DeploymentGroupID $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APField.ps1 function Update-APField { <# .SYNOPSIS Updates an Azure Pipeline field in a work item type and process by field ref name. .DESCRIPTION Updates an Azure Pipeline field in a work item type and process by field ref name. The field ref name can be retrieved by using Get-APFieldList. The process id can be retrieved by using Get-APProcessList. Work item type reference name can be retrieved by using Get-APWorkItemTypeList .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ProcessId The id of the process .PARAMETER WitRefName The reference name of the work item type. .PARAMETER FieldRefName The name of the field to update. .PARAMETER AllowGroups Allow setting field value to a group identity. Only applies to identity fields. .PARAMETER AllowedValues The list of field allowed values. .PARAMETER DefaultValue The default value of the field. .PARAMETER ReadOnly If true the field cannot be edited. .PARAMETER Required If true the field is required. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Updates an Azure Pipelines field to read only. Update-APField -Instance 'https://dev.azure.com' -Collection 'myCollection' -ProcessId $process.TypeId -WitRefName $witType.referencename -FieldRefName $field.referencename -Required $false -ReadOnly $true .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/fields/update?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ProcessId, [Parameter(Mandatory)] [string] $WitRefName, [Parameter(Mandatory)] [string] $FieldRefName, [Parameter()] [bool] $AllowGroups, [Parameter()] [string[]] $AllowedValues, [Parameter()] [object] $DefaultValue, [Parameter()] [bool] $ReadOnly, [Parameter()] [bool] $Required ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ } If ($PSBoundParameters.ContainsKey('AllowGroups')) { $body.allowGroups = $AllowGroups } If ($PSBoundParameters.ContainsKey('AllowedValues')) { $body.allowedvalues = $AllowedValues } If ($PSBoundParameters.ContainsKey('DefaultValue')) { $body.defaultValue = $DefaultValue } If ($PSBoundParameters.ContainsKey('ReadOnly')) { $body.readOnly = $ReadOnly } If ($PSBoundParameters.ContainsKey('Required')) { $body.required = $Required } $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-fieldname') -f $ProcessId, $WitRefName, $FieldRefName $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APInstalledExtension.ps1 function Update-APInstalledExtension { <# .SYNOPSIS Updates an installed extension. .DESCRIPTION Updates an installed extension. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ExtensionObject Azure Devops installed extension object, provided by Get-APInstalledExtensionList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension. .EXAMPLE Updates the installed extension for 'WindowsServiceManagerWindowsServiceManager'. $myExtensionObject = Get-APInstalledExtension -Session 'mySession' -PublisherName 'MDSolutions' -ExtensionName 'WindowsServiceManagerWindowsServiceManager' Update-APInstalledExtension -Session 'mySession' -ExtensionObject $myExtensionObject .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions/update?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [object] $ExtensionObject ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = Get-APApiEndpoint -ApiType 'extensionmanagement-installedextensions' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Method = 'PATCH' Body = $ExtensionObject Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APInstalledExtensionDocument.ps1 function Update-APInstalledExtensionDocument { <# .SYNOPSIS Updates an Azure Pipeline installed extension document. .DESCRIPTION Updates an Azure Pipeline installed extension document, that is stored as json. The extension details can be retrieved by using Get-APInstalledExtensionList. The document id can be retrieced by using Get-APInstalledExtensionDocumentList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER PublisherName Name of the publisher. Example: "MDSolutions". .PARAMETER ExtensionName Name of the extension. Example: "WindowsServiceManager". .PARAMETER ScopeType The scope of where the document is stored. Can be Default or User. .PARAMETER ScopeValue The value of the scope where the document is stored. Can be Current or Me. .PARAMETER DocumentCollection The name of the document collection. .PARAMETER InputObject The document object to be added. Converted and stored as json. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines extension document(s). .EXAMPLE Updates the WindowsServiceManager extension document with a new name. $document = Get-APInstalledExtensionDocument -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' -Published 'MDSolutions' -ScopeType 'Default' -ScopeValue 'Current' -DocumentId 'theDocumentGuid' $document.Name = 'newName' Update-APInstalledExtensionDocument -Instance 'https://dev.azure.com' -Collection 'myCollection' -ExtensionName 'WindowsServiceManager' -Published 'MDSolutions' -ScopeType 'Default' -ScopeValue 'Current' -InputObject $document .LINK Windows Service Manager extension: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager https://docs.microsoft.com/en-us/rest/api/azure/devops/extensionmanagement/installed%20extensions?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $PublisherName, [Parameter(Mandatory)] [string] $ExtensionName, [Parameter(Mandatory)] [ValidateSet('Default', 'User')] [string] $ScopeType, [Parameter(Mandatory)] [ValidateSet('Current', 'Me')] [string] $ScopeValue, [Parameter(Mandatory)] [string] $DocumentCollection, [Parameter(Mandatory)] [object] $InputObject ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $InputObject $apiEndpoint = (Get-APApiEndpoint -ApiType 'extensionmanagement-collection') -f $PublisherName, $ExtensionName, $ScopeType, $ScopeValue, $DocumentCollection $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters ApiSubDomainSwitch = 'extmgmt' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential Body = $body ContentType = 'application/json' } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APList.ps1 function Update-APList { <# .SYNOPSIS Updates an Azure Pipeline list by list id. .DESCRIPTION Updates an Azure Pipeline list by list id. The list id can be retrieved by using Get-APListList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ListId The id of the process .PARAMETER IsSuggested Indicates whether items outside of suggested list are allowed .PARAMETER Items A list of PickListItemModel .PARAMETER Name Name of the picklist .PARAMETER Type DataType of picklist .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Updates the list name to 'new_list_name'. Update-APList -Instance 'https://dev.azure.com' -Collection 'myCollection' -ListId 000000-0000-0000-0000000000 -Name 'new_list_name' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/processes/lists/update?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ListId, [Parameter()] [bool] $IsSuggested, [Parameter()] [string[]] $Items, [Parameter()] [string] $Name, [Parameter()] [string] $Type ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ } If ($PSBoundParameters.ContainsKey('IsSuggested')) { $body.isSuggested = $IsSuggested } If ($PSBoundParameters.ContainsKey('Items')) { $body.items = $Items } If ($PSBoundParameters.ContainsKey('Name')) { $body.name = $Name } If ($PSBoundParameters.ContainsKey('Type')) { $body.Type = $Type } $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-listId') -f $ListId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APNode.ps1 function Update-APNode { <# .SYNOPSIS Updates an Azure Pipeline node by node id. .DESCRIPTION Updates an Azure Pipeline node by node id. Return node ids with Get-APNodeList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER StructureGroup Structure group of the classification node. Options are areas or iterations. .PARAMETER Path Path of the classification node. .PARAMETER Name The new node's name. .PARAMETER Attributes Dictionary that has node attributes like start/finish date for iteration nodes. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines node. .EXAMPLE Updates the node at the path 'Iteration 1' for a project named 'myProject'. New-APNode -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -StructureGroup 'iterations' -Path 'Iteration 1' -Name 'Iteration 1 - New Name' -ApiVersion 6.0 .EXAMPLE Updates the start and finish date for the node at the path 'Iteration 1' for a project named 'myProject'. $attributes = @{ startDate = "2020-01-01T00:00:00Z" finishDate = "2020-01-02T00:00:00Z" } New-APNode -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -StructureGroup 'iterations' -Path 'Iteration 1' -Attributes $attributes -ApiVersion 6.0 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/classification%20nodes/update?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [ValidateSet('areas', 'iterations')] [string] $StructureGroup, [Parameter(Mandatory)] [string] $Path, [Parameter()] [string] $Name, [Parameter()] [object] $Attributes ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{} If ($Name) { $body.name = $Name } If ($Attributes) { $body.attributes = $Attributes } $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-path') -f $StructureGroup, $Path $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { $results.value } else { $results } } end { } } # Update-APPipelineApproval.ps1 function Update-APPipelineApproval { <# .SYNOPSIS Updates an Azure Pipeline approval status. .DESCRIPTION Updates an Azure Pipeline approval status. Return a list of pending approvals with Get-APPipelinePendingApprovalList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ApprovalId The id of the approval. .PARAMETER Comment The approval comment. .PARAMETER Status The updated status of the approval. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines approval(s) .EXAMPLE Returns an AP approval list for the current user in the 'myFirstProject'. Update-APPipelineApproval -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ApiVersion 6.1-preview -ApprovalId 4eg5aavx-1000-4333-ba70-67d5b15f0e -Status approved .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/approvals/update?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string[]] $ApprovalId, [Parameter()] [string] $Comment, [Parameter(Mandatory)] [ValidateSet('approved', 'rejected')] [string] $Status ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { [array] $body = Foreach ($id in $ApprovalId) { @{ approvalId = $id status = $Status comment = $Comment } } $apiEndpoint = Get-APApiEndpoint -ApiType 'pipelines-approvals' $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPWebRequestSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APWebRequest @invokeAPWebRequestSplat If ($results.value.count -eq 0) { return } elseIf ($results.value) { return $results.value } else { return $results } } end { } } # Update-APPolicyConfiguration.ps1 function Update-APPolicyConfiguration { <# .SYNOPSIS Updates a Azure Pipeline policy configuration. .DESCRIPTION Updates a Azure Pipeline policy configuration by configuration id. The id can be retrieved by using Get-APPolicyConfigurationList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template A policy template. A modified configuration policy object. The policy object can be retrived with Get-APPolicyConfigurationList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines policy configuration(s) .EXAMPLE Updates a policy configuration's 'isDeleted' value to false Update-APPolicyConfiguration -Session $Session -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/update?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [object] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = Get-APApiEndpoint -ApiType 'policy-configurations' $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'POST' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APRelease.ps1 function Update-APRelease { <# .SYNOPSIS Modifies an Azure Pipeline release. .DESCRIPTION Modifies an Azure Pipeline release by release id. The id can be retrieved by using Get-APreleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template The template provided by Get-APRelease. .INPUTS None, does not support pipeline. .OUTPUTS None, Update-APRelease returns Azure Pipelines release definition. .EXAMPLE Updates AP release with the release id of '5' with the $template. Update-APRelease -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 5 -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/update%20release?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-releaseId') -f $body.Id $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APReleaseDefinition.ps1 function Update-APReleaseDefinition { <# .SYNOPSIS Modifies an Azure Pipeline release definition. .DESCRIPTION Modifies an Azure Pipeline release definition by a template. A template can retrived by using Get-APReleaseDefinition. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template The template provided by Get-APReleaseDefinition. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, Azure Pipelines build. .EXAMPLE Updates AP release definition with the $template. $template is a JSON representation of the definition that can be found in the history of the release deinifiton during editing. Update-APReleaseDefinition -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -Template $template .LINK https://docs.microsoft.com/en-us/rest/api/vsts/release/definitions/update?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [PSobject] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-definitionId') -f $body.Id $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APReleaseEnvironment.ps1 function Update-APReleaseEnvironment { <# .SYNOPSIS Update the status of a release environment. .DESCRIPTION Update the status of a release environment by release id and environment id The release id can be retrieved by using Get-APReleaseList. The environment id can be retrieved by using Get-APRelease and providing the release id. The environment id is nested in the release object that is returned. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseID Id of the release. .PARAMETER EnvironmentID Id of the release environment. .PARAMETER Comment Comment used for the release status change. .PARAMETER ScheduledDeploymentTime Scheduled deployment time. .PARAMETER Status Environment status. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Release Environment .EXAMPLE Updates AP release environment with the release id of '3' and the environment id of '8099' to the status of 'inProgress'. Update-APReleaseEnvironment -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 3 -EnvironmentId 8099 -Status 'inProgress' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/release/releases/update%20release%20environment?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ReleaseId, [Parameter(Mandatory)] [int] $EnvironmentId, [Parameter()] [string] $Comment, [Parameter()] [string] $ScheduledDeploymentTime, [Parameter(Mandatory)] [string] [ValidateSet('canceled', 'inProgress', 'notStarted', 'partiallySucceeded', 'queued', 'rejected', 'scheduled', 'succeeded', 'undefined')] $Status ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ status = $Status } if ($Comment) { $body.comment = $Comment } If ($ScheduledDeploymentTime) { $body.scheduledDeploymentTime = $ScheduledDeploymentTime } $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-environmentId') -f $ReleaseId, $EnvironmentId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Method = 'PATCH' Body = $body Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } Invoke-APRestMethod @invokeAPRestMethodSplat } end { } } # Update-APReleaseResource.ps1 function Update-APReleaseResource { <# .SYNOPSIS Modifies an Azure Pipeline release resources. .DESCRIPTION Modifies an Azure Pipeline release resources by release id. The id can be retrieved by using Get-APreleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseId The id of the release to ne modified. .PARAMETER Comment Sets comment for release. .PARAMETER KeepForever Set 'true' to exclude the release from retention policies. .PARAMETER ManualEnvironments Sets list of manual environments. .PARAMETER Status Sets status of the release. .INPUTS None, does not support pipeline. .OUTPUTS None, Update-APReleaseResource returns Azure Pipelines release definition. .EXAMPLE Updates AP release resource with the release id of '5' with the comment of 'This is completed'. Update-APReleaseResource -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 5 -Comment 'This is completed' .EXAMPLE Updates AP release resource with the release id of '5' with the stauts of 'abandoned'. Update-APReleaseResource -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 5 -Status 'abandoned' .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/update%20release%20resource?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $ReleaseId, [Parameter()] [string] $Comment, [Parameter()] [bool] $KeepForever, [Parameter()] [string[]] $ManualEnvironments, [Parameter()] [ValidateSet('abandoned', 'active', 'draft', 'undefined')] [string] $Status ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ } If ($PSBoundParameters.Keys -contains 'Comment') { $body.comment = $Comment } If ($PSBoundParameters.Keys -contains 'KeepForever') { $body.KeepForever = $KeepForever } If ($PSBoundParameters.Keys -contains 'ManualEnvironments') { $body.ManualEnvironments = $ManualEnvironments } If ($PSBoundParameters.Keys -contains 'Status') { $body.Status = $Status } $apiEndpoint = (Get-APApiEndpoint -ApiType 'release-releaseId') -f $ReleaseId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint ApiSubDomainSwitch = 'vsrm' } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ ContentType = 'application/json' Body = $body Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APReleaseSummary.ps1 function Update-APReleaseSummary { <# .SYNOPSIS Pipeline invocation command used to upload and attach summary markdown to current timeline record. .DESCRIPTION Pipeline invocation command used to upload and attach summary markdown to current timeline record. This summary shall be added to the build/release summary and not available for download with logs. .PARAMETER Path The path to the markdown file to upload to the release summary. .PARAMETER Name The name of the expandable section in the release summary. .INPUTS None, does not support the pipline. .OUTPUTS None, does not support output. .EXAMPLE Update-APReleaseSummary -Path '.\mySummary.md' #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string] $Path, [Parameter()] [string] $Name ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { If (Test-Path $Path) { Write-Verbose -Message "[$($MyInvocation.MyCommand.Name)]: Uploading the file from [$Path] to the release summary." If ($pipelineInvocation) { If ($Name) { Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=$Name;]$Path" } else { Write-Host "##vso[task.uploadsummary]$Path" } } } else { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate file at [$Path]" } } end { } } # Update-APServiceEndpoint.ps1 function Update-APServiceEndpoint { <# .SYNOPSIS Updates an Azure Pipeline service endpoint. .DESCRIPTION Updates an Azure Pipeline service endpoint by endpoint id. The id can be retrieved by using Get-APServiceEndpointList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Template A service endpoint template. A modified service endpoint type object. The service endpoint type can be retrived with Get-APServiceEndpointTypeList. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint(s) .EXAMPLE Updates the description for the endpoint named 'myNewJenkinsEndpoint'. The password is required in order to update this service type because it does not get returned with Get-APServiceEndpointName. $session = 'mySession' $endpoint = Get-APServiceEndpointName -Session $session -EndpointNames 'myNewJenkinsEndpoint' $endpoint.Description = 'Updated description' $endpoint.authorization.parameters | Add-Member -NotePropertyName 'password' -NotePropertyValue 'mypassword' Update-APServiceEndpoint -Session $session -Template $endpoint .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/update%20service%20endpoint?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [object] $Template ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = $Template $endpointId = $Template.Id $apiEndpoint = (Get-APApiEndpoint -ApiType 'serviceendpoint-endpointId') -f $endpointId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APServiceEndpointPipelinePermission.ps1 function Update-APServiceEndpointPipelinePermission { <# .SYNOPSIS Updates an Azure Pipeline service endpoint pipeline permission. .DESCRIPTION Updates an Azure Pipeline service endpoint pipeline permission by endpoint id. The id can be retrieved by using Get-APServiceEndpointList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER EndpointId The service endpoint id. .PARAMETER GrantAccessPermissionToAllPipelines Will set the permission to true or false. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines service endpoint(s) .EXAMPLE Disables 'All Access Permission to All Pipelines' for the endpoint named 'myEndpointName'. $session = 'mySession' $endpoint = Get-APServiceEndpointName -Session $session -EndpointNames 'myEndpointName' Update-APServiceEndpointPipelinePermission -Session $session -EndpointId $endpoint.Id -GrantAccessPermissionToAllPipelines $false -Verbose .LINK Undocumented. https://docs.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/update%20service%20endpoint?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $EndpointId, [Parameter(Mandatory)] [bool] $GrantAccessPermissionToAllPipelines ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ allPipelines = @{ authorized = $GrantAccessPermissionToAllPipelines authorizedBy = $null authorizedOn = $null } pipelines = $null resource = @{ id = $EndpointId type = "endpoint" } } $apiEndpoint = (Get-APApiEndpoint -ApiType 'pipelines-endpointId') -f $endpointId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APSession.ps1 Function Update-APSession { <# .SYNOPSIS Updates an Azure Pipelines PS session. .DESCRIPTION Updates an Azure Pipelines PS session. The sensetive data is encrypted and stored in the users local application data. These updated sessions are available immediately. If the session was previously saved is will remain saved. .PARAMETER SessionName The friendly name of the session. .PARAMETER Id The id of the session. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. See example 1. .PARAMETER Project Project ID or project name. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to the project. .PARAMETER Version TFS version, this will provide the module with the api version mappings. .PARAMETER ApiVersion Version of the api to use. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Path The path where module data will be stored, defaults to $Script:ModuleDataPath. .INPUTS PSbject. Get-APSession, New-APSession .OUTPUTS None. Update-APSession does not generate any output. .EXAMPLE Updates the AP session named 'myFirstSession' with the api version of '6.0-preview.1' Update-APSession -SessionName 'myFirstSession' -ApiVersion '6.0-preview.1' #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory)] [string] $SessionName, [Parameter()] [string] $Id, [Parameter()] [uri] $Instance, [Parameter()] [string] $Collection, [Parameter()] [string] $Project, [Parameter()] [ValidateSet('vNext', '2018 Update 2', '2018 RTW', '2017 Update 2', '2017 Update 1', '2017 RTW', '2015 Update 4', '2015 Update 3', '2015 Update 2', '2015 Update 1', '2015 RTW')] [Obsolete("[New-APSession]: Version has been deprecated and replaced with ApiVersion.")] [string] $Version, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [string] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter()] [string] $ApiVersion, [Parameter()] [string] $Proxy, [Parameter()] [pscredential] $ProxyCredential, [Parameter()] [string] $Path = $Script:ModuleDataPath ) Begin { } Process { $getAPSessionSplat = @{ SessionName = $SessionName } If ($Id) { $getAPSessionSplat.Id = $Id } $existingSessions = Get-APSession @getAPSessionSplat If ($existingSessions) { Foreach ($existingSession in $existingSessions) { $newAPSessionSplat = @{ SessionName = $SessionName } If ($Version) { $newAPSessionSplat.Version = $Version } else { If ($existingSession.Version) { $newAPSessionSplat.Version = $existingSession.Version } } If ($ApiVersion) { $newAPSessionSplat.ApiVersion = $ApiVersion } else { If ($existingSession.ApiVersion) { $newAPSessionSplat.ApiVersion = $existingSession.ApiVersion } } If ($Instance) { $newAPSessionSplat.Instance = $Instance } else { If ($existingSession.Instance) { $newAPSessionSplat.Instance = $existingSession.Instance } } If ($Project) { $newAPSessionSplat.Project = $Project } else { If ($existingSession.Project) { $newAPSessionSplat.Project = $existingSession.Project } } If ($Collection) { $newAPSessionSplat.Collection = $Collection } else { If ($existingSession.Collection) { $newAPSessionSplat.Collection = $existingSession.Collection } } If ($PersonalAccessToken) { $newAPSessionSplat.PersonalAccessToken = $PersonalAccessToken } else { If ($existingSession.PersonalAccessToken) { $newAPSessionSplat.PersonalAccessToken = (Unprotect-APSecurePersonalAccessToken -PersonalAccessToken $existingSession.PersonalAccessToken) } } If ($Credential) { $_credentialObject = @{ Username = $Session.Credential.UserName Password = ($Session.Credential.GetNetworkCredential().SecurePassword | ConvertFrom-SecureString) } $newAPSessionSplat.Credential = $_credentialObject } else { If ($existingSession.Credential) { $newAPSessionSplat.Credential = $existingSession.Credential } } If ($Proxy) { $newAPSessionSplat.Proxy = $Session.Proxy } else { If ($existingSession.Proxy) { $newAPSessionSplat.Proxy = $existingSession.Proxy } } If ($ProxyCredential) { $_proxyCredentialObject = @{ Username = $Session.ProxyCredential.UserName Password = ($Session.ProxyCredential.GetNetworkCredential().SecurePassword | ConvertFrom-SecureString) } $newAPSessionSplat.ProxyCredential = $_proxyCredentialObject } else { If ($existingSession.ProxyCredential) { $newAPSessionSplat.ProxyCredential = $existingSession.ProxyCredential } } If ($existingSession.Saved) { $existingSession | Remove-APSession -Path $Path $session = New-APSession @newAPSessionSplat | Save-APSession } else { $existingSession | Remove-APSession -Path $Path $session = New-APSession @newAPSessionSplat } } } else { Write-Error "[$($MyInvocation.MyCommand.Name)]: Unable to locate an AP session with the name [$SessionName]." -ErrorAction Stop } } End { } } # Update-APTarget.ps1 function Update-APTarget { <# .SYNOPSIS Modifies an Azure Pipeline deployment group target. .DESCRIPTION Modifies an Azure Pipeline deployment group target. The deployment group id can be retrieved by using Get-APDeploymentGroupList. The target id can be retrieved by using Get-APTargetList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER DeploymentGroupId ID of the deployment. .PARAMETER Id Identifier of the deployment target. .PARAMETER Tags Tags for the deployment target. .INPUTS None, does not support pipeline. .OUTPUTS PSobject, An Azure Pipelines deployment group target. .EXAMPLE Updates AP deployment group target with the deployment group id of '6' and id of '30' with the tags of 'myFirstTag', 'mySecondTag'. Update-APTarget -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -DeploymentGroupID 6 -Id 30 -Tags 'myFirstTag', 'mySecondTag' .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/targets/update?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $DeploymentGroupId, [Parameter(Mandatory)] [int] $Id, [Parameter(Mandatory)] [string[]] $Tags ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{ Tags = ($Tags -join ',') Id = $Id } $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-targets') -f $DeploymentGroupID $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APTeam.ps1 function Update-APTeam { <# .SYNOPSIS Updates an Azure Pipeline team. .DESCRIPTION Updates an Azure Pipeline team based on a input parameters. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .PARAMETER Name The new name of the team. .PARAMETER Description The description of the team. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Updates the description for the AP team named 'myTeam' for a project named 'myProject'. Update-APTeam -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -TeamId 'myTeam' -Description 'New description' -ApiVersion 5.0-preview .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/core/teams/update?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId, [Parameter()] [string] $Name, [Parameter()] [string] $Description ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{} If ($Name) { $body.name = $Name } If ($Description) { $body.description = $Description } $apiEndpoint = (Get-APApiEndpoint -ApiType 'team-teamId') -f $Project, $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APTeamFieldValues.ps1 function Update-APTeamFieldValues { <# .SYNOPSIS Updates an Azure Pipeline team field values based on the team id. .DESCRIPTION Updates an Azure Pipeline team field values based on the team id. The id can be returned using Get-APTeamList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .PARAMETER DefaultValue The default area path. .PARAMETER Values Represents a single TeamFieldValue. https://docs.microsoft.com/en-us/rest/api/azure/devops/work/teamfieldvalues/update?view=azure-devops-rest-6.0#teamfieldvalue .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Updates the team field values for 'myTeam'. $vaules = @{ value = 'myProject\Area 1' includeChildren = $true } Update-APTeamFieldValues -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myProject' -TeamId 'myTeam' -ApiVersion 6.0 -DefaultValue 'myProject\Area 1' -Values $values .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/teamfieldvalues/update?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId, [Parameter()] [string] $DefaultValue, [Parameter()] [object[]] $Values ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{} If ($DefaultValue) { $body.defaultValue = $DefaultValue } If ($Values) { $body.Values = $Values } $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-teamfieldvalues') -f $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APTeamSettings.ps1 function Update-APTeamSettings { <# .SYNOPSIS Updates an Azure Pipeline team settings based on the team id. .DESCRIPTION Updates an Azure Pipeline team settings based on the team id. The id can be returned using Get-APTeamList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER TeamId The name or guid id of a team. .PARAMETER BacklogIteration The id of the iteration. .PARAMETER BacklogVisibilities The id of the iteration. .PARAMETER BugsBehavior The team's bug behavior. .PARAMETER DefaultIteration The team's default iteration. .PARAMETER DefaultIterationMacro The team's default iteration macro. .PARAMETER WorkingDays The team's working days. .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Updates the working days for the team named 'myTeam'. $workingDays = 'monday', 'tuesday' Update-APTeamSettings -Session $session -TeamId 'myTeam' -WorkingDays $workingDays .EXAMPLE Updates the backlog iteration for 'team1'. Update-APTeamSettings -Session $session -TeamId 'Team1' -BacklogIteration '000000-0000-0000-0000-0000000000' .EXAMPLE Update the team's backlog visibilities. $visibilities = @{ 'Microsoft.EpicCategory' = $false 'Microsoft.RequirementCategory' = $true 'Microsoft.FeatureCategory' = $true } Update-APTeamSettings -Session $session -TeamId 'Team1' -BacklogVisibilities $visibilities .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/work/teamsettings/update?view=azure-devops-rest-6.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $TeamId, [Parameter()] [string] $BacklogIteration, [Parameter()] [object] $BacklogVisibilities, [Parameter()] [ValidateSet('asRequirements', 'asTasks', 'off')] [string] $BugsBehavior, [Parameter()] [string] $DefaultIteration, [Parameter()] [string] $DefaultIterationMacro, [Parameter()] [ValidateSet('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday')] [string[]] $WorkingDays ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $body = @{} If ($BacklogIteration) { $body.backlogIteration = $BacklogIteration } If ($BacklogVisibilities) { $body.backlogVisibilities = $BacklogVisibilities } If ($BugsBehavior) { $body.bugsBehavior = $BugsBehavior } If ($DefaultIteration) { $body.defaultIteration = $DefaultIteration } If ($DefaultIterationMacro) { $body.defaultIterationMacro = $DefaultIterationMacro } If ($WorkingDays) { $body.workingDays = $WorkingDays } $apiEndpoint = (Get-APApiEndpoint -ApiType 'work-teamsettings') -f $TeamId $queryParameters = Set-APQueryParameters -InputObject $PSBoundParameters $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint Query = $queryParameters } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APVariableGroup.ps1 function Update-APVariableGroup { <# .SYNOPSIS Modifies an Azure Pipeline variable group. .DESCRIPTION Modifies an Azure Pipeline variable group by group id. The id can be retrieved by using Get-APVariableGroupList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER GroupId Id of the variable group. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER Description Sets description of the variable group. .PARAMETER Name Sets name of the variable group. .PARAMETER Variables Sets variables contained in the variable group. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines variable group. .EXAMPLE $varibales = @{ Var1 = 'updated val1' Var2 = 'updated val2' Var3 = 'updated val3' } $updateAPVariableGroupSplat = @{ Description = 'my updated variable group' Name = 'myUpdatedVariableGroup' Variables = $varibales Instance = 'https://dev.azure.com' Collection = 'myCollection' Project = 'myFirstProject' GroupId = 2 } Update-APVariableGroup @updateAPVariableGroupSplat .LINK https://docs.microsoft.com/en-us/rest/api/vsts/distributedtask/variablegroups/update?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $GroupId, [Parameter()] [string] $Name, [Parameter()] [string] $Description, [Parameter()] [object] $Variables ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $getAPVariableGroupSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion GroupId = $GroupId } If ($PersonalAccessToken) { $getAPVariableGroupSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPVariableGroupSplat.Credential = $Credential } If ($Proxy) { $getAPVariableGroupSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPVariableGroupSplat.ProxyCredential = $ProxyCredential } $_groupData = Get-APVariableGroup @getAPVariableGroupSplat If ($PSBoundParameters.Keys -contains 'Variables') { If ($Variables.GetType().Name -eq 'hashtable') { $_variables = @{ } Foreach ($token in $Variables.Keys) { $_variables.$token = @{ Value = $Variables.$token } } } else { $_variables = $Variables } } else { $_variables = $_groupData.Variables } If ($PSBoundParameters.Keys -contains 'Name') { $_name = $Name } else { $_name = $_groupData.Name } If ($PSBoundParameters.Keys -contains 'Description') { $_description = $Description } else { $_description = $_groupData.Description } $body = @{ Name = $_name Type = $_groupData.Type Description = $_description Variables = $_variables } $apiEndpoint = (Get-APApiEndpoint -ApiType 'distributedtask-VariableGroupId') -f $GroupId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance Project = $Project ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PUT' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = $body ContentType = 'application/json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Update-APWorkItem.ps1 function Update-APWorkItem { <# .SYNOPSIS Updates an Azure Pipeline workitem by workitem id. .DESCRIPTION Updates an Azure Pipeline workitem by workitem id. The workitem id can be retrieved by using Get-APWorkItemWorkItem. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER WorkItemId The id of the process .PARAMETER Expand The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. .PARAMETER BypassRules Do not enforce the work item type rules on this update .PARAMETER SuppressNotifications Do not fire any notifications for this change .PARAMETER ValidateOnly Indicate if you only want to validate the changes without saving the work item .PARAMETER Body The update patch body. See documentation for details. https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/update?view=azure-devops-rest-6.1#request-body *NOTE: body must be an array of objects* .INPUTS None, does not support the pipeline. .OUTPUTS PSObject, Azure Pipelines team(s) .EXAMPLE Updated the title and description for the work item with the id of '1'. $body = @( @{ op = 'add' path = '/fields/System.Title' value = 'New title' } @{ op = 'add' path = '/fields/System.Description' value = 'New description' } ) Update-APWorkItem -Session $session -WorkItemId '1' -Body $body -Verbose -ov results .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/update?view=azure-devops-rest-6.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $WorkItemId, [Parameter()] [ValidateSet('all', 'fields', 'links', 'none', 'relations')] [string] $Expand, [Parameter()] [bool] $BypassRules, [Parameter()] [bool] $SuppressNotifications, [Parameter()] [bool] $ValidateOnly, [Parameter()] [object[]] $Body ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $apiEndpoint = (Get-APApiEndpoint -ApiType 'wit-workitemId') -f $WorkItemId $setAPUriSplat = @{ Collection = $Collection Instance = $Instance ApiVersion = $ApiVersion ApiEndpoint = $apiEndpoint } [uri] $uri = Set-APUri @setAPUriSplat $invokeAPRestMethodSplat = @{ Method = 'PATCH' Uri = $uri Credential = $Credential PersonalAccessToken = $PersonalAccessToken Body = [array] $Body ContentType = 'application/json-patch+json' Proxy = $Proxy ProxyCredential = $ProxyCredential } $results = Invoke-APRestMethod @invokeAPRestMethodSplat If ($results.value) { return $results.value } else { return $results } } end { } } # Wait-APBuild.ps1 function Wait-APBuild { <# .SYNOPSIS Waits for an Azure Pipelines build to exit 'inProgress' status. .DESCRIPTION Waits for an Azure Pipelines build to exit 'inProgress' status based on the build id. The id can be retrieved by using Get-APBuildList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER BuildId The ID of the build .PARAMETER Timeout Timeout threshold in seconds. .PARAMETER PollingInterval The number of seconds to wait before checking the status of the build, defaults to 1. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines build(s) .EXAMPLE Waits for the build with the id of '7' for the 'myFirstProject. Wait-APBuild -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -BuildId 7 .EXAMPLE Waits for only 30 seconds for the build with the id of '9'. Wait-APBuild -Session 'mySession' -BuildId 7 -Timeout 30 .LINK https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/get?view=vsts-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $BuildId, [Parameter()] [int] $Timeout = 300, [Parameter()] [int] $PollingInterval = 1 ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $_timeout = (Get-Date).AddSeconds($TimeOut) $getAPBuildSplat = @{ Collection = $Collection Instance = $Instance BuildId = $BuildId Project = $Project ApiVersion = $ApiVersion } If ($PersonalAccessToken) { $getAPBuildSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPBuildSplat.Credential = $Credential } If ($Proxy) { $getAPBuildSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPBuildSplat.ProxyCredential = $ProxyCredential } Do { $buildData = Get-APBuild @getAPBuildSplat -ErrorAction 'Stop' If ($buildData.Status -eq 'inProgress' -or $buildData.Status -eq 'notStarted') { Write-Verbose ("[{0}] Current status is: [$($buildData.Status)]. Sleeping for [$($PollingInterval)] seconds" -f (Get-Date -Format G)) Start-Sleep -Seconds $PollingInterval } else { return $buildData } } Until ((Get-Date) -ge $_timeout) Write-Error "[$($MyInvocation.MyCommand.Name)]: Timed out after [$TimeOut] seconds. [$($buildData._links.web.href)]" } end { } } # Wait-APOperation.ps1 function Wait-APOperation { <# .SYNOPSIS Waits for an Azure Pipelines operation to exit 'inProgress' status. .DESCRIPTION Waits for an Azure Pipelines operation to exit 'inProgress' status based on the operation id. An operation id is returned by commands like New-APProject. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER OperationId The ID of the operation .PARAMETER Timeout Timeout threshold in seconds. .PARAMETER PollingInterval The number of seconds to wait before checking the status of the operation, defaults to 1. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines operation(s) .EXAMPLE Waits for the operation with the id of '7'. Wait-APOperation -Instance 'https://dev.azure.com' -Collection 'myCollection' -OperationId 7 .EXAMPLE Waits for only 30 seconds for the operation with the id of '9'. Wait-APOperation -Session 'mySession' -OperationId 7 -Timeout 30 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/operations/operations/get?view=azure-devops-rest-5.1 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [string] $OperationId, [Parameter()] [int] $Timeout = 300, [Parameter()] [int] $PollingInterval = 1 ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $_timeout = (Get-Date).AddSeconds($TimeOut) $getAPOperationSplat = @{ Collection = $Collection Instance = $Instance OperationId = $OperationId ApiVersion = $ApiVersion } If ($PersonalAccessToken) { $getAPOperationSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPOperationSplat.Credential = $Credential } If ($Proxy) { $getAPOperationSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPOperationSplat.ProxyCredential = $ProxyCredential } Do { $operationData = Get-APOperation @getAPOperationSplat -ErrorAction 'Stop' If ($operationData.Status -eq 'inProgress' -or $operationData.Status -eq 'notStarted') { Write-Verbose ("[{0}] Current status is: [$($operationData.Status)]. Sleeping for [$($PollingInterval)] seconds" -f (Get-Date -Format G)) Start-Sleep -Seconds $PollingInterval } else { return $operationData } } Until ((Get-Date) -ge $_timeout) Write-Error "[$($MyInvocation.MyCommand.Name)]: Timed out after [$TimeOut] seconds. [$($operationData._links.web.href)]" } end { } } # Wait-APRelease.ps1 function Wait-APRelease { <# .SYNOPSIS Waits for an Azure Pipelines release to exit 'inProgress' status. .DESCRIPTION Waits for a Azure Pipelines release to exit 'inProgress' status based on the release id. The id can be retrieved by using Get-APReleaseList. .PARAMETER Instance The Team Services account or TFS server. .PARAMETER Collection For Azure DevOps the value for collection should be the name of your orginization. For both Team Services and TFS The value should be DefaultCollection unless another collection has been created. .PARAMETER Project Project ID or project name. .PARAMETER ApiVersion Version of the api to use. .PARAMETER PersonalAccessToken Personal access token used to authenticate that has been converted to a secure string. It is recomended to uses an Azure Pipelines PS session to pass the personal access token parameter among funcitons, See New-APSession. https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts .PARAMETER Credential Specifies a user account that has permission to send the request. .PARAMETER Proxy Use a proxy server for the request, rather than connecting directly to the Internet resource. Enter the URI of a network proxy server. .PARAMETER ProxyCredential Specifie a user account that has permission to use the proxy server that is specified by the -Proxy parameter. The default is the current user. .PARAMETER Session Azure DevOps PS session, created by New-APSession. .PARAMETER ReleaseId The ID of the release .PARAMETER Environment The name of the environment to check the status for. .PARAMETER Timeout Timeout threshold in seconds. .PARAMETER PollingInterval The number of seconds to wait before checking the status of the release, defaults to 1. .INPUTS None, does not support pipeline. .OUTPUTS PSObject, Azure Pipelines release(s) .EXAMPLE Waits for the release with the id of '7' for the 'myFirstProject. Wait-APRelease -Instance 'https://dev.azure.com' -Collection 'myCollection' -Project 'myFirstProject' -ReleaseId 7 .EXAMPLE Waits for only 30 seconds for the release with the id of '9'. Wait-APRelease -Session 'mySession' -ReleaseId 7 -Timeout 30 .LINK https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases?view=azure-devops-rest-5.0 #> [CmdletBinding(DefaultParameterSetName = 'ByPersonalAccessToken')] Param ( [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [uri] $Instance, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Collection, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $Project, [Parameter(Mandatory, ParameterSetName = 'ByPersonalAccessToken')] [Parameter(Mandatory, ParameterSetName = 'ByCredential')] [string] $ApiVersion, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Security.SecureString] $PersonalAccessToken, [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $Credential, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [string] $Proxy, [Parameter(ParameterSetName = 'ByPersonalAccessToken')] [Parameter(ParameterSetName = 'ByCredential')] [pscredential] $ProxyCredential, [Parameter(Mandatory, ParameterSetName = 'BySession')] [object] $Session, [Parameter(Mandatory)] [int] $ReleaseId, [Parameter(Mandatory)] [string] $Environment, [Parameter()] [int] $Timeout = 300, [Parameter()] [int] $PollingInterval = 1 ) begin { If ($PSCmdlet.ParameterSetName -eq 'BySession') { $currentSession = $Session | Get-APSession If ($currentSession) { $Instance = $currentSession.Instance $Collection = $currentSession.Collection $Project = $currentSession.Project $PersonalAccessToken = $currentSession.PersonalAccessToken $Credential = $currentSession.Credential $Proxy = $currentSession.Proxy $ProxyCredential = $currentSession.ProxyCredential If ($currentSession.Version) { $ApiVersion = (Get-APApiVersion -Version $currentSession.Version) } else { $ApiVersion = $currentSession.ApiVersion } } } } process { $_timeout = (Get-Date).AddSeconds($TimeOut) $getAPReleaseSplat = @{ Collection = $Collection Instance = $Instance ReleaseId = $ReleaseId Project = $Project ApiVersion = $ApiVersion } If ($PersonalAccessToken) { $getAPReleaseSplat.PersonalAccessToken = $PersonalAccessToken } If ($Credential) { $getAPReleaseSplat.Credential = $Credential } If ($Proxy) { $getAPReleaseSplat.Proxy = $Proxy } If ($ProxyCredential) { $getAPReleaseSplat.ProxyCredential = $ProxyCredential } Do { $releaseData = Get-APRelease @getAPReleaseSplat -ErrorAction 'Stop' $_environmentStatus = $releaseData.environments | Where-Object { $PSItem.name -eq $Environment } | Select-Object -ExpandProperty 'Status' If ($_environmentStatus -eq 'inProgress' -or $_environmentStatus -eq 'queued') { Write-Verbose ("[{0}] Current status is: [$($_environmentStatus)]. Sleeping for [$($PollingInterval)] seconds" -f (Get-Date -Format G)) Start-Sleep -Seconds $PollingInterval } else { return $releaseData } } Until ((Get-Date) -ge $_timeout) Write-Error "[$($MyInvocation.MyCommand.Name)]: Timed out after [$TimeOut] seconds. [$($releaseData._links.web.href)]" } end { } } # Write-APLogMessage.ps1 function Write-APLogMessage { <# .SYNOPSIS Pipeline invocation command that writes a log message to a powershell channel or an Azure DevOps pipeline timeline record log. .DESCRIPTION Writes a log message to a powershell channel or an Azure DevOps pipeline timeline record log. Pipeline invocation commands make changes during pipeline execution. If the command is excuted in a console window the command will output logging messages. .PARAMETER Message The log message. .PARAMETER Error Switch, the log should be an error. .PARAMETER Warning Switch, the log should be a warning. .INPUTS None, does not support the pipline .OUTPUTS Log, error or warning. .EXAMPLE Write-APLogMessage -Message 'This is an error message!' -Error .EXAMPLE Write-APLogMessage -Message 'This is an warning message!' -Warning #> [CmdletBinding(DefaultParameterSetName = 'ByError')] param ( [Parameter(Mandatory)] [string] $Message, [Parameter(Mandatory, ParameterSetName = 'ByError')] [switch] $Error, [Parameter(Mandatory, ParameterSetName = 'ByWarning')] [switch] $Warning ) begin { If ($env:Build_BuildId -or $env:Release_DefinitionId) { $pipelineInvocation = $true } } process { Switch ($PSCmdlet.ParameterSetName) { 'ByError' { If ($pipelineInvocation) { Write-Host "##vso[task.logissue type=error;]$Message" } else { Write-Error -Message $Message } } 'ByWarning' { If ($pipelineInvocation) { Write-Host "##vso[task.logissue type=warning;]$Message" } else { Write-Warning -Message $Message } } } } end { } } # Imported from [D:\a\1\s\AzurePipelinesPS\Tests] |