RJSN

EnableFirewallStorageAccounts

Dec 14th, 2017
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Get all the storage accounts
  2. $all = Get-AzureRmResource | where-object { $_.ResourceType -like "Microsoft.Storage/storageAccounts" }
  3.  
  4. # Enable the firewall on all storage accounts and add the IP addresses 1.1.1.1 / changes 1.1.1.1. to your own IP addresses
  5. foreach ($item in $all)
  6. {
  7.   Update-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $item.ResourceGroupName -AccountName $item.Name -Bypass AzureServices,Metrics,Logging -DefaultAction Deny -IpRule (@{IPAddressOrRange="1.1.1.1";Action="allow"},@{IPAddressOrRange="1.1.1.1";Action="allow"},@{IPAddressOrRange="1.1.1.1";Action="allow"},@{IPAddressOrRange="1.1.1.1";Action="allow"})
  8.  
  9. }
Add Comment
Please, Sign In to add comment