Skip to content

Instantly share code, notes, and snippets.

@kongou-ae
Last active July 24, 2018 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kongou-ae/e751c032fe8f0cb0fa901a0d756e5f62 to your computer and use it in GitHub Desktop.
Save kongou-ae/e751c032fe8f0cb0fa901a0d756e5f62 to your computer and use it in GitHub Desktop.
Set-AzureRmNetworkWatcherConfigFlowLog
$Region = "westus2"
$NsgName = "vyos-nsg"
$NsgRsgName = "virtualwan"
$LogstorageRsgName = "azs"
$LogStorageName = "azsdiag457"
$NetworkWatcherName = "NetworkWatcher_" + $Region
$NW = Get-AzurermNetworkWatcher -ResourceGroupName NetworkWatcherRG -Name $NetworkWatcherName
$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName $NsgRsgName -Name $NsgName
$storageAccount = Get-AzureRmStorageAccount -ResourceGroupName $LogstorageRsgName -Name $LogStorageName
$res = Get-AzureRmNetworkWatcherFlowLogStatus -NetworkWatcher $NW -TargetResourceId $nsg.Id
if ( $res.Enabled -eq $false ){
Set-AzureRmNetworkWatcherConfigFlowLog -NetworkWatcher $NW -TargetResourceId $nsg.Id `
-StorageAccountId $storageAccount.Id -EnableFlowLog $true `
-EnableRetention $True -RetentionInDays 365
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment