mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
56 lines
1.8 KiB
PowerShell
56 lines
1.8 KiB
PowerShell
#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 |