new-mailbox cmdlet and log
Hi.I have written a script to make new mailboxes. This script is very simple, is just like this:import-csv newusers.csv | new-mailbox The command new-mailbox has some parameters that I haven't written above. It works fine.But if some of these identities already exists in Active Directory, then some red words appear in the powershell window, warning of this error.I'd like to keep a log about all errors found by new-mailbox command. And if new users is successfully created, then I would also like to have it in this log.Do you know how to keep a log when using new-mailbox cmdlet?Thanks, bye,Mig. En.
November 4th, 2009 1:35pm

You can pipe the result to a log file by using > logfile.txtShaun
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2009 1:52pm

Ok, thanks, but I need that the log file contains only the logins that have caused an error (maybe because they already exist).If I redirect the output, then there is a lot of text and the user who has to read the log doesn't need to know about cmdlets or Exchange, this user is just an operator who runs scripts in order to make new users, remove them, and so on.Thank you anyway,Mig. En.
November 4th, 2009 8:49pm

In that case you need to format the output with just user name and the error coming up, below is for moving mailbox but you can create similar error reporting script with new-mailbox cmdlet... PowerShell Script: Move Mailboxes From Exchange 2003 to Exchange 2007 http://exchangeshare.wordpress.com/2007/11/20/powershell-script-move-mailboxes-from-exchange-2003-to-exchange-2007/Amit Tank MVP: Exchange Server | MCTS: Microsoft Exchange Server 2010, ConfigurationMCITP: EMA | MCSA: M | Blog: http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2009 8:58pm

Thank you very much for your help, Amit.I didn't know about the $error variable. By the way, I found a little mistake at your post. It is needed a pipe in the write-output cmdlets. The right version of your script is at:http://gallery.technet.microsoft.com/ScriptCenter/en-us/a394cb8f-3033-457a-9b7b-258014b21cebThank you very much,Mig.En.
November 6th, 2009 8:29pm

Oh yeh, I moved/migrated my blog from BlogSpotto Wordpress and pipe was not supported character at blogspt. Thanks for pointing it out, I have corrected it... :)Amit Tank MVP: Exchange Server | MCTS: Microsoft Exchange Server 2010, ConfigurationMCITP: EMA | MCSA: M | Blog: http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
November 6th, 2009 8:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics