Exchange Postfächer aus CSV- Datei anlegen

Um Postfächer in einem Exchange 2010 Server anzulegen findet meist die Exchange Management Console ihren Einsatz. Geht es allerdings darum viele Postfächer anzulegen wird das leicht zur Qual. Hier bietet es sich an die notwendigen Daten, wie den Benutzernamen, das Kennwort usw. aus einer CSV- Datei auszulesen und die Postfächer dann automatisiert anlegen zu lassen. Hierfür reicht folgendes kleines Exchange- Management- Shell- Script- eigentlich sogar nur ein Einzeiler:  
Import-Csv -Delimiter ";" c:\users.csv | ForEach-Object -Process { New-Mailbox -Name $_.Name -FirstName $_.FirstName -LastName $_.LastName -OrganizationalUnit $_.OU -UserPrincipalName $_.UPN -Alias $_.alias -Database "Datenbankname" -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -ResetPasswordOnNextLogon $true -RetentionPolicy Policy90days }
  Die Datenquelle (users.csv) mit den Benutzerdaten hierzu sieht in etwa wie folgt aus:  
Name;Firstname;Lastname;OU;UPN;Alias;Password
Meiser, Hans;Hans;Meiser;bayreuth.tk/Users;hans.meiser@bayreuth.tk;hans.meiser;ganzgeheim1
Pummel, Otto;Otto;Pummel;bayreuth.tk/Users;otto.pummel@bayreuth.tk;otto.pummel;ganzgeheim2

  Die verwendeten Parameter sind selbsterklärend und stellen nur einen Teil der möglichen Werte dar. Eine komplette Übersicht erhält man in der Exchange Management Shell unter "Get-Help New-Mailbox"  

		
			

Create Exchange mailboxes from CSV file

Creation of new mailboxes in Exchange 2010 is mostly done by using the Exchange Management Console. If there is the need to create a lot of mailboxes this easily becomes a pain. For this it is much more easy to read the needed data like username, password a.s.o. from a CSV file and then automatically create the mailboxes. The following little Exchange- Management- Shell- script is enough to accomplish this- in fact a one- liner:  
Import-Csv -Delimiter ";" c:\users.csv | ForEach-Object -Process { New-Mailbox -Name $_.Name -FirstName $_.FirstName -LastName $_.LastName -OrganizationalUnit $_.OU -UserPrincipalName $_.UPN -Alias $_.alias -Database "Databasename" -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -ResetPasswordOnNextLogon $true -RetentionPolicy Policy90days }
  The datasource (users.csv) containing the userdata needs to be structured as follows:  
Name;Firstname;Lastname;OU;UPN;Alias;Password
Meiser, Hans;Hans;Meiser;bayreuth.tk/Users;hans.meiser@bayreuth.tk;hans.meiser;ganzgeheim1
Pummel, Otto;Otto;Pummel;bayreuth.tk/Users;otto.pummel@bayreuth.tk;otto.pummel;ganzgeheim2

  The used parameters are quite self- explaining but are only a part of the values possible. The command "Get-Help New-Mailbox" provides a complete overview.