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:
File diff suppressed because it is too large
Load Diff
56
Powershell/Lists/Azure/AppInsightsWorkspace.ps1
Normal file
56
Powershell/Lists/Azure/AppInsightsWorkspace.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
#Connect-AzAccount
|
||||
|
||||
[string] $date = Get-Date -Format "yyyy-MM-dd HHmm"
|
||||
$fileName = ".\$date appinsights.csv"
|
||||
|
||||
$subscriptions = Get-AzSubscription | Where-Object State -eq "Enabled"
|
||||
|
||||
class AppInsightsCheck {
|
||||
[string] $SubscriptionId = ""
|
||||
[string] $SubscriptionName = ""
|
||||
[string] $Id = ""
|
||||
[string] $ResourceGroupName = ""
|
||||
[string] $Name = ""
|
||||
[string] $WorkspaceResourceId = ""
|
||||
[string] $Tag_Team = ""
|
||||
[string] $Tag_Product = ""
|
||||
[string] $Tag_Environment = ""
|
||||
[string] $Tag_Data = ""
|
||||
[string] $Tag_CreatedOnDate = ""
|
||||
[string] $Tag_Deployment = ""
|
||||
}
|
||||
|
||||
[AppInsightsCheck[]]$Result = @()
|
||||
|
||||
foreach ($subscription in $subscriptions)
|
||||
{
|
||||
Set-AzContext -SubscriptionId $subscription.Id
|
||||
|
||||
$allAppinsights = Get-AzApplicationInsights
|
||||
foreach ($appinsights in $allAppinsights)
|
||||
{
|
||||
[AppInsightsCheck] $AppInsightsCheck = [AppInsightsCheck]::new()
|
||||
|
||||
$AppInsightsCheck.SubscriptionId = $subscription.Id
|
||||
$AppInsightsCheck.SubscriptionName = $subscription.Name
|
||||
$AppInsightsCheck.Id = $appinsights.Id
|
||||
$AppInsightsCheck.Name = $appinsights.Name
|
||||
$AppInsightsCheck.ResourceGroupName = $appinsights.ResourceGroupName
|
||||
$AppInsightsCheck.WorkspaceResourceId = $appinsights.WorkspaceResourceId
|
||||
|
||||
$resource = Get-AzResource -ResourceId $appinsights.Id
|
||||
|
||||
$AppInsightsCheck.Tag_Team = $resource.Tags.team
|
||||
$AppInsightsCheck.Tag_Product = $resource.Tags.product
|
||||
$AppInsightsCheck.Tag_Environment = $resource.Tags.environment
|
||||
$AppInsightsCheck.Tag_Data = $resource.Tags.data
|
||||
$AppInsightsCheck.Tag_CreatedOnDate = $resource.Tags.CreatedOnDate
|
||||
$AppInsightsCheck.Tag_Deployment = $resource.Tags.drp_deployment
|
||||
|
||||
$Result += $AppInsightsCheck
|
||||
}
|
||||
}
|
||||
|
||||
$Result | Export-Csv -Path $fileName -NoTypeInformation -Force
|
||||
|
||||
$Result | ft
|
||||
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