gpt4 book ai didi

powershell - 如何隐藏 Azure PowerShell cmdlet 的警告

转载 作者:行者123 更新时间:2023-12-04 01:16:59 24 4
gpt4 key购买 nike

当我调用一些 azure commandlet 时收到警告。示例:

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

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

警告:GeoReplicationEnabled 属性将在 Azure PowerShell 的 future 版本中弃用。该值将合并到 AccountType 属性中。

请注意:我一直在使用 $verbose:False 来避免调用中出现此类消息。但无法阻止此警告出现。

最佳答案

您可以尝试 -WarningAction Ignore,但如果这不起作用,您可以将警告流(即流 3)重定向到 $null (或重定向到任何你想要的地方):

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

请注意,-Verbose:$false 将影响详细消息,而不是警告,它们是不同的流。

about_Redirection

另请注意,这需要 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.

关于powershell - 如何隐藏 Azure PowerShell cmdlet 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30034259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com