modules/Libraries/Get-AzDoVariableGroupRoleDefinitions.psm1
<#
.SYNOPSIS Get role definitions for a specific Azure DevOps libary .DESCRIPTION The command will retreive the role definitions for the specificed variable .PARAMETER VariableGroupName The name of the variable group to retrieve .PARAMETER ApiVersion Allows for specifying a specific version of the api to use (default is 5.0) .EXAMPLE Get-AzDoVariableGroupRoleDefinitions -VariableGroupName <variable group name> .NOTES .LINK https://github.com/ravensorb/Posh-AzureDevOps #> function Get-AzDoVariableGroupRoleDefinitions() { [CmdletBinding( DefaultParameterSetName="Name" )] param ( # Common Parameters [PoshAzDo.AzDoConnectObject][parameter(ValueFromPipelinebyPropertyName = $true, ValueFromPipeline = $true)]$AzDoConnection, [string]$ApiVersion = $global:AzDoApiVersion # Module Parameters ) BEGIN { if (-not $PSBoundParameters.ContainsKey('Verbose')) { $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference') } $errorPreference = 'Stop' if ( $PSBoundParameters.ContainsKey('ErrorAction')) { $errorPreference = $PSBoundParameters['ErrorAction'] } if (-Not (Test-Path variable:ApiVersion)) { $ApiVersion = "5.1-preview" } if (-Not $ApiVersion.Contains("preview")) { $ApiVersion = "5.1-preview" } if (-Not (Test-Path varaible:$AzDoConnection) -and $AzDoConnection -eq $null) { $AzDoConnection = Get-AzDoActiveConnection if ($null -eq $AzDoConnection) { Write-Error -ErrorAction $errorPreference -Message "AzDoConnection or ProjectUrl must be valid" } } Write-Verbose "Entering script $($MyInvocation.MyCommand.Name)" Write-Verbose "Parameter Values" $PSBoundParameters.Keys | ForEach-Object { Write-Verbose "$_ = '$($PSBoundParameters[$_])'" } } PROCESS { # https://dev.azure.com/3pager/_apis/securityroles/scopes/distributedtask.variablegroup/roledefinitions $apiUrl = Get-AzDoApiUrl -RootPath $($AzDoConnection.OrganizationUrl) -ApiVersion $ApiVersion -BaseApiPath "/_apis/securityroles/scopes/distributedtask.variablegroup/roledefinitions" $variableGroupRoleDefinitions = Invoke-RestMethod $apiUrl -Headers $AzDoConnection.HttpHeaders Write-Verbose "---------Role Definitions---------" Write-Verbose ($variableGroupRoleDefinitions| ConvertTo-Json -Depth 50 | Out-String) Write-Verbose "---------Role Definitions---------" $variableGroupRoleDefinitions.value } END { Write-Verbose "Leaving script $($MyInvocation.MyCommand.Name)" } } |