1

I am doing a bulk import, setting or updating attribute6 on 1,000 users in AD.

I'm using the following Exchange commandlet to accomplish this:

 [PS] C:\>set-mailbox -Identity  user@company.com   -CustomAttribute6  knruiz@nfp.com    -WarningAction:SilentlyContinue -ErrorAction SilentlyContinue

The above command is repeated 1000 times and is auto generated.

My problem is that I want to generate a list of errors that I can feed back upstream to resolve errors such as:

  • Missing user
  • Ambiguous user
  • Failure in setting attribute.

What I want to eliminate is the following text:

WARNING: The command completed successfully but no settings of 'company.com/Enterprise/Users/last, first' have been modified.

What I've tried was setting the following -WarningAction:SilentlyContinue -ErrorAction SilentlyContinue

It seems that either the exchange commandlets don't support this, or perhaps because Exchange Powershell commandlets use "remoting" with stubs may be complicating the error handling.

makerofthings7
  • 8,821
  • 28
  • 115
  • 196

2 Answers2

1

You can try setting the warning action before running the command:

$oldWarningPreference = $WarningPreference
$WarningPreference = 'SilentlyContinue'
set-mailbox -Identity  user@company.com -CustomAttribute6 knruiz@nfp.com -ErrorAction SilentlyContinue
$WarningPreference = $oldWarningPreference
xXhRQ8sD2L7Z
  • 685
  • 5
  • 12
0

Restart your shell session, your command should work as you expect. You could try -ErrorAction 0 and -WarningAction 0 but these are just aliases.

Raf
  • 308
  • 1
  • 8