Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide warnings from Azure powershell command lets

Am getting warnings when i invoke some azure commandlets. Example:

Get-AzureStorageAccount -StorageAccountName $storageName -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -verbose:$false

New-AzureStorageAccount -StorageAccountName $storageName -Location $storageLocation -ErrorAction Stop -WarningAction SilentlyContinue -verbose:$false

WARNING: GeoReplicationEnabled property will be deprecated in a future release of Azure PowerShell. The value will be merged into the AccountType property.

Please note: I have been using $verbose:False to avoid such messages from the invocation. But could not stop this WARNING from appearing.

like image 342
Pradebban Raja Avatar asked May 04 '15 15:05

Pradebban Raja


People also ask

How do I show warnings in PowerShell?

Help (default is "Y"): This command uses the Write-Warning cmdlet to display a warning. The WarningAction common parameter with a value of Inquire directs the system to prompt the user when the command displays a warning. For more information about the WarningAction common parameter, see about_CommonParameters.

Can you run PowerShell commands in Azure CLI?

Azure CLI can be run in both PowerShell and CMD, but PowerShell gives you more tab-completion features.


2 Answers

You could try -WarningAction Ignore, but if that doesn't work, you can redirect the warning stream, which is stream 3, to $null (or to wherever you want):

New-AzureStorageAccount -StorageAccountName $storageName 3> $null
# Left out other parameters for readability

Note that -Verbose:$false will affect verbose messages, not warnings, which are a different stream.

about_Redirection

Also note that this requires Powershell 3+:

The All (*), Warning (3), Verbose (4) and Debug (5) redirection operators were introduced in Windows PowerShell 3.0. They do not work in earlier versions of Windows PowerShell.

like image 50
briantist Avatar answered Oct 05 '22 21:10

briantist


I have exactly the same problem before and solve this by the follow:

New-AzureStorageAccount ... | Out-Null
like image 24
juvchan Avatar answered Oct 05 '22 20:10

juvchan