我正在进行批量导入,设置或更新AD中1,000个用户的属性6。
我正在使用以下Exchange命令行程序来完成此操作:
[PS] C:\>set-mailbox -Identity [email protected] -CustomAttribute6 [email protected] -WarningAction:SilentlyContinue -ErrorAction SilentlyContinue
上述命令重复1000次,自动生成。
我的问题是,我想生成一个错误列表,我可以反馈到上游来解决错误,如:
我想要消除的是以下文字:
警告:该命令已成功完成,但未修改“company.com/Enterprise/Users/last,first”的设置。
我试过的是设置下面的-WarningAction:SilentlyContinue -ErrorAction SilentlyContinue
似乎Exchange命令行不支持这一点,或者可能是因为Exchange Powershell命令行工具使用“远程处理”存根可能会使error handling复杂化。
运行命令之前,您可以尝试设置警告操作:
$oldWarningPreference = $WarningPreference $WarningPreference = 'SilentlyContinue' set-mailbox -Identity [email protected] -CustomAttribute6 [email protected] -ErrorAction SilentlyContinue $WarningPreference = $oldWarningPreference
重新启动你的shell会话,你的命令应该像你期望的那样工作。 你可以尝试-ErrorAction 0和-WarningAction 0 ,但这些只是别名。