gpt4 book ai didi

Powershell 2 : Unable to suppress warning message

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

我在 powershell 2 中对“set-distributiongroup”进行 cmdlet 调用。我只是将参数“hiddenFromAddressListsEnabled”的值设置为预定义的 bool 值。

但是,无论我尝试什么,如果 bool 赋值实际上没有改变“hiddenFromAddressListsEnabled”的当前值,它就会显示一条警告消息。

这是我正在调用的主要命令:

set-DistributionGroup -identity TestGroup                  `
-hiddenFromAddressListsEnabled=$true

让我们在语义上将我上面所说的定义为“命令”。

现在,我尝试添加几个不同的变体,所有变体都具有适当的行延续和语法。以下是这些变体:
command > $null
command 2> $null
command -ErrorAction:silentlycontinue
command -ErrorVariable $throwAway
command -WarningAction:silentlycontinue
command -WarningVariable $throwAway
$var = command

无论上述一项或多项的各种组合如何,我仍然收到黄色警告:消息吐到输出。具体来说,这:
WARNING: The command completed successfully but no settings of
'<xxxxxx>/Users/TestGroup' have been modified.

对我不理解的关键概念有什么建议吗?我希望命令不产生此输出,并且如果发生这种情况,我希望它默默地继续。

谢谢!!

最佳答案

我一直在尝试在停止服务时抑制警告消息:

WARNING: Waiting for service 'Service Description' to finish stopping...

以下对我有用:
Stop-Service $svc.Name -WarningAction SilentlyContinue

关于Powershell 2 : Unable to suppress warning message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7392943/

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