mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
83 lines
3.8 KiB
PowerShell
83 lines
3.8 KiB
PowerShell
#Connect-AzAccount
|
|
|
|
class ResourceCheck {
|
|
[string] $ResourceId = ""
|
|
[string] $Kind = ""
|
|
[string] $Location = ""
|
|
[string] $ResourceName = ""
|
|
[string] $ResourceGroup = ""
|
|
[string] $ResourceType = ""
|
|
[string] $State = ""
|
|
[string] $SubscriptionId = ""
|
|
[string] $SubscriptionName = ""
|
|
[string] $Tag_Team = ""
|
|
[string] $Tag_Product = ""
|
|
[string] $Tag_Environment = ""
|
|
[string] $Tag_Data = ""
|
|
[string] $Tag_CreatedOnDate = ""
|
|
[string] $Prop_HttpsOnly = ""
|
|
[string] $Prop_PhpVersion = ""
|
|
[string] $Prop_NetFrameworkVersion = ""
|
|
[string] $Prop_WindowsFxVersion = ""
|
|
[string] $Prop_RemoteDebuggingEnabled = ""
|
|
[string] $Prop_MinTlsVersion = ""
|
|
[string] $Prop_FtpsState = ""
|
|
}
|
|
|
|
|
|
Write-Host "======================================================================================================================================================================"
|
|
Write-Host "Creating webapp resource overview."
|
|
Write-Host "======================================================================================================================================================================"
|
|
|
|
$subscriptions = Get-AzSubscription | Where-Object State -eq "Enabled"
|
|
|
|
foreach ($subscription in $subscriptions)
|
|
{
|
|
Write-Host "----------------------------------------------------------------------------------------------------------------------------------------------------------------------"
|
|
|
|
Set-AzContext -SubscriptionId $subscription.Id
|
|
|
|
Write-Host "----------------------------------------------------------------------------------------------------------------------------------------------------------------------"
|
|
|
|
$allResourceGroups = Get-AzResourceGroup
|
|
|
|
foreach ($group in $allResourceGroups) {
|
|
|
|
Write-Host "Resource group $($group.ResourceGroupName)"
|
|
|
|
$allWebApps = Get-AzWebApp -ResourceGroupName $group.ResourceGroupName
|
|
|
|
foreach ($webApp in $allWebApps) {
|
|
|
|
if (($webApp.SiteConfig.FtpsState -ne "Disabled") -and ($webApp.SiteConfig.FtpsState -ne "FtpsOnly")) {
|
|
Write-Host "Disable FTP $($webApp.Name)"
|
|
$x = Set-AzWebApp -Name $webApp.Name -ResourceGroupName $group.ResourceGroupName -FtpsState Disabled
|
|
}
|
|
if (($webApp.SiteConfig.PhpVersion -ne "off") -and ($webApp.SiteConfig.PhpVersion -ne "")) {
|
|
Write-Host "Disable PHP $($webApp.Name)"
|
|
$x = Set-AzWebApp -Name $webApp.Name -ResourceGroupName $group.ResourceGroupName -PhpVersion "off"
|
|
}
|
|
|
|
$allSlots = Get-AzWebAppSlot -Name $webApp.Name -ResourceGroupName $webApp.ResourceGroup
|
|
|
|
foreach ($slotTemp in $allSlots) {
|
|
|
|
[string] $slotName = $slotTemp.Name.Split("/")[1]
|
|
$slot = Get-AzWebAppSlot -Name $webApp.Name -ResourceGroupName $webApp.ResourceGroup -Slot $slotName
|
|
|
|
if (($slot.SiteConfig.FtpsState -ne "Disabled") -and ($webApp.SiteConfig.FtpsState -ne "FtpsOnly")) {
|
|
Write-Host "Disable FTP $($webApp.Name) - $($slotName)"
|
|
$y = Set-AzWebAppSlot -Name $webApp.Name -Slot $slotName -ResourceGroupName $group.ResourceGroupName -FtpsState Disabled
|
|
}
|
|
if (($slot.SiteConfig.PhpVersion -ne "") -and ($slot.SiteConfig.PhpVersion -ne "off")) {
|
|
Write-Host "Disable PHP $($webApp.Name) - $($slotName)"
|
|
$y = Set-AzWebAppSlot -Name $webApp.Name -Slot $slotName -ResourceGroupName $group.ResourceGroupName -PhpVersion "off"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host "======================================================================================================================================================================"
|
|
Write-Host "Done."
|