mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-28 03:02:19 +01:00
First importable
This commit is contained in:
@@ -23,17 +23,4 @@ function Get-BlobEffectoryDomainResources {
|
||||
}
|
||||
|
||||
$loadedResources
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# $context = New-AzStorageContext -ConnectionString "DefaultEndpointsProtocol=https;AccountName=runbookseffectory;AccountKey=PIyewEcppMcm8imMhpUUOgrOUbWyFPK0o8PfdwPnEiNvEQqUvTDzjuV4W18z2sBuRzspGs5pV/Fz96umfePviw==;EndpointSuffix=core.windows.net"
|
||||
# Get-AzTrafficManagerProfile | Export-Csv "$Env:temp/test4.csv"
|
||||
# Set-AzStorageBlobContent -Context $context -Container "dangling-dns" -File "$Env:temp/test4.csv" -Blob "test2.csv" -Force >$null
|
||||
|
||||
# Get-AzStorageBlobContent -Context $context -Container "dangling-dns" -Blob "test2.csv" -Destination "$Env:temp/test3.csv" -Force
|
||||
# $foo = Import-CSV "$Env:temp/test3.csv"
|
||||
|
||||
# $foo
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#Requires -Modules Az.Accounts,Az.Websites,Az.FrontDoor,Az.Storage,Az.Cdn,Az.Network,Az.TrafficManager,Az.ContainerInstance
|
||||
function Get-EffectoryDomainResources {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Find resources in Azure that have DNS records
|
||||
.DESCRIPTION
|
||||
Gets all resources that have hostnames.
|
||||
.PARAMETER subscriptionId
|
||||
Optional Subscription Id to set the context to. Otherwise uses the current context.
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $effectoryDomainPattern,
|
||||
[Parameter()]
|
||||
[string] $subscriptionId
|
||||
)
|
||||
|
||||
# Initialize
|
||||
[EffectoryDomainNameCheck[]]$result = @()
|
||||
[string]$effectoryDomainPattern = "*.effectory.com"
|
||||
|
||||
# Get subscription info
|
||||
[Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext]$currentContext = $null
|
||||
if (![string]::IsNullOrWhitespace($subscriptionId)) {
|
||||
$currentContext = Set-AzContext -SubscriptionId $subscriptionId
|
||||
}
|
||||
else {
|
||||
$currentContext = Get-AzContext
|
||||
$subscriptionId = $currentContext.Subscription
|
||||
}
|
||||
|
||||
Write-Host "Processing subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking WebApps and WebApp Slots for subscription $($currentContext.Name)"
|
||||
$webApps = Get-AzWebApp
|
||||
[int]$webAppCounter = 0
|
||||
[int]$webAppSlotCounter = 0
|
||||
|
||||
if ($null -ne $webApps) {
|
||||
# check webapps
|
||||
$itemsWebApps = CheckWebApps -subscription $currentContext -webApps $webApps -effectoryDomainPattern $effectoryDomainPattern
|
||||
$webAppCounter += $itemsWebApps.Count
|
||||
$result += $itemsWebApps
|
||||
|
||||
# check webapp slots
|
||||
foreach ($webApp in $webApps) {
|
||||
$slot = Get-AzWebAppSlot -WebApp $webApp
|
||||
if ($null -ne $slot) {
|
||||
$itemsWebAppSlots = CheckWebApps -subscription $currentContext -webApps $slot -effectoryDomainPattern $effectoryDomainPattern
|
||||
$webAppSlotCounter += $itemsWebAppSlots.Count
|
||||
$result += $itemsWebAppSlots
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host "Found $($webAppCounter) WebApps and $($webAppSlotsCounter) WebApp Slots for subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking FrontDoor Endpoints for subscription $($currentContext.Name)"
|
||||
$frontDoors = Get-AzFrontDoor
|
||||
[int]$frontDoorEndPointCounter = 0
|
||||
|
||||
if ($null -ne $frontDoors) {
|
||||
$itemsFrontDoors = CheckFrontDoorEndPoints -subscription $currentContext -frontDoors $frontDoors -effectoryDomainPattern $effectoryDomainPattern
|
||||
$frontDoorEndPointCounter += $itemsFrontDoors.Count
|
||||
$result += $itemsFrontDoors
|
||||
}
|
||||
Write-Host "Found $($frontDoorEndPointCounter) FrontDoor Endpoints for subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking Storage Accounts for subscription $($currentContext.Name)"
|
||||
$storageAccounts = Get-AzStorageAccount | Where-Object { $_.CustomDomain.Name -like $effectoryDomainPattern } # storage accounts
|
||||
[int]$storageCounter = 0
|
||||
|
||||
if ($null -ne $storageAccounts) {
|
||||
$itemsStorage = CheckStorageAccounts -subscription $currentContext -storageAccounts $storageAccounts -effectoryDomainPattern $effectoryDomainPattern
|
||||
$storageCounter += $itemsStorage.Count
|
||||
$result += $itemsStorage
|
||||
}
|
||||
Write-Host "Found $($storageCounter) Storage Accounts for subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking Cdn Endpoints for subscription $($currentContext.Name)"
|
||||
$cdnProfiles = Get-AzCdnProfile
|
||||
[int]$cdnCounter = 0
|
||||
|
||||
if ($null -ne $cdnProfiles) {
|
||||
$itemsCdn = CheckCdnEndpoints -subscription $currentContext -cdnProfiles $cdnProfiles -effectoryDomainPattern $effectoryDomainPattern
|
||||
$cdnCounter += $itemsCdn.Count
|
||||
$result += $itemsCdn
|
||||
}
|
||||
Write-Host "Found $($cdnCounter) Cdn Endpoints for subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking public IP addresses for subscription $($currentContext.Name)"
|
||||
$ipAddresses = Get-AzPublicIpAddress | Where-Object DnsSettings -ne $null | Where-Object { $_.DnsSettings.DomainNameLabel -ne "" }
|
||||
[int]$ipCounter = 0
|
||||
|
||||
if ($null -ne $ipAddresses) {
|
||||
$itemsIpAddresses = CheckIpAddresses -subscription $currentContext -ipAddresses $ipAddresses -effectoryDomainPattern $effectoryDomainPattern
|
||||
$ipCounter += $itemsIpAddresses.Count
|
||||
$result += $itemsIpAddresses
|
||||
}
|
||||
Write-Host "Found $($ipCounter) public IP addresses for subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking Traffic Managers for subscription $($currentContext.Name)"
|
||||
$trafficManagers = Get-AzTrafficManagerProfile
|
||||
[int]$trafficManagerCounter = 0
|
||||
|
||||
if ($null -ne $trafficManagers) {
|
||||
$itemsTrafficManagers = CheckTrafficManagers -subscription $currentContext -trafficManagers $trafficManagers -effectoryDomainPattern $effectoryDomainPattern
|
||||
$trafficManagerCounter += $itemsTrafficManagers.Count
|
||||
$result += $itemsTrafficManagers
|
||||
}
|
||||
Write-Host "Found $($trafficManagerCounter) Traffic Managers for subscription $($currentContext.Name)"
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking Container groups for subscription $($currentContext.Name)"
|
||||
$containerInstances = Get-AzContainerGroup
|
||||
|
||||
if ($null -ne $containerInstances) {
|
||||
throw "Container groups are not implemented yet."
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
Write-Host "Checking API Management for subscription $($currentContext.Name)"
|
||||
$apiManagementServices = Get-AzApiManagement
|
||||
|
||||
if ($null -ne $apiManagementServices) {
|
||||
throw "API Management services are not implemented yet."
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
$result
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
function PerformDanglingDnsRecordsCheck() {
|
||||
|
||||
[EffectoryDomainNameCheck[]]$current = @()
|
||||
[EffectoryDomainNameCheck[]]$previous = @()
|
||||
|
||||
# ----------------------------------------------------------------------------------------
|
||||
Write-Host "RETRIEVING PREVIOUS DOMAIN RECSOURCES"
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------
|
||||
Write-Host "RETRIEVING CURRENT DOMAIN RECSOURCES"
|
||||
$subscriptions = Get-AzSubscription | Where-Object State -eq "Enabled"
|
||||
|
||||
foreach ($subscription in $subscriptions)
|
||||
{
|
||||
$items = Get-EffectoryDomainResources -subscriptionId $subscription.Id
|
||||
$current = $current + $items
|
||||
}
|
||||
|
||||
$current
|
||||
}
|
||||
Reference in New Issue
Block a user