Monthly Archives: March 2012

C#.NET – Create Mailboxes

C#.NET – Create Mailboxes

Updated:

Version 1.0.1 is released

I’ve added the possibility to create Room, Equipment and Shared Mailboxes.
The zip file with the application is now updated, one CSV example file is included.

=====

This is my 3rd C#.Net application, this one is creating mailboxes based on CSV file (semi colon separated).

I’m using FileHelpers for reading the CSV file, this dll file is embedded into the exe file for easier handle.

The application is using remote PowerShell, so make sure that you have enabled remote PowerShell for the user that’s configured.
Follow this link: http://technet.microsoft.com/en-us/library/dd298084.aspx

The remote PowerShell connection mechanism is the default (Windows Auth) one.

Start with browsing for the CSV file, semi colon separated (;), then press the Load button for loading up the contents in the CSV file.
The items will be counted in the upper right corner.

Next step is to press the Verify button for checking so that the mailboxes doesn’t already exists.
If some of them already exist, the Create button will not be clickable.
If some mailbox already exists, make sure to edit the CSV file and load it again and then hit the Verify button.

When none of the listed mailboxes are found, the Create button will be clickable.

After the mailboxes has been created it will list them with UPN and Status (OK, Created).
If you want to be sure that they were created, press the Verify button for checking if they exist.

(Or search for them using EMC/EMS)

image

Feel free to use the application how much you want, use it at your own risk and I don’t do any kind of support for it.

The application can be downloaded here.
CSV file example is included.

Thanks for reading

Selected PowerShell commands, output to CSV file

Selected PowerShell commands, output to CSV file

Here’s a sample on a basic PowerShell script that combines Get-Mailbox, Get-User and Get-MailboxStatistics commands.

The specified objects will be saved into a CSV file.

You can download the script here.

I would be more than happy for any kind of comment or feedback
Feel free to use the script below


#############################################################################
 # PS-Merge.ps1
 # Description:
 # This script combines three commands and sends the output into a CSV file
 #
 # Jonas Andersson, MCC 2011
 # http://www.testlabs.se/blog
 # Twitter @jonand82
 #############################################################################

#Add Exchange Management Snap-In to recognize Exchange CmdLets in PowerShell
 Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue

$Database = @{Name="Database";Expression={ $stats.database }}
 $DisplayName = @{Name="DisplayName";Expression={ $stats.DisplayName }}
 $StorageLimitStatus = @{Name="StorageLimitStatus";Expression={ $stats.StorageLimitStatus }}
 $TotalItemSize = @{Name="MailboxSize";Expression={ $stats.TotalItemSize }}
 $Company = @{Name="Company";Expression={ $user.Company}}
 $FirstName = @{Name="FirstName";Expression={ $user.FirstName}}
 $LastName = @{Name="LastName";Expression={ $user.LastName}}
 $LastLogon = @{Name="LastLogon";Expression={ $stats.LastLoggedOnUserAccount}}
 $LastLogonTime = @{Name="LastLogonTime";Expression={ $stats.LastLogonTime}}

$Mailboxes = Get-Mailbox -ResultSize Unlimited
 $Mailboxes | foreach {
 $user = Get-User $_
 $stats = Get-MailboxStatistics $_
 $_ | select Alias,SamAccountName,$DisplayName,$FirstName,$LastName,$LastLogon,$LastLogonTime,$Company,*SMTP*,$Database,$StorageLimitStatus,$TotalItemSize,RecipientTypeDetails
 } | Export-CSV -NoTypeInformation C:\output.csv