Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,23 @@ function Enable-StorageEncryptionInTransit
$storageAccounts | ForEach-Object {
if ($_.EnableHttpsTrafficOnly)
{
if($_.Kind -eq "FileStorage"){
$fileshares=@()
$fileshares= Get-AzRMStorageShare -StorageAccountName $_.StorageAccountName -ResourceGroupName $_.ResourceGroupName
if(($fileshares|Measure-Object).Count -gt 0)
{
$SMBFileShares = @()
$NFSFileShares = @()
$SMBFileShares = $fileshares|Where-Object{$_.EnabledProtocols -contains "SMB"}
$NFSFileShares = $fileshares|Where-Object{$_.EnabledProtocols -contains "NFS"}
if($NFSFileShares.Count -gt 0 -and $SMBFileShares.Count -eq 0)
{
$storagewithOnlyNFSShares = $_.StorageAccountName
Write-Host "Excluding Storage Accounts $($_.StorageAccountName) with type FileStorage and having only NFS fileshares"
$storageAccounts=$storageAccounts|Where-Object{$_.StorageAccountName -ne $storagewithOnlyNFSShares}
}
}
}
$stgWithEnableHTTPS += $_
}
else
Expand Down Expand Up @@ -609,6 +626,26 @@ function Disable-StorageEncryptionInTransit
$remediatedResourceLog | ForEach-Object {
try
{
$res = Get-AzStorageAccount -ResourceGroupName $_.ResourceGroupName -Name _.StorageAccountName
if($_.Kind -eq "FileStorage"){
$fileshares=@()
$fileshares= Get-AzRMStorageShare -StorageAccountName $_.StorageAccountName -ResourceGroupName $_.ResourceGroupName
if(($fileshares|Measure-Object).Count -gt 0)
{
$SMBFileShares = @()
$NFSFileShares = @()
$SMBFileShares = $fileshares|Where-Object{$_.EnabledProtocols -contains "SMB"}
$NFSFileShares = $fileshares|Where-Object{$_.EnabledProtocols -contains "NFS"}
if($NFSFileShares.Count -gt 0 -and $SMBFileShares.Count -eq 0)
{
$storagewithOnlyNFSShares = $_.StorageAccountName
Write-Host "Excluding Storage Accounts $($_.StorageAccountName) with type FileStorage and having only NFS fileshares"
continue
}
}
}


$output = Set-AzStorageAccount -ResourceGroupName $_.ResourceGroupName -Name $_.StorageAccountName -EnableHttpsTrafficOnly $false -ErrorAction SilentlyContinue
if($output -ne $null)
{
Expand Down
Binary file modified TemplateFiles/RemediationScripts.zip
Binary file not shown.