Created
May 18, 2017 04:18
-
-
Save averkinderen/6002c7658c5a9d47cb92888dc31c167a to your computer and use it in GitHub Desktop.
This file contains 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
#variables | |
$ResourgeGroupName = Read-Host "Please provide name of ResourgeGroup that will be used for saving the NSG logs" | |
$StorageAccountLogs = Read-Host "Please provide name of Storage Account that will be used for saving the NSG logs" | |
#Login to the Azure Resource Management Account | |
Login-AzureRmAccount | |
Register-AzureRmResourceProvider -ProviderNamespace Microsoft.Insights | |
#region Get Azure Subscriptions | |
$subscriptions = Get-AzureRmSubscription | |
$menu = @{} | |
for ($i = 1;$i -le $subscriptions.count; $i++) | |
{ | |
Write-Host -Object "$i. $($subscriptions[$i-1].Name)" | |
$menu.Add($i,($subscriptions[$i-1].Id)) | |
} | |
[int]$ans = Read-Host -Prompt 'Enter selection' | |
$subscriptionID = $menu.Item($ans) | |
$subscription = Get-AzureRmSubscription -SubscriptionId $subscriptionID | |
Set-AzureRmContext -SubscriptionName $subscription.Name | |
#endregion | |
$subId = (Get-AzureRmContext).Subscription.Id | |
$subName = (Get-AzureRmContext).Subscription.Name | |
#regionGet Azure details details | |
$NW = Get-AzurermNetworkWatcher | |
#endregion | |
Foreach($NW in $NWs){ | |
$NWlocation = $NW.location | |
write-host "Looping trough $NWlocation" -ForegroundColor Yellow | |
#region Enable NSG Flow Logs | |
$nsgs = Get-AzureRmNetworkSecurityGroup | Where-Object {$_.Location -eq $NWlocation} | |
Foreach($nsg in $nsgs) | |
{ | |
Get-AzureRmNetworkWatcherFlowLogStatus -NetworkWatcher $NW -TargetResourceId $nsg.Id | |
Set-AzureRmNetworkWatcherConfigFlowLog -NetworkWatcher $NW -TargetResourceId $nsg.Id -StorageAccountId $storageAccount.Id -EnableFlowLog $false | |
write-host "Diagnostics disabled for $nsg.Name " -BackgroundColor Green | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment