Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Application]::EnableVisualStyles() [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") ############################################## # # # Laden der Exchange Management Shell # # # ############################################## $s = Get-PSSession | Where-Object {$_.ConfigurationName -eq 'Microsoft.Exchange'} if($s){ Write-Host "Exchange Management Shell already loaded" } else { Write-Host "Exchange Management Shell not found - Loading..." . "$env:ExchangeInstallPath\bin\RemoteExchange.ps1" Write-Host "Exchange Management Shell Loaded" Write-Host "Connecting to Exchange server" Connect-ExchangeServer -Auto Write-Host "Connected to Exchange Server" } ############################# # # # Variablen-Bereich # # # ############################# $a = New-Object System.Collections.ArrayList $b = New-Object System.Collections.ArrayList for ( $i = 0 ; $i -le 90 ; $i++){ $date = (Get-Date).AddDays(-$i).ToShortDateString() $date = $date $a.Add($date) $b.Add($date) } ################################################# $Form = New-Object system.Windows.Forms.Form $Form.ClientSize = '907,140' $Form.text = "Exchange MessageLogViewer" $Form.BackColor = "#ffffff" $Form.TopMost = $false $startdatum = New-Object system.Windows.Forms.Label $startdatum.text = "Bitte Startdatum auswählen" $startdatum.AutoSize = $true $startdatum.width = 25 $startdatum.height = 10 $startdatum.location = New-Object System.Drawing.Point(27,21) $startdatum.Font = 'Microsoft Sans Serif,11,style=Bold' $startdatumBox = New-Object system.Windows.Forms.ComboBox $startdatumBox.width = 169 $startdatumBox.height = 20 $startdatumBox.location = New-Object System.Drawing.Point(46,46) $startdatumBox.Font = 'Microsoft Sans Serif,11' $startdatumBox.Dropdownstyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList; $startdatumBox.Add_SelectedIndexChanged({ }) $startdatumBox.DataSource = $a $enddatum = New-Object system.Windows.Forms.Label $enddatum.text = "Bitte Enddatum auswählen" $enddatum.AutoSize = $true $enddatum.width = 25 $enddatum.height = 10 $enddatum.location = New-Object System.Drawing.Point(311,21) $enddatum.Font = 'Microsoft Sans Serif,11,style=Bold' $enddatumBox = New-Object system.Windows.Forms.ComboBox $enddatumBox.width = 169 $enddatumBox.height = 20 $enddatumBox.location = New-Object System.Drawing.Point(325,46) $enddatumBox.Font = 'Microsoft Sans Serif,11' $enddatumBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList; $enddatumBox.Add_SelectedIndexChanged({ }) $enddatumBox.DataSource = $b $startbutton = New-Object system.Windows.Forms.Button $startbutton.text = "Log Anzeigen!" $startbutton.width = 122 $startbutton.height = 30 $startbutton.location = New-Object System.Drawing.Point(585,16) $startbutton.Font = 'Microsoft Sans Serif,11,style=Bold' $endProgramm = New-Object system.Windows.Forms.Button $endProgramm.text = "Beenden" $endProgramm.width = 86 $endProgramm.height = 30 $endProgramm.location = New-Object System.Drawing.Point(722,16) $endProgramm.Font = 'Microsoft Sans Serif,11,style=Bold' $startzeitTB = New-Object system.Windows.Forms.TextBox $startzeitTB.multiline = $false $startzeitTB.width = 100 $startzeitTB.height = 20 $startzeitTB.location = New-Object System.Drawing.Point(115,82) $startzeitTB.Font = 'Microsoft Sans Serif,10' $startzeitTB.Text = Get-Date -Format HH:mm:00 $endzeitTB = New-Object system.Windows.Forms.TextBox $endzeitTB.multiline = $false $endzeitTB.width = 100 $endzeitTB.height = 20 $endzeitTB.location = New-Object System.Drawing.Point(394,81) $endzeitTB.Font = 'Microsoft Sans Serif,10' $endzeitTB.Text = Get-Date -Format HH:mm:00 $startzeit = New-Object system.Windows.Forms.Label $startzeit.text = "Uhrzeit" $startzeit.AutoSize = $true $startzeit.width = 25 $startzeit.height = 10 $startzeit.location = New-Object System.Drawing.Point(52,86) $startzeit.Font = 'Microsoft Sans Serif,10' $endzeit = New-Object system.Windows.Forms.Label $endzeit.text = "Uhrzeit" $endzeit.AutoSize = $true $endzeit.width = 25 $endzeit.height = 10 $endzeit.location = New-Object System.Drawing.Point(325,86) $endzeit.Font = 'Microsoft Sans Serif,10' $allproperties = New-Object system.Windows.Forms.CheckBox $allproperties.text = "Mehr Spalten anzeigen!" $allproperties.AutoSize = $false $allproperties.width = 230 $allproperties.height = 25 $allproperties.location = New-Object System.Drawing.Point(585,80) $allproperties.Font = 'Microsoft Sans Serif,12' $Form.controls.AddRange(@($startdatum,$startdatumBox,$enddatum,$enddatumBox,$startbutton,$endProgramm,$startzeitTB,$endzeitTB,$startzeit,$endzeit,$allproperties)) $startbutton.Add_Click({ if($allproperties.Checked){ $startdate1 = Get-Date $startdatumBox.SelectedItem $startdate2 = Get-Date $startzeitTB.text -Format HH:mm:ss $startdate = $startdate1 + $startdate2 $enddate1 = Get-Date $enddatumBox.SelectedItem $enddate2 = Get-Date $endzeitTB.Text -Format HH:mm:ss $enddate = $enddate1 + $enddate2 Get-MessageTrackingLog -Start $startdate -End $enddate | select Timestamp,EventId,Sender,Recipient*,MessageSubject,ReturnPath,Client*,Server*,Source*,Connector*,Original*,MessgeInfo,EventData | Out-GridView } else{ $startdate1 = Get-Date $startdatumBox.SelectedItem $startdate2 = Get-Date $startzeitTB.text -Format HH:mm:ss $startdate = $startdate1 + $startdate2 $enddate1 = Get-Date $enddatumBox.SelectedItem $enddate2 = Get-Date $endzeitTB.Text -Format HH:mm:ss $enddate = $enddate1 + $enddate2 Get-MessageTrackingLog -Start $startdate -End $enddate | Out-GridView } }) $endProgramm.Add_Click({$Form.Close()}) [void] $Form.ShowDialog()