Added more storage scripts #115638

This commit is contained in:
Jurjen Ladenius
2025-10-08 08:31:36 +02:00
parent f96deb9bf7
commit 8a57c600a0
11 changed files with 85982 additions and 59 deletions

View File

@@ -1,7 +1,8 @@
param (
[string] $subscriptionId = "",
[string] $resourcegroupName = "",
[string] $storageAccountName = ""
[string] $storageAccountName = "",
[string[]] $specificTables = @()
)
if (("" -eq $subscriptionId) -or ("" -eq $resourcegroupName) -or ("" -eq $storageAccountName)) {
@@ -34,6 +35,21 @@ $fileName = ".\$date - $storageAccountName - tablecheck.csv"
# .\AzureStorageTableQuery.ps1 -subscriptionId "6e2b45e4-5e7b-4628-8827-ec44e23d2f6b" -resourcegroupName "ParticipantIntegration-Settings" -storageAccountName "integrationsettings"
# .\AzureStorageTableQuery.ps1 -subscriptionId "6e2b45e4-5e7b-4628-8827-ec44e23d2f6b" -resourcegroupName "ParticipantIntegration" -storageAccountName "participantintegration"
# .\AzureStorageTableQuery.ps1 -subscriptionId "a134faf1-7a89-4f2c-8389-06d00bd5e2a7" -resourcegroupName "effectorycore" -storageAccountName "coremailings" -specificTables "Recipients"
# .\AzureStorageTableQuery.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "results-activity" -storageAccountName "effactivity" -specificTables "MeasurementParticipants"
# .\AzureStorageTableQuery.ps1 -subscriptionId "e33c30f7-06c7-4765-86a9-7a8979b6d1cc" -resourcegroupName "EffectoryPublicApi" -storageAccountName "effectorypublicapi"
# .\AzureStorageTableQuery.ps1 -subscriptionId "86945e42-fa5a-4bbc-948f-3f5407f15d3e" -resourcegroupName "hierarchy" -storageAccountName "hierarchyeff"
# .\AzureStorageTableQuery.ps1 -subscriptionId "6e2b45e4-5e7b-4628-8827-ec44e23d2f6b" -resourcegroupName "ParticipantIntegration-Settings" -storageAccountName "integrationsettings"
# .\AzureStorageTableQuery.ps1 -subscriptionId "8c282de4-a7df-458e-b151-e10ca7b49966" -resourcegroupName "my-effectory-project-settings" -storageAccountName "projectsettingseffectory" -specificTables "Project"
# .\AzureStorageTableQuery.ps1 -subscriptionId "fced11a2-8ba7-4596-9ff4-de8b47713c48" -resourcegroupName "ResultIntegration" -storageAccountName "resultintegration"
# .\AzureStorageTableQuery.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "results-calculation" -storageAccountName "resultscalculation" -specificTables "Calculations" , "SurveyParticipants"
$surveys = @(3884,
4401,
4426,
@@ -11068,7 +11084,11 @@ $subscription = Set-AzContext -SubscriptionId $subscriptionId
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourcegroupName -Name $storageAccountName
$tables = Get-AzStorageTable -Context $storageAccount.Context #-Name "integrationeventstore"
$tables = Get-AzStorageTable -Context $storageAccount.Context
if ($specificTables.Length -gt 0) {
$tables = $tables | Where-Object { $specificTables -contains $_.Name }
}
foreach ($table in $tables) {
@@ -11085,36 +11105,35 @@ foreach ($table in $tables) {
$obj = $row
#$obj = $row.Payload | ConvertFrom-Json
# if (($null -ne $obj) -and ($null -ne $obj.SurveyId)) {
if (($null -ne $obj)-and ($null -ne $obj.SurveyId)) {
# $survey = [int] $obj.SurveyId
$survey = [int] $obj.SurveyId
# if ($surveys -contains $survey) {
# Write-Warning "Found surveyId that should have been deleted: [$($survey)]"
if ($surveys -contains $survey) {
Write-Warning "Found surveyId that should have been deleted: [$($survey)]"
# [TableCheck] $tableCheck = [TableCheck]::new()
# $tableCheck.SubscriptionId = $subscription.Subscription.Id
# $tableCheck.SubscriptionName = $subscription.Subscription.Name
# $tableCheck.ResourcegroupName = $resourcegroupName
# $tableCheck.StorageAccountName = $storageAccountName
# $tableCheck.TableName = $table.Name
# $tableCheck.SurveyId = $survey
# $tableCheck.Message = "Found surveyId that should have been deleted: [$($survey)]"
# $Result += $tableCheck
# }
# else {
# Write-Information "SurveyId is ok: [$($survey)]"
# }
# }
# else {
# Write-Information "Found row with no SurveyId"
# }
[TableCheck] $tableCheck = [TableCheck]::new()
$tableCheck.SubscriptionId = $subscription.Subscription.Id
$tableCheck.SubscriptionName = $subscription.Subscription.Name
$tableCheck.ResourcegroupName = $resourcegroupName
$tableCheck.StorageAccountName = $storageAccountName
$tableCheck.TableName = $table.Name
$tableCheck.SurveyId = $survey
$tableCheck.Message = "Found surveyId that should have been deleted: [$($survey)]"
$Result += $tableCheck
}
else {
Write-Host "SurveyId is ok: [$($survey)]"
}
}
else {
Write-Host "Found row with no SurveyId"
}
if ($null -ne $obj.PartitionKey) {
if ($null -ne $obj.AccountId){
# $account = [int] $obj.AccountId
$account = [int] $obj.PartitionKey
$account = [int] $obj.AccountId
if ($accounts -contains $account) {
Write-Warning "Found accountId that should have been deleted: [$($account)]"
@@ -11129,11 +11148,11 @@ foreach ($table in $tables) {
$Result += $tableCheck
}
else {
Write-Information "AccountId is ok: [$($account)]"
Write-Host "AccountId is ok: [$($account)]"
}
}
else {
Write-Information "Found row with no AccountId"
Write-Host "Found row with no AccountId"
}
if ($Result.Length -gt 0) {