mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
Restructured, deleted lists, added service connection list
This commit is contained in:
48
Powershell/Lists/DevOps/Repositories.ps1
Normal file
48
Powershell/Lists/DevOps/Repositories.ps1
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
class Repository {
|
||||
[string] $Id = ""
|
||||
[string] $Name = ""
|
||||
[string] $DefaultBranch = ""
|
||||
[string] $IsDisabled = ""
|
||||
[string] $WebUrl = ""
|
||||
[string] $LastPRDate = ""
|
||||
[string] $LastPRName = ""
|
||||
[string] $LastPRUrl = ""
|
||||
}
|
||||
|
||||
$fileName = "c:\temp\2023-05-03 repositories.csv"
|
||||
|
||||
Write-Host "========================================================================================================================================================================"
|
||||
Write-Host "Creating repository overview."
|
||||
Write-Host "========================================================================================================================================================================"
|
||||
|
||||
$repos = az repos list --organization "https://dev.azure.com/effectory/" --project "survey software" | ConvertFrom-Json | Select-Object
|
||||
|
||||
[Repository[]]$Result = @()
|
||||
|
||||
foreach ($repo in $repos)
|
||||
{
|
||||
[Repository] $repository = [Repository]::new()
|
||||
$repository.Id = $repo.id
|
||||
$repository.Name = $repo.name
|
||||
$repository.DefaultBranch = $repo.defaultBranch
|
||||
$repository.IsDisabled = $repo.isDisabled
|
||||
$repository.WebUrl = $repo.webUrl
|
||||
|
||||
$lastPr = az repos pr list --project "survey software" --repository $repo.name --organization "https://dev.azure.com/effectory/" --status all --top 1 | ConvertFrom-Json | Select-Object
|
||||
|
||||
if ($lastPr) {
|
||||
$repository.LastPRDate = $lastPr.creationDate
|
||||
$repository.LastPRName = $lastPr.title
|
||||
$repository.LastPRUrl = $lastPr.url
|
||||
}
|
||||
|
||||
$Result += $repository
|
||||
}
|
||||
|
||||
$Result | Export-Csv -Path $fileName -Append -NoTypeInformation
|
||||
|
||||
Write-Host "========================================================================================================================================================================"
|
||||
Write-Host "Done."
|
||||
|
||||
# az repos pr list --project "survey software" --repository "ProjectCenter" --organization "https://dev.azure.com/effectory/" --status all --top 1
|
||||
55
Powershell/Lists/DevOps/ServiceConnections.ps1
Normal file
55
Powershell/Lists/DevOps/ServiceConnections.ps1
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
class ServiceConnection {
|
||||
[string] $Id = ""
|
||||
[string] $Name = ""
|
||||
[string] $OperationStatus = ""
|
||||
[string] $AuthorizationScheme = ""
|
||||
[string] $ServicePrincipalApplicationId = ""
|
||||
[string] $ServicePrincipalObjectId = ""
|
||||
[string] $ServicePrincipalName = ""
|
||||
[string] $ServicePrincipalEndDateTime = ""
|
||||
}
|
||||
|
||||
[string] $date = Get-Date -Format "yyyy-MM-dd HHmm"
|
||||
$fileName = ".\$date serviceconnections.csv"
|
||||
|
||||
Write-Host "========================================================================================================================================================================"
|
||||
Write-Host "Creating service connection overview."
|
||||
Write-Host "========================================================================================================================================================================"
|
||||
|
||||
$token = "{INSERT_PERSONAL_ACCESS_TOKEN}"
|
||||
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
|
||||
$organization = "effectory"
|
||||
$project = "Survey%20Software"
|
||||
|
||||
$url="https://dev.azure.com/$organization/$project/_apis/serviceendpoint/endpoints?api-version=6.0-preview.4"
|
||||
$head = @{ Authorization =" Basic $token" }
|
||||
$response = Invoke-RestMethod -Uri $url -Method GET -Headers $head
|
||||
|
||||
[ServiceConnection[]]$Result = @()
|
||||
$response.value | ForEach-Object {
|
||||
[ServiceConnection] $serviceConnection = [ServiceConnection]::new()
|
||||
$serviceConnection.Id = $_.id
|
||||
$serviceConnection.Name = $_.name
|
||||
$serviceConnection.OperationStatus = $_.operationStatus
|
||||
$serviceConnection.AuthorizationScheme = $_.authorization.scheme
|
||||
|
||||
$principalid = $_.authorization.parameters.serviceprincipalid
|
||||
if ($null -ne $principalid) {
|
||||
$principal = Get-AzADServicePrincipal -ApplicationId $principalid
|
||||
$credential = Get-AzADAppCredential -ApplicationId $principalid
|
||||
|
||||
$serviceConnection.ServicePrincipalApplicationId = $principalid
|
||||
$serviceConnection.ServicePrincipalObjectId = $principal.Id
|
||||
$serviceConnection.ServicePrincipalName = $principal.DisplayName
|
||||
$serviceConnection.ServicePrincipalEndDateTime = $credential.EndDateTime
|
||||
}
|
||||
$Result += $serviceConnection
|
||||
}
|
||||
|
||||
$Result | Export-Csv -Path $fileName -Append -NoTypeInformation
|
||||
|
||||
Write-Host "========================================================================================================================================================================"
|
||||
Write-Host "Done."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user