如何从Azure Powershell命令隐藏警告 [英] How to hide warnings from Azure powershell command lets
问题描述
当我调用一些天蓝色的Commandlet时,我会收到警告. 示例:
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
警告:在将来的Azure PowerShell版本中将不推荐使用GeoReplicationEnabled属性.该值将合并到AccountType属性中.
WARNING: GeoReplicationEnabled property will be deprecated in a future release of Azure PowerShell. The value will be merged into the AccountType property.
请注意:我一直在使用$ verbose:False来避免来自调用的此类消息.但是无法阻止此警告出现.
Please note: I have been using $verbose:False to avoid such messages from the invocation. But could not stop this WARNING from appearing.
推荐答案
您可以尝试-WarningAction Ignore
,但是如果这样做不起作用,则可以将警告流(即流3)重定向到$null
(或到您想要的任何地方):
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
请注意,-Verbose:$false
将影响详细信息,而不是警告,它们是不同的流.
Note that -Verbose:$false
will affect verbose messages, not warnings, which are a different stream.
还请注意,这需要Powershell 3 +:
Also note that this requires Powershell 3+:
全部(*),警告(3),详细(4)和调试(5)重定向 介绍了运算符 在Windows PowerShell 3.0中.它们在早期版本的Windows PowerShell中不起作用.
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.
这篇关于如何从Azure Powershell命令隐藏警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!