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.

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
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.

  • I attempted this in a new Powershell session. It did not work. – random65537 Apr 29 '14 at 13:37
  • this should work.. are you using new-pssession/import-session to establish connectivity? – Raf May 1 '14 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.