How to: Personal Access Tokens Expiration Mapping

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL to list all Personal Access Tokens of all users on the Azure DevOps organization;
  • $Connstr = connection string to Azure SQL Database that stores the report information. To create this report, it’s necessary to create previously a Azure SQL Server and Database and run a script below:
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($PAT)")) }$UriUsers = "https://vssps.dev.azure.com/$($Organization)/_apis/graph/users?api-version=6.1-preview.1"$UsersResult = Invoke-RestMethod -Uri $UriUsers -Method get -Headers $AzureDevOpsAuthenicationHeader Foreach ($user in $UsersResult.value)
{
Write-Host $user.displayName
}
$UriUserPAT = "https://vssps.dev.azure.com/$($Organization)/_apis/tokenadmin/personalaccesstokens/$($user.descriptor)?api-version=6.1-preview.1"    $UserPATResult = Invoke-RestMethod -Uri $UriUserPAT -Method get -Headers $AzureDevOpsAuthenicationHeader    Foreach ($up in $UserPATResult.value)    
{
Write-Host $up.displayName
}
  • User Name (1) = Filter report using User Name field;
  • Personal Access Tokens Informations (2) = List all information about Personal Access Tokens (User Name, User Email, Token Name, Creation Token Date, Expiration Date, and Token Scope);
  • Expiration Tokens by Month Year = uses this Pie chart to filter the next tokens that will expire.

--

--

--

Tech Solution Architect Manager na Accenture

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

C# Fixture to submit start step function

Fun and Useful CLI Tools for Software Developers

CS371p Spring 2019: David Sikabwe

The State of Visual Regression Testing in 2022

Flat a tree using parallel programming

How To Design A Simple Database Schema

Introduction to Software Testing

Significant Trends for Reliable, Fast Multi-Cloud Computing

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinicius Moura

Vinicius Moura

Tech Solution Architect Manager na Accenture

More from Medium

How to: Including a bunch of Work Items on Azure DevOps

How to set up the Azure Front door for your web application?

Getting Started With Azure Bicep

Create Azure Purview using Bicep