Skip to content

Instantly share code, notes, and snippets.

@johnlokerse
Created April 23, 2023 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save johnlokerse/970d99a0c5e8bf5a660d2a6a0ed1d3a8 to your computer and use it in GitHub Desktop.
Save johnlokerse/970d99a0c5e8bf5a660d2a6a0ed1d3a8 to your computer and use it in GitHub Desktop.
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $PersonalAccessToken,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $OrganizationName,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $SecurityGroupId
)
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$PersonalAccessToken"))
$body = @{
"group" = @{
"origin" = "aad"
"originId" = $SecurityGroupId
"subjectKind" = "group"
}
"licenseRule" = @{
"licensingSource" = "account"
"accountLicenseType" = "express"
"licenseDisplayName" = "Basic"
}
}
$invokeRestMethodSplat = @{
Method = "POST"
Uri = "https://vsaex.dev.azure.com/$OrganizationName/_apis/groupentitlements?api-version=7.1-preview.1"
# Add the header for authentication
Headers = @{
"Authorization" = "Basic $auth"
}
ContentType = "application/json"
Body = ($body | ConvertTo-Json -Depth 50)
}
Invoke-RestMethod @invokeRestMethodSplat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment