This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create and Azure Custom Role with the required permissions for the Veeam service. | |
| # Permissions from https://helpcenter.veeam.com/docs/vbr/userguide/azure_service_account_permissions.html?ver=13 | |
| resource "azurerm_role_definition" "veeam_service" { | |
| name = "Veeam Service" | |
| scope = data.azurerm_subscription.current.id | |
| description = "Can perform actions required of Veeam Service Agent" | |
| permissions { | |
| actions = [ | |
| "Microsoft.Authorization/locks/delete", | |
| "Microsoft.Authorization/locks/Read", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ###################### Resource Group ################################################### | |
| # Create resource group | |
| resource "azurerm_resource_group" "rg-routetest" { | |
| name = "rg-vnet-extend-demo" | |
| location = var.location | |
| tags = var.tags | |
| } | |
| ###################### VNET-1 ################################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Update the MDE Extension on all the Windows Arc machines in the current Azure subscription | |
| #Get Latest Version of the MDE Extension (Change Region as appropriate) | |
| $targetVersion= (Get-AzVMExtensionImage -Location "uksouth" -Type "MDE.Windows" -PublisherName "Microsoft.Azure.AzureDefenderForServers" | Sort-Object -Property Version -Descending | Select -First 1).Version | |
| $Target=@{"Microsoft.Azure.AzureDefenderForServers.MDE.Windows" = @{"targetVersion"="$targetVersion"}} | |
| #Loop through Arc Machines | |
| ForEach ($Machine in Get-AzConnectedMachine){ | |
| #Get the MDE Extension if installed and not the current version | |
| $MDEExtension=(Get-AzConnectedMachine -name $Machine.Name -ResourceGroupName $Machine.resourcegroupName).Resource | Where {$_.InstanceViewName -eq "MDE.Windows" -and $_.TypeHandlerVersion -ne $targetVersion} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Returns all the Azure VNETs along with their DNS servers | |
| foreach ($subscription in Get-AzSubscription){ | |
| Set-AzContext $Subscription | Out-Null | |
| Get-AzVirtualNetwork | Select-Object @{N="Subscription";E={$Subscription.Name}}, | |
| Name, | |
| Location, | |
| ResourceGroupName, | |
| @{N="DnsServers";E={$_.DhcpOptions.DnsServers}} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AzureDiagnostics | |
| | extend fromIP=tostring(split(split(msg_s,"from")[1],":")[0]) | |
| | extend toIP=tostring(split(split(msg_s,"to ")[1],":")[0]) | |
| | extend action= strcat(tostring(split(split(msg_s,"Action: ")[1],".")[0]), tostring(split(split(msg_s,"was ")[1],":")[0]) ) | |
| | extend rule= tostring(split(split(msg_s,"Rule: ")[1],":")[0]) | |
| | extend port= trim(":", tostring(split(split(msg_s,toIP)[1]," ")[0])) | |
| | project TimeGenerated, fromIP, toIP, port, action, rule, msg_s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-AzNetworkSecurityGroup -Name $Name -ResourceGroupName $ResourceGroupName ` | |
| | Add-AzNetworkSecurityRuleConfig -Name "ClientCommunicationtoAPIM" -Description "Client communication to API Management" -Access "Allow" -Protocol "tcp" -Direction "Inbound" -Priority 200 -SourceAddressPrefix "internet" -SourcePortRange "*" -DestinationAddressPrefix "VirtualNetwork" -DestinationPortRange (80,443) ` | |
| | Add-AzNetworkSecurityRuleConfig -Name "ManagementEndpointForAzurePortalAndPowerShell" -Description "Management endpoint for Azure portal and PowerShell" -Access "Allow" -Protocol "tcp" -Direction "Inbound" -Priority 210 -SourceAddressPrefix "ApiManagement" -SourcePortRange "*" -DestinationAddressPrefix "VirtualNetwork" -DestinationPortRange (3443) ` | |
| | Add-AzNetworkSecurityRuleConfig -Name "AzureInfrastructureLoadBalancer" -Description "Azure Infrastru |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get Azure VMs with no marketplace image | |
| Get-AzVm | Where-Object {!($_.StorageProfile.ImageReference)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Redirect example.com/subpage1 to example.com/subpage1.html, example.com/subpage2 to example.com/subpage2.html | |
| #And so on | |
| #Snippet from the nginx config file | |
| #Tested in an Azure PHP WebApp | |
| #Redirect /page to /page.html | |
| location / { | |
| try_files $uri $uri/index.html $uri/index.php $uri.html $uri/ ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Find empty Azure App Service Plans | |
| .DESCRIPTION | |
| Find Azure App Service Plans in the current Azure Context with no App Services associated with them. | |
| These empty App Service Plans will potentially be incurring unneccessary charges. | |
| .EXAMPLE | |
| #Return a list of Empty App Service Plans in the current Azure Context | |
| Get-AzEmptyAppServicePlans | |
| .EXAMPLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Return a List of Azure VMs (in the current context) which are not backed up by Recovery Services Vaults | |
| $BackupStatus=@() | |
| $BackupStatus=foreach ($VM in Get-AzVM) { $VM | Select-Object Name, ResourceGroupName, @{Name="BackedUp";Expression={(Get-AzRecoveryServicesBackupStatus -Name $VM.Name -ResourceGroupName $VM.ResourceGroupName -Type AzureVM).BackedUp }}} | |
| $BackupStatus | Where {$_.BackedUp -eq $false} | Select Name, ResourceGroupName |
NewerOlder