@@ -310,57 +310,50 @@ Set this parameter so that no sign-in occurs -- you must sign in first. Use this
310310This command produces only STDOUT output (not standard PowerShell) with information about affect accounts.
311311#>
312312param(
313- [boolean ]$BypassConfirmation= $false,
314- [Parameter(Mandatory= $true, ValueFromPipelineByPropertyName= 'SubscriptionId') ]
313+ [boolean ]$BypassConfirmation = $false,
314+ [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = 'SubscriptionId') ]
315315 [String ] $SubscriptionId,
316316 [switch ] $ReadOnly, # Use this if you don't want to make changes, but want to get information about affected accounts
317317 [switch ] $NoSignin # Use this if you are already signed in and don't want to be prompted again
318318)
319319
320320begin {
321321 if ( ! $NoSignin.IsPresent ) {
322- login-azaccount | out-null
322+ Login-AzAccount | Out-Null
323323 }
324324}
325325
326326process {
327327 try {
328- select-azsubscription -subscriptionid $SubscriptionId -erroraction stop | out-null
329- } catch {
330- write-error "Unable to access select subscription '$SubscriptionId' as the signed in user -- ensure that you have access to this subscription." -erroraction stop
328+ Select-AzSubscription -SubscriptionId $SubscriptionId -ErrorAction Stop | Out-Null
329+ }
330+ catch {
331+ Write-Error "Unable to access select subscription '$SubscriptionId' as the signed in user -- ensure that you have access to this subscription." -ErrorAction Stop
331332 }
332333
333- foreach ($account in Get-AzStorageAccount)
334- {
335- if($account.AllowBlobPublicAccess -eq $null -or $account.AllowBlobPublicAccess -eq $true)
336- {
334+ foreach ($account in Get-AzStorageAccount) {
335+ if ($null -eq $account.AllowBlobPublicAccess -or $account.AllowBlobPublicAccess -eq $true) {
337336 Write-host "Account:" $account.StorageAccountName " isn't disallowing public access."
338337
339338 if ( ! $ReadOnly.IsPresent ) {
340- if(!$BypassConfirmation)
341- {
339+ if (!$BypassConfirmation) {
342340 $confirmation = Read-Host "Do you wish to disallow public access? [y/n]"
343341 }
344- if($BypassConfirmation -or $confirmation -eq 'y')
345- {
346- try
347- {
348- set-AzStorageAccount -Name $account.StorageAccountName -ResourceGroupName $account.ResourceGroupName -AllowBlobPublicAccess $false
342+ if ($BypassConfirmation -or $confirmation -eq 'y') {
343+ try {
344+ Set-AzStorageAccount -Name $account.StorageAccountName -ResourceGroupName $account.ResourceGroupName -AllowBlobPublicAccess $false
349345 Write-Host "Success!"
350346 }
351- catch
352- {
353- Write-output $_
347+ catch {
348+ Write-Output $_
354349 }
355350 }
356351 }
357352 }
358- elseif($account.AllowBlobPublicAccess -eq $false)
359- {
360- Write-Host "Account:" $account.StorageAccountName " has public access disabled, no action required."
353+ elseif ($account.AllowBlobPublicAccess -eq $false) {
354+ Write-Host "Account:" $account.StorageAccountName "has public access disabled, no action required."
361355 }
362- else
363- {
356+ else {
364357 Write-Host "Account:" $account.StorageAccountName ". Error, please manually investigate."
365358 }
366359 }
0 commit comments