mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 10:45:02 +01:00
Merged PR 63012: Added more storage scripts #115638
Added more storage scripts #115638 Related work items: #115638
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
"/subscriptions/181146cf-2354-4167-a6db-94ad14329c4d",
|
||||
"/subscriptions/38a6726a-7c4d-402c-8bc2-36677fc0c3b4",
|
||||
"/subscriptions/e2ebc1a5-47f2-4e95-9aec-9816de2d0dd0",
|
||||
"/subscriptions/c133a016-9848-4855-b7e4-0db51b6970c2"
|
||||
"/subscriptions/c133a016-9848-4855-b7e4-0db51b6970c2",
|
||||
"/subscriptions/3e1654e9-f7f9-4a65-a9b3-8ca3c2f0f2dc"
|
||||
]
|
||||
}
|
||||
@@ -63,6 +63,7 @@
|
||||
"/subscriptions/38a6726a-7c4d-402c-8bc2-36677fc0c3b4",
|
||||
"/subscriptions/e33c30f7-06c7-4765-86a9-7a8979b6d1cc",
|
||||
"/subscriptions/e2ebc1a5-47f2-4e95-9aec-9816de2d0dd0",
|
||||
"/subscriptions/c133a016-9848-4855-b7e4-0db51b6970c2"
|
||||
"/subscriptions/c133a016-9848-4855-b7e4-0db51b6970c2",
|
||||
"/subscriptions/3e1654e9-f7f9-4a65-a9b3-8ca3c2f0f2dc"
|
||||
]
|
||||
}
|
||||
@@ -3,7 +3,8 @@ param (
|
||||
[string] $resourcegroupName = "",
|
||||
[string] $storageAccountName = "",
|
||||
[bool] $containersOnly = $false,
|
||||
[string[]] $excludedContainers = @()
|
||||
[string[]] $excludedContainers = @(),
|
||||
[string] $blobPrefix = ""
|
||||
)
|
||||
|
||||
if (("" -eq $subscriptionId) -or ("" -eq $resourcegroupName) -or ("" -eq $storageAccountName)) {
|
||||
@@ -13,23 +14,43 @@ else {
|
||||
Write-Host "Processing subscription [$subscriptionId], resource group [$resourcegroupName], storage account [$storageAccountName]"
|
||||
}
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "results-activity" -storageAccountName "effactivity"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "Results" -storageAccountName "myeffectoryresults"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "a134faf1-7a89-4f2c-8389-06d00bd5e2a7" -resourcegroupName "Default-Storage-WestEurope" -storageAccountName "ecestore"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "1ab2120c-947c-40e2-96c7-460d3e9659de" -resourcegroupName "sa-backups" -storageAccountName "archivecommvault"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "1ab2120c-947c-40e2-96c7-460d3e9659de" -resourcegroupName "sa-backups" -storageAccountName "backupcommvault"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "2a07dfa7-69ee-4608-b2d5-14124fcccc31" -resourcegroupName "questionnaire-server-weu" -storageAccountName "questionnairestoreweu"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "a134faf1-7a89-4f2c-8389-06d00bd5e2a7" -resourcegroupName "Default-Storage-WestEurope" -storageAccountName "mailingstore"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "a134faf1-7a89-4f2c-8389-06d00bd5e2a7" -resourcegroupName "Default-Storage-WestEurope" -storageAccountName "projectcenter"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "a134faf1-7a89-4f2c-8389-06d00bd5e2a7" -resourcegroupName "effectorycore" -storageAccountName "corerightsaggregator" -ContainersOnly $true
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "3190b0fd-4a66-4636-a204-5b9f18be78a6" -resourcegroupName "authorization" -storageAccountName "authorizationv2"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "86945e42-fa5a-4bbc-948f-3f5407f15d3e" -resourcegroupName "hierarchy" -storageAccountName "hierarchyeff"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "f9ab522b-4895-492d-b8a8-ca6e1f60c2a8" -resourcegroupName "participant-exchange" -storageAccountName "participantexchangev2" -excludedContainers "leases","insights-metrics-pt1m","insights-logs-partitionkeystatistics","insights-logs-dataplanerequests","insights-logs-controlplanerequests","event-attachments","command-handlers","aggregates-streaming","aggregates","`$logs","`$blobchangefeed"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "14c2354d-45a9-4e0f-98ff-be58cdbcddc7" -resourcegroupName "ec-automation-prod" -storageAccountName "stecautomationprod"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "Results" -storageAccountName "myeffectoryresults"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "3190b0fd-4a66-4636-a204-5b9f18be78a6" -resourcegroupName "authorization" -storageAccountName "authorizationv2"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "a134faf1-7a89-4f2c-8389-06d00bd5e2a7" -resourcegroupName "effectorycore" -storageAccountName "coremailings"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "results-activity" -storageAccountName "effactivity" -excludedContainers "`$logs","`$blobchangefeed", "activitybackup-applease", "activitybackup-largemessages", "activitybackup-leases", "activitycleanup-applease", "activitycleanup-leases", "activityprojectors-largemessages", "activityprojectors-leases", "activityquestionnaireavailableactivitygenerat-largemessages", "activityquestionnaireavailableactivitygenerat-leases", "attachments", "azure-webjobs-hosts", "azure-webjobs-secrets", "testhubname-applease", "testhubname-largemessages", "testhubname-leases" -blobPrefix "projects"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "86945e42-fa5a-4bbc-948f-3f5407f15d3e" -resourcegroupName "hierarchy" -storageAccountName "hierarchyeff"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "6e2b45e4-5e7b-4628-8827-ec44e23d2f6b" -resourcegroupName "ParticipantIntegration-Settings" -storageAccountName "integrationsettings"
|
||||
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "1ab2120c-947c-40e2-96c7-460d3e9659de" -resourcegroupName "sa-backups" -storageAccountName "archivecommvault"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "1ab2120c-947c-40e2-96c7-460d3e9659de" -resourcegroupName "sa-backups" -storageAccountName "backupcommvault"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "2a07dfa7-69ee-4608-b2d5-14124fcccc31" -resourcegroupName "questionnaire-server-weu" -storageAccountName "questionnairestoreweu"
|
||||
#
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "f9ab522b-4895-492d-b8a8-ca6e1f60c2a8" -resourcegroupName "participant-exchange" -storageAccountName "participantexchangev2" -excludedContainers "leases","insights-metrics-pt1m","insights-logs-partitionkeystatistics","insights-logs-dataplanerequests","insights-logs-controlplanerequests","event-attachments","command-handlers","aggregates-streaming","aggregates","`$logs","`$blobchangefeed"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "14c2354d-45a9-4e0f-98ff-be58cdbcddc7" -resourcegroupName "ec-measurement" -storageAccountName "stecmeasurementprod"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "2a07dfa7-69ee-4608-b2d5-14124fcccc31" -resourcegroupName "questionnaire-server-weu" -storageAccountName "questionnairedataweu"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "54794e27-b714-4346-81bc-05eae7ccb5a5" -resourcegroupName "question-management-api-weu" -storageAccountName "qmprojectionsweu" -excludedContainers "`$logs","`$blobchangefeed"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "Results" -storageAccountName "myeffectoryresults" -excludedContainers "`$logs","`$blobchangefeed", "attachments", "azure-webjobs-hosts", "azure-webjobs-secrets", "azure-webjobs-dashboard", "azure-webjobs-hosts", "azure-webjobs-secrets", "hierarchydatesettings-leases", "projectcalculations-leases","resultscleanup-applease","resultscleanup-leases","resultsgroupscorecalculator-leases","testhubname-leases"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "results-calculation" -storageAccountName "resultscalculation" -excludedContainers "`$logs","`$blobchangefeed", "attachments", "azure-webjobs-hosts", "azure-webjobs-secrets", "local-leases", "local-applease", "calculations", "calculations-test"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "54794e27-b714-4346-81bc-05eae7ccb5a5" -resourcegroupName "question-management-internaldata_api-weu" -storageAccountName "qmidapiweustore"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "54794e27-b714-4346-81bc-05eae7ccb5a5" -resourcegroupName "question-management-library-weu" -storageAccountName "qmlibraryweu"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "54794e27-b714-4346-81bc-05eae7ccb5a5" -resourcegroupName "question-management-media-api-weu" -storageAccountName "qmmediaweu"
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "54794e27-b714-4346-81bc-05eae7ccb5a5" -resourcegroupName "question-management-api-weu" -storageAccountName "qmprojectionsweu"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "2a07dfa7-69ee-4608-b2d5-14124fcccc31" -resourcegroupName "questionnaire-data-collector-api-weu" -storageAccountName "quedatacolstoreweu"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "34c83aa8-6a8f-4c5e-9c27-0f1730d233bb" -resourcegroupName "start-a-survey" -storageAccountName "startasurvey" -excludedContainers "active-projects","attachments","attachments-logs","azure-webjobs-hosts","azure-webjobs-secrets","durablefunctionshub-largemessages","durablefunctionshub-leases","event-documents","locales","locales-theme-names","pdf-temp","portal","public","schemas"
|
||||
|
||||
# .\AzureStoragebloblist.ps1 -subscriptionId "7feeb150-9ee0-4aea-992a-5f3a89d933e6" -resourcegroupName "rg-yourfeedback-001" -storageAccountName "yourfeedback" -excludedContainers "`$logs","`$blobchangefeed"
|
||||
|
||||
class BlobCheck {
|
||||
[string] $SubscriptionId = ""
|
||||
@@ -46,7 +67,7 @@ $containerToken = $null
|
||||
$blobToken = $null
|
||||
|
||||
[string] $date = Get-Date -Format "yyyy-MM-dd HHmm"
|
||||
$fileName = ".\$date - $storageAccountName - bloblist.csv"
|
||||
$fileName = ".\$date - $storageAccountName - bloblist.csv"
|
||||
|
||||
$subscription = Set-AzContext -SubscriptionId $subscriptionId
|
||||
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourcegroupName -Name $storageAccountName
|
||||
@@ -74,11 +95,10 @@ if ($containersOnly -eq $true) {
|
||||
if ($Result.Length -gt 0) {
|
||||
$Result | Export-Csv -Path $fileName -NoTypeInformation -Append
|
||||
}
|
||||
if ($containers.Length -le 0)
|
||||
{
|
||||
if ($containers.Length -le 0) {
|
||||
Break;
|
||||
}
|
||||
$containerToken = $containers[$containers.Count -1].ContinuationToken;
|
||||
$containerToken = $containers[$containers.Count - 1].ContinuationToken;
|
||||
}
|
||||
while ($null -ne $containerToken)
|
||||
}
|
||||
@@ -92,15 +112,21 @@ elseif ($containersOnly -eq $false) {
|
||||
}
|
||||
|
||||
foreach ($container in $containers) {
|
||||
do {
|
||||
do {
|
||||
[BlobCheck[]]$Result = @()
|
||||
|
||||
$blobList = Get-AzStorageBlob -Container $Container.Name -Context $storageAccount.Context -MaxCount $maxCount -ContinuationToken $blobToken #-Prefix "projects"
|
||||
if ("" -ne $blobPrefix) {
|
||||
$blobList = Get-AzStorageBlob -Container $Container.Name -Context $storageAccount.Context -MaxCount $maxCount -ContinuationToken $blobToken -Prefix $blobPrefix
|
||||
}
|
||||
else {
|
||||
$blobList = Get-AzStorageBlob -Container $Container.Name -Context $storageAccount.Context -MaxCount $maxCount -ContinuationToken $blobToken
|
||||
}
|
||||
|
||||
if ($blobList.Length -le 0) {
|
||||
Break;
|
||||
}
|
||||
|
||||
foreach($blob in $blobList) {
|
||||
foreach ($blob in $blobList) {
|
||||
[BlobCheck] $blobCheck = [BlobCheck]::new()
|
||||
$blobCheck.SubscriptionId = $subscription.Subscription.Id
|
||||
$blobCheck.SubscriptionName = $subscription.Subscription.Name
|
||||
@@ -112,16 +138,15 @@ elseif ($containersOnly -eq $false) {
|
||||
$Result += $blobCheck
|
||||
}
|
||||
$Result | Export-Csv -Path $fileName -NoTypeInformation -Append
|
||||
$blobToken = $blobList[$blobList.Count -1].ContinuationToken;
|
||||
$blobToken = $blobList[$blobList.Count - 1].ContinuationToken;
|
||||
}
|
||||
while ($null -ne $blobToken)
|
||||
}
|
||||
|
||||
if ($containers.Length -le 0)
|
||||
{
|
||||
if ($containers.Length -le 0) {
|
||||
Break;
|
||||
}
|
||||
$containerToken = $containers[$containers.Count -1].ContinuationToken;
|
||||
$containerToken = $containers[$containers.Count - 1].ContinuationToken;
|
||||
}
|
||||
while ($null -ne $containerToken)
|
||||
}
|
||||
11090
Powershell/Lists/Azure/AzureStorageBlobListQuery.ps1
Normal file
11090
Powershell/Lists/Azure/AzureStorageBlobListQuery.ps1
Normal file
File diff suppressed because it is too large
Load Diff
31820
Powershell/Lists/Azure/AzureStorageBlobListQueryNotInList.ps1
Normal file
31820
Powershell/Lists/Azure/AzureStorageBlobListQueryNotInList.ps1
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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) {
|
||||
|
||||
42927
Powershell/Lists/Azure/AzureStorageTableQueryByKey.ps1
Normal file
42927
Powershell/Lists/Azure/AzureStorageTableQueryByKey.ps1
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,6 @@ $serverList= @('c0m7f8nybr.database.windows.net','calculations.database.windows.
|
||||
'logit-backup.database.windows.net', 'mhpfktialk.database.windows.net', 'participants.database.windows.net', 'signin-effectory.database.windows.net',
|
||||
'sqlserver01prod.6a1f4aa9f43a.database.windows.net')
|
||||
|
||||
# 'sqlserver01test.164709c94fb0.database.windows.net', 'replication.database.windows.net',
|
||||
|
||||
$databaseListQuery = @'
|
||||
SELECT name, database_id, create_date
|
||||
FROM sys.databases
|
||||
@@ -54,7 +52,9 @@ foreach ($server in $serverlist) {
|
||||
Write-Host "Server [$server)]"
|
||||
Write-Host "----------------------------------------------------------------------------------------------------------------------------------------------------------------------"
|
||||
|
||||
$access_token = (Get-AzAccessToken -ResourceUrl https://database.windows.net).Token
|
||||
$access_token_secure = (Get-AzAccessToken -ResourceUrl https://database.windows.net).Token
|
||||
$access_token = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($access_token_secure))
|
||||
|
||||
$connectionString = "Data Source=$server;Initial Catalog=master;Persist Security Info=False;Encrypt=True;TrustServerCertificate=False;Application Name=CloudEngineering";
|
||||
|
||||
$databases = Invoke-Sqlcmd -Query $databaseListQuery -ConnectionString $connectionString -AccessToken $access_token
|
||||
|
||||
@@ -3,9 +3,17 @@ $AzureSQLDatabaseName = "yyyy"
|
||||
$SQLOutput = ""
|
||||
|
||||
try {
|
||||
$AzureSQLServerName = $AzureSQLServerName + ".database.windows.net"
|
||||
$Cred = Get-AutomationPSCredential -Name "SQLServerUser-AzureAutomation"
|
||||
$SQLOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName -Username $Cred.UserName -Password $Cred.GetNetworkCredential().Password -Database $AzureSQLDatabaseName -Query "exec [dbo].[AzureSQLMaintenance] @Operation='all' ,@LogToTable=1" -QueryTimeout 65535 -ConnectionTimeout 60 -Verbose) 4>&1
|
||||
$AzureSQLServerName = $AzureSQLServerName + ".database.windows.net"
|
||||
|
||||
Disable-AzContextAutosave -Scope Process
|
||||
$AzureContext = (Connect-AzAccount -Identity).context
|
||||
|
||||
$token = (Get-AzAccessToken -ResourceUrl https://database.windows.net).Token
|
||||
|
||||
$SQLOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName `
|
||||
-Database $AzureSQLDatabaseName `
|
||||
-AccessToken "$token" `
|
||||
-Query "exec [dbo].[AzureSQLMaintenance] @Operation='all' ,@LogToTable=1" -QueryTimeout 65535 -ConnectionTimeout 60 -Verbose) 4>&1
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ Get-AzSubscription | Export-Csv -Path $fileName -NoTypeInformation
|
||||
|
||||
|
||||
|
||||
Set-AzRoleDefinition -InputFile 'C:\Repository\Cloud Engineering\Custom roles\Storage Data Contributor.json'
|
||||
Set-AzRoleDefinition -InputFile 'C:\Repository\Cloud Engineering\Custom roles\Storage Data Reader.json'
|
||||
Set-AzRoleDefinition -InputFile 'C:\Repository\Cloud Engineering\Cloud Engineering\Custom roles\Storage Data Contributor.json'
|
||||
Set-AzRoleDefinition -InputFile 'C:\Repository\Cloud Engineering\Cloud Engineering\Custom roles\Storage Data Reader.json'
|
||||
New-AzRoleDefinition -InputFile 'C:\Repository\Cloud Engineering\Custom roles\Resource Lock Administrator.json'
|
||||
|
||||
|
||||
|
||||
32
SQL/ListDatabaseObjects.sql
Normal file
32
SQL/ListDatabaseObjects.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- Query to list all objects in a database with their types
|
||||
SELECT
|
||||
s.name + '.' + o.name AS ObjectName,
|
||||
CASE o.type
|
||||
WHEN 'U' THEN 'User Table'
|
||||
WHEN 'V' THEN 'View'
|
||||
WHEN 'P' THEN 'Stored Procedure'
|
||||
WHEN 'FN' THEN 'Scalar Function'
|
||||
WHEN 'IF' THEN 'Inline Table Function'
|
||||
WHEN 'TF' THEN 'Table Function'
|
||||
WHEN 'TR' THEN 'Trigger'
|
||||
WHEN 'PK' THEN 'Primary Key'
|
||||
WHEN 'F' THEN 'Foreign Key'
|
||||
WHEN 'C' THEN 'Check Constraint'
|
||||
WHEN 'D' THEN 'Default Constraint'
|
||||
WHEN 'UQ' THEN 'Unique Constraint'
|
||||
WHEN 'S' THEN 'System Table'
|
||||
WHEN 'SQ' THEN 'Service Queue'
|
||||
WHEN 'IT' THEN 'Internal Table'
|
||||
WHEN 'X' THEN 'Extended Stored Procedure'
|
||||
WHEN 'PC' THEN 'CLR Stored Procedure'
|
||||
WHEN 'FS' THEN 'CLR Scalar Function'
|
||||
WHEN 'FT' THEN 'CLR Table Function'
|
||||
WHEN 'AF' THEN 'CLR Aggregate Function'
|
||||
ELSE 'Other'
|
||||
END AS ObjectType,
|
||||
o.modify_date AS ModifiedDate
|
||||
FROM sys.objects o
|
||||
INNER JOIN sys.schemas s ON o.schema_id = s.schema_id
|
||||
WHERE o.is_ms_shipped = 0 -- Exclude system objects
|
||||
and not (o.type in ('TR','PK','F','C','D','UQ','S','SQ','IT','',''))
|
||||
ORDER BY s.name, ObjectType, o.name;
|
||||
Reference in New Issue
Block a user