
Hier ist es nun, mein Power Shell GUI Script zum Exportieren von Exchange Postfächern in PST-Dateien!
Diese Seite beinhaltet alle Relevanten Informationen zu dem Script sowie das Change Log. Selbstverständlich kann das Script hier auch als *.zip-Datei heruntergeladen werden :)
[wpfilebase tag=browser id=8/]
#=========================================================================#
# Exchange Server 2010 / 2013 Mailbox-Exporter 1.0 #
# © Andres Sichel // blog.asichel.de // blog@asichel.de #
# Exportiert Exchange Mailboxen in PST-Dateien #
# #
#=========================================================================#
#Für die ausführung muss das Script im STA Modus ausgeführt werden (http://technet.microsoft.com/en-us/magazine/ff629472.aspx)
If ($host.Runspace.ApartmentState -ne 'STA')
# Ausführungspfad wichtig für die HTML DLL GvS.controls muss im Pfad vom Script liegen
$script:Scriptpath = Split-Path $script:MyInvocation.MyCommand.Path
$script:Recipients_Info_Array = New-Object System.Collections.ArrayList
# Systembibliotheken laden
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.VisualStyles")
# Hauptfensterfenster erstellen
$Icon = [system.drawing.icon]::ExtractAssociatedIcon("$scriptpath\icon.ico")
$Font = New-Object System.Drawing.Font("Arial",10,[System.Drawing.FontStyle]::Regular)
$Fenster1 = New-Object System.Windows.Forms.Form
$Fenster1.Size = New-Object System.Drawing.Size(890,710)
$Fenster1.MaximumSize = "890,310"
$Fenster1.MinimumSize = "890,310"
$Fenster1.Text = "Exchange Server 2010 / 2013 Mailbox-Exporter Version 1.0 © Andres Sichel"
$Fenster1.StartPosition = "CenterScreen"
$Fenster1.BackColor = "#B2E4FF"
$Fenster1.Icon = $Icon
$Fenster1.Font = $Font
# Gruppenboxen ermöglichen das verwenden mehrere Radio-Button Gruppen.
# Zudem ist es leichter die Objekte im Fenster anzuordnen
# Gruppenbox fuer MailboxExport
$GroupBoxExport = New-Object System.Windows.Forms.GroupBox
$GroupBoxExport.Location = New-Object System.Drawing.Size(400,100)
$GroupBoxExport.size = New-Object System.Drawing.Size(465,150)
$GroupBoxExport.Font = $Font
$GroupBoxExport.Text = "Mailbox Exportieren:"
$Fenster1.Controls.Add($GroupBoxExport)
# Gruppenbox fuer Server Benutzer und usw
$GroupBoxEXSrv = New-Object System.Windows.Forms.GroupBox
$GroupBoxEXSrv.Location = New-Object System.Drawing.Size(5,100)
$GroupBoxEXSrv.size = New-Object System.Drawing.Size(380,150)
$GroupBoxEXSrv.Font = $Font
$GroupBoxEXSrv.Text = "Mit Exchange Server verbinden"
$Fenster1.Controls.Add($GroupBoxEXSrv)
# Gruppenbox fuer Benutzer-Mailbox
$GroupBoxMBXAlias = New-Object System.Windows.Forms.GroupBox
$GroupBoxMBXAlias.Location = New-Object System.Drawing.Size(400,10)
$GroupBoxMBXAlias.size = New-Object System.Drawing.Size(465,80)
$GroupBoxMBXAlias.Font = $Font
$GroupBoxMBXAlias.Text = "Mailboxalias angeben"
$Fenster1.Controls.Add($GroupBoxMBXAlias)
# Enter drücken zulassen (nur für Benutzerabfragen)
$Fenster1.KeyPreview = $True
$Fenster1.Add_KeyDown()
# Mit Escape wird Abmelden ausgeführt und das Fenster wird geschlossen
$Fenster1.Add_KeyDown()
# Funktionen erstellen
function Anmelden
#Beende Funktion Anmelden
function Abfrage
# Beendet die Funktion Abfrage
function Export # Beendet die Funktion Speichern
function ExportStatusQuery
function Abmelden # Beendet die Funktion Abmelden
function PfadAbfrage
$SpeichernOk =
# Info-Text Anzeigen lassen
$About1 = New-Object System.Windows.Forms.Label
$About1.Location = New-Object System.Drawing.Size(5,10)
$About1.Size =New-Object System.Drawing.Size(400,35)
$About1.Text = "Exchange Server 2010 / 2013 Mailbox-Exporter Version 1.0
© Andres Sichel // blog.asichel.de // blog@asichel.de"
$Fenster1.Controls.Add($About1)
# Anmeldung erfolgreich Textfeld
$AnmledungErg = New-Object System.Windows.Forms.Label
$AnmledungErg.Location = New-Object System.Drawing.Size(7,25)
$AnmledungErg.Size =New-Object System.Drawing.Size(350,20)
$AnmledungErg.Text = "Anmeldung steht noch aus!"
$GroupBoxEXSrv.Controls.Add($AnmledungErg)
# Eingabefeld für Servernamen bauen
$ServerName = New-Object System.Windows.Forms.Textbox
$ServerName.Location = New-Object System.Drawing.Size(10,60)
$ServerName.Size = New-Object System.Drawing.Size(170,20)
$ServerName.Text = "'Servername im FQDN'"
$ServerName.TabIndex = 1
$GroupBoxEXSrv.Controls.Add($ServerName)
# Anmeldebutton bauen
$Login = New-Object System.Windows.Forms.Button
$Login.Location = New-Object System.Drawing.Size(195,60)
$Login.Size = New-Object System.Drawing.Size(80,22)
$Login.Text = "Anmelden"
$Login.TabIndex = 3
$Login.BackColor = "white"
$Login.Add_Click()
$GroupBoxEXSrv.Controls.Add($Login)
# Abfrage aktuelle Benutzer
$WindowsUser = New-Object System.Windows.Forms.CheckBox
$WindowsUser.Location = New-Object System.Drawing.Size(10,90)
$WindowsUser.Size = New-Object System.Drawing.Size(250,20)
$WindowsUser.Text = "Anmeldung mit aktuellem Benutzer"
$WindowsUser.TabIndex = 2
$GroupBoxEXSrv.Controls.Add($WindowsUser)
# Abmeldebutton bauen
$Abmelden = New-Object System.Windows.Forms.Button
$Abmelden.Location = New-Object System.Drawing.Size(290,60)
$Abmelden.Size = New-Object System.Drawing.Size(80,22)
$Abmelden.Text = "Abmelden"
$Abmelden.TabIndex = 19
$Abmelden.BackColor = "white"
$Abmelden.Add_Click()
$GroupBoxEXSrv.Controls.Add($Abmelden)
# Benutzermailbox angeben
$UserName = New-Object System.Windows.Forms.Combobox
$UserName.Location = New-Object System.Drawing.Size(10,30)
$UserName.Size = New-Object System.Drawing.Size(200,20)
$UserName.Text = "'Username angeben'"
$UserName.TabIndex = 4
$GroupBoxMBXAlias.Controls.Add($UserName)
# Benutzermailbox auflösen
$UsernameAbfragen = New-Object System.Windows.Forms.Button
$UsernameAbfragen.Location = New-Object System.Drawing.Size(240,30)
$UsernameAbfragen.Size = New-Object System.Drawing.Size(80,22)
$UsernameAbfragen.Text = "Auflösen"
$UsernameAbfragen.TabIndex = 5
$UsernameAbfragen.BackColor = "white"
$UsernameAbfragen.Add_Click()
$GroupBoxMBXAlias.Controls.Add($UsernameAbfragen)
#Speicherndialog
$PSTSpeichern = New-Object System.Windows.Forms.SaveFileDialog
$PSTSpeichern.ValidateNames =$false
$PSTSpeichern.CheckPathExists =$true
$PSTSpeichern.Filter = "PST File (*.pst)|*.pst|All Files (*.*)|*.*"
$PSTSpeichern.CreatePrompt = $false
$PSTSpeichern.CheckFileExists = $false
$PSTSpeichern.Title = "Speicherpfad angeben (\\servername\freigabe)"
$PSTSpeichern.DefaultExt = "pst"
$PSTSpeichern.InitialDirectory = "::"; #Systemordner Computer / Dieser PC
$PSTSpeichern.FileName = $Info.DisplayName
$PSTSpeichern.RestoreDirectory = $true
$PSTSpeichern.add_FileOk($SpeichernOk)
#MailboxGröße Textfeld erstellen
$MailboxSize = New-Object System.Windows.Forms.Label
$MailboxSize.Location = New-Object System.Drawing.Size(7,25)
$MailboxSize.Size =New-Object System.Drawing.Size(400,20)
$MailboxSize.Text = ""
$GroupBoxExport.Controls.Add($MailboxSize)
# Pfad
$Speicherort = New-Object System.Windows.Forms.Textbox
$Speicherort.Location = New-Object System.Drawing.Size(10,60)
$Speicherort.Size = New-Object System.Drawing.Size(200,20)
$Speicherort.Text = "'Speicherpfad angeben (UNC)'"
$Speicherort.ReadOnly = $true
$Speicherort.TabIndex = 1
$GroupBoxExport.Controls.Add($Speicherort)
# Pfad-Button
$Pfad = New-Object System.Windows.Forms.Button
$Pfad.Location = New-Object System.Drawing.Size(220,60)
$Pfad.Size = New-Object System.Drawing.Size(120,22)
$Pfad.Text = "Pfad auswählen"
$Pfad.TabIndex = 5
$Pfad.BackColor = "white"
$Pfad.Add_Click()
$GroupBoxExport.Controls.Add($Pfad)
# Export-Button
$Export = New-Object System.Windows.Forms.Button
$Export.Location = New-Object System.Drawing.Size(360,60)
$Export.Size = New-Object System.Drawing.Size(80,22)
$Export.Text = "Export"
$Export.TabIndex = 5
$Export.BackColor = "white"
$Export.Add_Click()
$GroupBoxExport.Controls.Add($Export)
#Exportstatusanzeigen lassen
$ExportStatusInfo = New-Object System.Windows.Forms.Label
$ExportStatusInfo.Location = New-Object System.Drawing.Size(7,90)
$ExportStatusInfo.Size =New-Object System.Drawing.Size(450,20)
$ExportStatusInfo.Text = ""
$GroupBoxExport.Controls.Add($ExportStatusInfo)
#Forstschrittsanzeige export
$ExportProgressBar = New-Object System.Windows.Forms.ProgressBar
$ExportProgressBar.Location = New-Object System.Drawing.Size(10,110)
$ExportProgressBar.Size = New-Object System.Drawing.Size(430,20)
$ExportProgressBar.MarqueeAnimationSpeed = 30
$ExportProgressBar.Visible = $true
$GroupBoxExport.Controls.Add($ExportProgressBar)
# Fenster anzeigen lassen
$Fenster1.Add_Shown()
[System.Windows.Forms.Application]::EnableVisualStyles()
#[System.Windows.Forms.Application]::Run($ExportProgressBar)
[void] $Fenster1.ShowDialog()
[…] Mailbox-Exporter […]