-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasyEXCH-PMA_V1.0.0.ps1
More file actions
2695 lines (2285 loc) · 105 KB
/
easyEXCH-PMA_V1.0.0.ps1
File metadata and controls
2695 lines (2285 loc) · 105 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
.SYNOPSIS
Easy Exchange ProxyAddress Manager - Verwaltung von ProxyMailAddresses für MS365 ADSync
.DESCRIPTION
PowerShell Script mit WPF GUI zur Verwaltung von ProxyMailAddresses für Active Directory Benutzer.
Lädt Benutzer aus lokalem AD, zeigt aktuelle ProxyAddresses und ermöglicht Hinzufügen/Ändern/Löschen.
Prüft automatisch MS365 ADSync-Kompatibilität (berücksichtigt Legacy Exchange Attribute).
.VERSION
1.0.0
.AUTHOR
Andreas Hepp | PhinIT.DE
.DATE
2025-12-08
#>
#Requires -Version 5.1
# Progress Bars deaktivieren (wichtig für -noConsole Kompilierung)
$ProgressPreference = 'SilentlyContinue'
# Assemblies laden
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName WindowsBase
Add-Type -AssemblyName System.Windows.Forms
# Visual Styles aktivieren (MUSS vor GUI-Erstellung erfolgen)
[System.Windows.Forms.Application]::EnableVisualStyles()
# XAML Definition
$xaml = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="easyEXCH ProxyAddress Manager" Height="900" Width="1400"
WindowStartupLocation="CenterScreen" ResizeMode="CanResize">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
<Border Grid.Row="0" Background="#0078D4" Padding="10" CornerRadius="5" Margin="0,0,0,10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Titel -->
<StackPanel Grid.Column="0">
<TextBlock Name="txtTitle" Text="easyEXCH ProxyAddress Manager" FontSize="20" FontWeight="Bold" Foreground="White"/>
<TextBlock Name="txtSubtitle" Text="Verwaltung von ProxyMailAddresses für MS365 ADSync" FontSize="12" Foreground="WhiteSmoke" Margin="0,5,0,0"/>
</StackPanel>
<!-- Sprach-Schalter -->
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="🌐" FontSize="16" Foreground="White" VerticalAlignment="Center" Margin="0,0,5,0"/>
<Button Name="btnLangDE" Content="DE" Width="40" Height="30" Margin="0,0,5,0" Background="#28A745" Foreground="White" FontWeight="Bold" ToolTip="Deutsch"/>
<Button Name="btnLangEN" Content="EN" Width="40" Height="30" Background="#6C757D" Foreground="White" FontWeight="Bold" ToolTip="English"/>
</StackPanel>
</Grid>
</Border>
<!-- Main Content -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="3.5*"/>
</Grid.ColumnDefinitions>
<!-- Left Panel: ProxyAddress Management -->
<Border Grid.Column="0" BorderBrush="#E0E0E0" BorderThickness="1" CornerRadius="5" Padding="10" Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- User Info Header -->
<Border Grid.Row="0" Background="#F0F0F0" Padding="10" CornerRadius="5" Margin="0,0,0,10" Name="pnlUserInfo" Visibility="Collapsed">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock Name="txtSelectedUserName" Text="" FontSize="16" FontWeight="Bold"/>
<TextBlock Name="txtSelectedUserMail" Text="" FontSize="12" Foreground="Gray" Margin="0,2,0,0"/>
<TextBlock Name="txtSelectedUserSAM" Text="" FontSize="10" Foreground="DarkGray" Margin="0,2,0,0"/>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Name="txtValidationStatus" Text="✅ MS365 Kompatibel" FontSize="12" FontWeight="Bold" Foreground="Green" HorizontalAlignment="Right"/>
<TextBlock Name="txtValidationDetails" Text="" FontSize="10" Foreground="Gray" Margin="0,2,0,0" TextWrapping="Wrap" MaxWidth="200" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>
</Border>
<!-- Validation Info -->
<Border Grid.Row="1" Background="#FFF3CD" BorderBrush="#FFC107" BorderThickness="1" Padding="8" CornerRadius="5" Margin="0,0,0,10" Name="pnlValidationInfo" Visibility="Collapsed">
<StackPanel>
<TextBlock Name="lblValidationTitle" Text="⚠️ MS365 ADSync Validierung" FontWeight="Bold" FontSize="11" Foreground="#856404"/>
<TextBlock Name="txtValidationMessages" Text="" FontSize="10" Foreground="#856404" Margin="0,5,0,0" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<!-- ProxyAddresses List -->
<GroupBox Name="grpProxyAddresses" Header="Aktuelle ProxyAddresses" Grid.Row="2" Margin="0,0,0,10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- DataGrid -->
<DataGrid Name="dgProxyAddresses" Grid.Row="0"
AutoGenerateColumns="False"
IsReadOnly="True"
AlternatingRowBackground="LightGray"
GridLinesVisibility="All"
CanUserSortColumns="True"
CanUserResizeColumns="True"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Header="Typ" Binding="{Binding Type}" Width="60"/>
<DataGridTextColumn Header="Adresse" Binding="{Binding Address}" Width="*"/>
<DataGridTextColumn Header="Primär" Binding="{Binding IsPrimary}" Width="50"/>
<DataGridTextColumn Header="Status" Binding="{Binding ValidationStatus}" Width="80"/>
</DataGrid.Columns>
</DataGrid>
<!-- Action Buttons -->
<Grid Grid.Row="1" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Name="btnAddProxy" Grid.Column="0" Content="➕ Hinzufügen" Height="35" Background="#28A745" Foreground="White" FontWeight="Bold" IsEnabled="False" FontSize="11"/>
<Button Name="btnEditProxy" Grid.Column="2" Content="✏️ Bearbeiten" Height="35" Background="#FFC107" Foreground="Black" FontWeight="Bold" IsEnabled="False" FontSize="11"/>
<Button Name="btnDeleteProxy" Grid.Column="4" Content="🗑️ Löschen" Height="35" Background="#DC3545" Foreground="White" FontWeight="Bold" IsEnabled="False" FontSize="11"/>
<Button Name="btnSetPrimary" Grid.Column="6" Content="⭐ Als Primär" Height="35" Background="#0078D4" Foreground="White" FontWeight="Bold" IsEnabled="False" FontSize="11"/>
<Button Name="btnRefresh" Grid.Column="8" Content="🔄 Aktualisieren" Height="35" Background="#6C757D" Foreground="White" FontWeight="Bold" IsEnabled="False" FontSize="11"/>
</Grid>
<!-- No Data Message -->
<TextBlock Name="txtNoProxyData" Grid.Row="0" Text="Kein Benutzer ausgewählt.`nBitte wählen Sie einen Benutzer aus der Liste."
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="14" Foreground="Gray" Visibility="Visible" TextAlignment="Center"/>
</Grid>
</GroupBox>
</Grid>
</Border>
<!-- Right Panel: User Search & List -->
<Border Grid.Column="2" BorderBrush="#E0E0E0" BorderThickness="1" CornerRadius="5" Padding="10" Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Search Options -->
<GroupBox Name="grpSearchUsers" Header="Benutzer suchen" Grid.Row="0" Margin="0,0,0,10">
<StackPanel Margin="5">
<TextBlock Name="lblSearchTerm" Text="Suchbegriff (min. 3 Zeichen - Vorname, Nachname, Email, SAM):" Margin="0,0,0,5" FontSize="11"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Name="txtSearch" Grid.Column="0" Height="25" ToolTip="Automatische Suche ab 3 Zeichen"/>
<Button Name="btnSearch" Grid.Column="2" Content="🔍 Suchen" Height="25" Width="100" Background="#0078D4" Foreground="White" FontWeight="Bold"/>
</Grid>
</StackPanel>
</GroupBox>
<!-- Load All Button -->
<GroupBox Name="grpLoadUsers" Header="Alle Benutzer" Grid.Row="1" Margin="0,0,0,10">
<StackPanel Margin="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Name="btnLoadAll" Grid.Column="0" Content="👥 Alle Benutzer laden" Height="35" Background="#28A745" Foreground="White" FontWeight="Bold"/>
<Button Name="btnCheckADSync" Grid.Column="2" Content="🔍 ADSync prüfen" Height="35" Width="130" Background="#17A2B8" Foreground="White" FontWeight="Bold" IsEnabled="False" ToolTip="Prüft ob alle geladenen Benutzer ADSync-kompatibel sind"/>
</Grid>
<TextBlock Name="txtUserCount" Text="0 Benutzer geladen" Margin="0,5,0,0" FontSize="10" Foreground="Gray" HorizontalAlignment="Center"/>
</StackPanel>
</GroupBox>
<!-- User List -->
<GroupBox Name="grpFoundUsers" Header="Gefundene Benutzer" Grid.Row="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- DataGrid -->
<Grid Grid.Row="0">
<DataGrid Name="dgUsers"
AutoGenerateColumns="False"
IsReadOnly="True"
SelectionMode="Single"
AlternatingRowBackground="LightGray"
GridLinesVisibility="All"
CanUserSortColumns="True"
CanUserResizeColumns="True"
HeadersVisibility="Column">
<DataGrid.Columns>
<DataGridTextColumn Header="Vorname" Binding="{Binding GivenName}" Width="100"/>
<DataGridTextColumn Header="Nachname" Binding="{Binding Surname}" Width="120"/>
<DataGridTextColumn Header="DisplayName" Binding="{Binding DisplayName}" Width="150"/>
<DataGridTextColumn Header="Primäre E-Mail" Binding="{Binding PrimarySMTP}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
<TextBlock Name="txtNoUsers" Text="Keine Benutzer geladen.
Bitte suchen oder alle laden."
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="12" Foreground="Gray" Visibility="Visible" TextAlignment="Center"/>
</Grid>
<!-- Action Buttons -->
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,10,0,0" HorizontalAlignment="Left">
<Button Name="btnExport" Content="📤 Export CSV" Height="30" Width="110" Background="#17A2B8" Foreground="White" FontWeight="Bold" Margin="0,0,5,0" IsEnabled="False" ToolTip="Exportiert alle geladenen ProxyAddresses als CSV"/>
<ComboBox Name="cmbFilter" Width="150" Height="30" Margin="0,0,5,0" SelectedIndex="0">
<ComboBoxItem Content="🔍 Alle anzeigen"/>
<ComboBoxItem Content="✅ Nur kompatible"/>
<ComboBoxItem Content="⚠️ Mit Warnungen"/>
<ComboBoxItem Content="❌ Mit Fehlern"/>
</ComboBox>
<Button Name="btnHistory" Content="📜 History" Height="30" Width="100" Background="#6C757D" Foreground="White" FontWeight="Bold" IsEnabled="False" ToolTip="Zeigt Änderungsverlauf des ausgewählten Benutzers"/>
<Button Name="btnStatistics" Content="📊 Statistik" Height="30" Width="100" Background="#FFC107" Foreground="Black" FontWeight="Bold" Margin="5,0,0,0" IsEnabled="False" ToolTip="Zeigt Statistik-Dashboard"/>
</StackPanel>
</Grid>
</GroupBox>
</Grid>
</Border>
</Grid>
<!-- Footer -->
<Border Grid.Row="2" Background="#F0F0F0" Padding="10" CornerRadius="5" Margin="0,10,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Name="txtStatus" Text="Bereit" VerticalAlignment="Center" Grid.Column="0"/>
<TextBlock Text="Version 1.0.0 | Andreas Hepp - www.PhinIT.DE 2025" VerticalAlignment="Center" FontSize="10" Foreground="Gray" Grid.Column="1"/>
</Grid>
</Border>
</Grid>
</Window>
"@
#region Language Resources
# Aktuelle Sprache (Standard: Deutsch)
$script:CurrentLanguage = "DE"
# Sprachressourcen
$script:LanguageStrings = @{
DE = @{
# Header
Title = "easyEXCH ProxyAddress Manager"
Subtitle = "Verwaltung von ProxyMailAddresses für MS365 ADSync"
# Buttons
Search = "🔍 Suchen"
LoadAll = "👥 Alle Benutzer laden"
CheckADSync = "🔍 ADSync prüfen"
Export = "📤 Export CSV"
History = "📜 History"
Statistics = "📊 Statistik"
Add = "➕ Hinzufügen"
Edit = "✏️ Bearbeiten"
Delete = "🗑️ Löschen"
SetPrimary = "⭐ Als Primär"
Refresh = "🔄 Aktualisieren"
# GroupBox Headers
CurrentProxyAddresses = "Aktuelle ProxyAddresses"
SearchUsers = "Benutzer suchen"
LoadUsers = "Alle Benutzer"
FoundUsers = "Gefundene Benutzer"
# Labels
SearchLabel = "Suchbegriff (min. 3 Zeichen - Vorname, Nachname, Email, SAM):"
UserInfo = "Benutzer-Informationen"
ValidationStatus = "Validierungsstatus"
ValidationTitle = "⚠️ MS365 ADSync Validierung"
Compatible = "✅ MS365 Kompatibel"
NotCompatible = "❌ Nicht kompatibel"
# DataGrid Columns - ProxyAddresses
ColType = "Typ"
ColAddress = "Adresse"
ColPrimary = "Primär"
ColStatus = "Status"
# DataGrid Columns - Users
ColGivenName = "Vorname"
ColSurname = "Nachname"
ColDisplayName = "Anzeigename"
ColPrimarySMTP = "Primäre SMTP"
# Tooltips
TooltipAdd = "Hinzufügen"
TooltipEdit = "Bearbeiten"
TooltipDelete = "Löschen"
TooltipSetPrimary = "Als Primär"
TooltipRefresh = "Aktualisieren"
TooltipGerman = "Deutsch"
TooltipEnglish = "English"
TooltipADSync = "Prüft ob alle geladenen Benutzer ADSync-kompatibel sind"
TooltipSearch = "Automatische Suche ab 3 Zeichen"
# Filter
FilterAll = "🔍 Alle anzeigen"
FilterValid = "✅ Nur kompatible"
FilterWarnings = "⚠️ Mit Warnungen"
FilterErrors = "❌ Mit Fehlern"
# Messages
NoUsersLoaded = "Keine Benutzer geladen.`nBitte suchen oder alle laden."
NoUsersFound = "Keine Benutzer gefunden für '{0}'.`nBitte ändern Sie den Suchbegriff."
NoUserSelected = "Kein Benutzer ausgewählt.`nBitte wählen Sie einen Benutzer aus der Liste."
MinChars = "Mindestens 3 Zeichen eingeben..."
Ready = "Bereit"
# Status
UsersLoaded = "{0} Benutzer geladen"
UsersFoundCount = "{0} Benutzer gefunden"
# Dynamic Messages
LoadingUsers = "Lade Benutzer aus Active Directory..."
SearchingFor = "Suche nach '{0}'..."
CheckingADSync = "Prüfe {0} Benutzer auf ADSync-Kompatibilität..."
ADSyncComplete = "ADSync-Prüfung abgeschlossen: {0}/{1} kompatibel"
ProxyAddressAdded = "ProxyAddress erfolgreich hinzugefügt"
ProxyAddressDeleted = "ProxyAddress erfolgreich gelöscht"
PrimarySMTPSet = "Primäre SMTP-Adresse erfolgreich gesetzt"
UserRefreshed = "Benutzer aktualisiert"
ExportComplete = "Export abgeschlossen: {0}"
FilterApplied = "Filter angewendet: {0} Benutzer"
HistoryLoaded = "History geladen für {0}"
StatisticsShown = "Statistik angezeigt"
ErrorOccurred = "Fehler: {0}"
# Dialog Titles
StatisticsTitle = "Statistik"
NoData = "Keine Daten"
NoDataMessage = "Keine Benutzer geladen. Bitte laden Sie zuerst Benutzer."
Close = "Schließen"
}
EN = @{
# Header
Title = "easyEXCH ProxyAddress Manager"
Subtitle = "Management of ProxyMailAddresses for MS365 ADSync"
# Buttons
Search = "🔍 Search"
LoadAll = "👥 Load All Users"
CheckADSync = "🔍 Check ADSync"
Export = "📤 Export CSV"
History = "📜 History"
Statistics = "📊 Statistics"
Add = "➕ Add"
Edit = "✏️ Edit"
Delete = "🗑️ Delete"
SetPrimary = "⭐ Set Primary"
Refresh = "🔄 Refresh"
# GroupBox Headers
CurrentProxyAddresses = "Current ProxyAddresses"
SearchUsers = "Search Users"
LoadUsers = "All Users"
FoundUsers = "Found Users"
# Labels
SearchLabel = "Search term (min. 3 characters - First name, Last name, Email, SAM):"
UserInfo = "User Information"
ValidationStatus = "Validation Status"
ValidationTitle = "⚠️ MS365 ADSync Validation"
Compatible = "✅ MS365 Compatible"
NotCompatible = "❌ Not compatible"
# DataGrid Columns - ProxyAddresses
ColType = "Type"
ColAddress = "Address"
ColPrimary = "Primary"
ColStatus = "Status"
# DataGrid Columns - Users
ColGivenName = "First Name"
ColSurname = "Last Name"
ColDisplayName = "Display Name"
ColPrimarySMTP = "Primary SMTP"
# Tooltips
TooltipAdd = "Add"
TooltipEdit = "Edit"
TooltipDelete = "Delete"
TooltipSetPrimary = "Set as Primary"
TooltipRefresh = "Refresh"
TooltipGerman = "Deutsch"
TooltipEnglish = "English"
TooltipADSync = "Checks if all loaded users are ADSync compatible"
TooltipSearch = "Automatic search from 3 characters"
# Filter
FilterAll = "🔍 Show All"
FilterValid = "✅ Compatible Only"
FilterWarnings = "⚠️ With Warnings"
FilterErrors = "❌ With Errors"
# Messages
NoUsersLoaded = "No users loaded.`nPlease search or load all."
NoUsersFound = "No users found for '{0}'.`nPlease change your search term."
NoUserSelected = "No user selected.`nPlease select a user from the list."
MinChars = "Enter at least 3 characters..."
Ready = "Ready"
# Status
UsersLoaded = "{0} users loaded"
UsersFoundCount = "{0} users found"
# Dynamic Messages
LoadingUsers = "Loading users from Active Directory..."
SearchingFor = "Searching for '{0}'..."
CheckingADSync = "Checking {0} users for ADSync compatibility..."
ADSyncComplete = "ADSync check complete: {0}/{1} compatible"
ProxyAddressAdded = "ProxyAddress successfully added"
ProxyAddressDeleted = "ProxyAddress successfully deleted"
PrimarySMTPSet = "Primary SMTP address successfully set"
UserRefreshed = "User refreshed"
ExportComplete = "Export complete: {0}"
FilterApplied = "Filter applied: {0} users"
HistoryLoaded = "History loaded for {0}"
StatisticsShown = "Statistics displayed"
ErrorOccurred = "Error: {0}"
# Dialog Titles
StatisticsTitle = "Statistics"
NoData = "No Data"
NoDataMessage = "No users loaded. Please load users first."
Close = "Close"
}
}
# Funktion zum Abrufen eines übersetzten Strings
function Get-LocalizedString {
param(
[string]$Key,
$Args # Nicht typisiert, damit es flexibel ist
)
try {
$text = $script:LanguageStrings[$script:CurrentLanguage][$Key]
if ($null -eq $text) {
Write-Log -Message "Übersetzung nicht gefunden für Key: $Key" -Level WARNING -Source "Language"
return $Key
}
# Wenn keine Args übergeben wurden, Text direkt zurückgeben
if ($null -eq $Args) {
return $text
}
# Args in Array konvertieren wenn nötig
$argsArray = if ($Args -is [Array]) { $Args } else { @($Args) }
# String formatieren
try {
return $text -f $argsArray
} catch {
Write-Log -Message "Fehler beim Formatieren von '$Key': $($_.Exception.Message)" -Level ERROR -Source "Language"
return $text
}
} catch {
Write-Log -Message "Fehler in Get-LocalizedString für Key '$Key': $($_.Exception.Message)" -Level ERROR -Source "Language"
return $Key
}
}
# Funktion zum Umschalten der Sprache
function Switch-Language {
param([string]$Language)
$script:CurrentLanguage = $Language
# UI-Texte aktualisieren
Update-UILanguage
# Button-Status aktualisieren
if ($Language -eq "DE") {
$btnLangDE.Background = "#28A745"
$btnLangEN.Background = "#6C757D"
} else {
$btnLangDE.Background = "#6C757D"
$btnLangEN.Background = "#28A745"
}
Write-Log -Message "Sprache gewechselt zu: $Language" -Level INFO -Source "Language"
}
# Funktion zum Aktualisieren der UI-Texte
function Update-UILanguage {
# Header
$txtTitle.Text = Get-LocalizedString "Title"
$txtSubtitle.Text = Get-LocalizedString "Subtitle"
# GroupBox Headers
$grpProxyAddresses.Header = Get-LocalizedString "CurrentProxyAddresses"
$grpSearchUsers.Header = Get-LocalizedString "SearchUsers"
$grpLoadUsers.Header = Get-LocalizedString "LoadUsers"
$grpFoundUsers.Header = Get-LocalizedString "FoundUsers"
# Labels
$lblSearchTerm.Text = Get-LocalizedString "SearchLabel"
$lblValidationTitle.Text = Get-LocalizedString "ValidationTitle"
# Messages
$txtNoProxyData.Text = Get-LocalizedString "NoUserSelected"
if ($txtNoUsers.Visibility -eq 'Visible') {
$txtNoUsers.Text = Get-LocalizedString "NoUsersLoaded"
}
# Buttons
$btnSearch.Content = Get-LocalizedString "Search"
$btnLoadAll.Content = Get-LocalizedString "LoadAll"
$btnCheckADSync.Content = Get-LocalizedString "CheckADSync"
$btnExport.Content = Get-LocalizedString "Export"
$btnHistory.Content = Get-LocalizedString "History"
$btnStatistics.Content = Get-LocalizedString "Statistics"
$btnAddProxy.Content = Get-LocalizedString "Add"
$btnEditProxy.Content = Get-LocalizedString "Edit"
$btnDeleteProxy.Content = Get-LocalizedString "Delete"
$btnSetPrimary.Content = Get-LocalizedString "SetPrimary"
$btnRefresh.Content = Get-LocalizedString "Refresh"
# Tooltips
$btnAddProxy.ToolTip = Get-LocalizedString "TooltipAdd"
$btnEditProxy.ToolTip = Get-LocalizedString "TooltipEdit"
$btnDeleteProxy.ToolTip = Get-LocalizedString "TooltipDelete"
$btnSetPrimary.ToolTip = Get-LocalizedString "TooltipSetPrimary"
$btnRefresh.ToolTip = Get-LocalizedString "TooltipRefresh"
$btnLangDE.ToolTip = Get-LocalizedString "TooltipGerman"
$btnLangEN.ToolTip = Get-LocalizedString "TooltipEnglish"
$btnCheckADSync.ToolTip = Get-LocalizedString "TooltipADSync"
$txtSearch.ToolTip = Get-LocalizedString "TooltipSearch"
# DataGrid Columns - ProxyAddresses
$dgProxyAddresses.Columns[0].Header = Get-LocalizedString "ColType"
$dgProxyAddresses.Columns[1].Header = Get-LocalizedString "ColAddress"
$dgProxyAddresses.Columns[2].Header = Get-LocalizedString "ColPrimary"
$dgProxyAddresses.Columns[3].Header = Get-LocalizedString "ColStatus"
# DataGrid Columns - Users
$dgUsers.Columns[0].Header = Get-LocalizedString "ColGivenName"
$dgUsers.Columns[1].Header = Get-LocalizedString "ColSurname"
$dgUsers.Columns[2].Header = Get-LocalizedString "ColDisplayName"
$dgUsers.Columns[3].Header = Get-LocalizedString "ColPrimarySMTP"
# Filter
$cmbFilter.Items[0].Content = Get-LocalizedString "FilterAll"
$cmbFilter.Items[1].Content = Get-LocalizedString "FilterValid"
$cmbFilter.Items[2].Content = Get-LocalizedString "FilterWarnings"
$cmbFilter.Items[3].Content = Get-LocalizedString "FilterErrors"
# Status
if ($txtStatus.Text -eq "Bereit" -or $txtStatus.Text -eq "Ready") {
$txtStatus.Text = Get-LocalizedString "Ready"
}
}
#endregion Language Resources
#region Functions
# PS2EXE-kompatible Pfad-Erkennung
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$script:ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
} else {
$script:ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
if (!$script:ScriptPath) { $script:ScriptPath = "." }
}
# Globale Variablen
$script:CurrentUser = $null
$script:AllUsers = @()
$script:MS365Domains = @()
$script:FilteredUsers = @()
$script:CurrentFilter = "Alle"
$script:ExportFolder = Join-Path $script:ScriptPath "Exports"
$script:HistoryFolder = Join-Path $script:ScriptPath "History"
# Logging-Konfiguration
$script:CurrentExecutingUser = $env:USERNAME
$script:CurrentDate = Get-Date -Format "yyyy-MM-dd"
$script:LogRootFolder = Join-Path $script:ScriptPath "Logs"
$script:UserLogFolder = Join-Path $script:LogRootFolder $script:CurrentExecutingUser
$script:LogFile = Join-Path $script:UserLogFolder "$($script:CurrentExecutingUser)_$($script:CurrentDate).log"
$script:DebugLogFile = Join-Path $script:UserLogFolder "DEBUG_$($script:CurrentExecutingUser)_$($script:CurrentDate).log"
$script:MaxLogAgeDays = 90
$script:EnableDebugLogging = $true
# Export- und History-Ordner initialisieren
function Initialize-ExportFolders {
try {
if (-not (Test-Path $script:ExportFolder)) {
New-Item -Path $script:ExportFolder -ItemType Directory -Force | Out-Null
}
if (-not (Test-Path $script:HistoryFolder)) {
New-Item -Path $script:HistoryFolder -ItemType Directory -Force | Out-Null
}
return $true
} catch {
return $false
}
}
# ProxyAddresses exportieren (automatisch vor Änderungen)
function Export-ProxyAddressHistory {
param(
[Parameter(Mandatory=$true)]
$User,
[string]$Action = "Backup"
)
try {
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$fileName = "$($User.SamAccountName)_$timestamp.csv"
$filePath = Join-Path $script:HistoryFolder $fileName
$exportData = @()
if ($User.ProxyAddresses) {
foreach ($proxy in $User.ProxyAddresses) {
$exportData += [PSCustomObject]@{
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Action = $Action
User = $User.SamAccountName
DisplayName = $User.DisplayName
ProxyAddress = $proxy
ExecutedBy = $env:USERNAME
}
}
}
$exportData | Export-Csv -Path $filePath -NoTypeInformation -Encoding UTF8
Write-Log -Message "History-Export erstellt: $fileName" -Level INFO -Source "Export"
return $filePath
} catch {
Write-Log -Message "Fehler beim History-Export: $($_.Exception.Message)" -Level ERROR -Source "Export"
return $null
}
}
# Statistik-Dashboard anzeigen
function Show-Statistics {
param(
[Parameter(Mandatory=$true)]
$Users
)
try {
Write-Log -Message "Erstelle Statistik-Dashboard" -Level INFO -Source "Statistics"
# Statistiken berechnen
$totalUsers = $Users.Count
$usersWithProxy = @($Users | Where-Object { $_.ProxyAddresses }).Count
$usersWithoutProxy = $totalUsers - $usersWithProxy
$validUsers = 0
$usersWithWarnings = 0
$usersWithErrors = 0
$totalProxyAddresses = 0
$primarySMTP = 0
$secondarySMTP = 0
$sipAddresses = 0
$x500Addresses = 0
foreach ($user in $Users) {
$validation = Test-UserMS365Compatibility -User $user
if ($validation.IsValid) {
$validUsers++
}
if ($validation.Warnings.Count -gt 0) {
$usersWithWarnings++
}
if ($validation.Issues.Count -gt 0) {
$usersWithErrors++
}
if ($user.ProxyAddresses) {
$totalProxyAddresses += $user.ProxyAddresses.Count
$primarySMTP += @($user.ProxyAddresses | Where-Object { $_ -cmatch '^SMTP:' }).Count
$secondarySMTP += @($user.ProxyAddresses | Where-Object { $_ -cmatch '^smtp:' }).Count
$sipAddresses += @($user.ProxyAddresses | Where-Object { $_ -match '^SIP:' }).Count
$x500Addresses += @($user.ProxyAddresses | Where-Object { $_ -match '^X500:' }).Count
}
}
# Statistik-Fenster
$statsWindow = New-Object System.Windows.Window
$statsWindow.Title = Get-LocalizedString "StatisticsTitle"
$statsWindow.Width = 700
$statsWindow.Height = 600
$statsWindow.WindowStartupLocation = 'CenterOwner'
$statsWindow.Owner = $window
$grid = New-Object System.Windows.Controls.Grid
$grid.Margin = "20"
$scrollViewer = New-Object System.Windows.Controls.ScrollViewer
$scrollViewer.VerticalScrollBarVisibility = "Auto"
$stackPanel = New-Object System.Windows.Controls.StackPanel
# Titel
$title = New-Object System.Windows.Controls.TextBlock
$title.Text = "📊 Statistik-Dashboard"
$title.FontSize = 24
$title.FontWeight = "Bold"
$title.Margin = "0,0,0,20"
$stackPanel.Children.Add($title)
# Benutzer-Statistiken
$userStats = New-Object System.Windows.Controls.TextBlock
$userStats.Text = @"
👥 BENUTZER-STATISTIKEN
═══════════════════════════════════════
Gesamt: $totalUsers
Mit ProxyAddresses: $usersWithProxy
Ohne ProxyAddresses: $usersWithoutProxy
✅ MS365-Kompatibel: $validUsers
⚠️ Mit Warnungen: $usersWithWarnings
❌ Mit Fehlern: $usersWithErrors
"@
$userStats.FontFamily = "Consolas"
$userStats.FontSize = 12
$userStats.Background = "#F0F0F0"
$userStats.Padding = "15"
$userStats.Margin = "0,0,0,20"
$stackPanel.Children.Add($userStats)
# ProxyAddress-Statistiken
$proxyStats = New-Object System.Windows.Controls.TextBlock
$proxyStats.Text = @"
📧 PROXYADDRESS-STATISTIKEN
═══════════════════════════════════════
Gesamt ProxyAddresses: $totalProxyAddresses
Durchschnitt pro Benutzer: $([math]::Round($totalProxyAddresses / $totalUsers, 2))
SMTP: (Primär): $primarySMTP
smtp: (Sekundär): $secondarySMTP
SIP: $sipAddresses
X500: $x500Addresses
"@
$proxyStats.FontFamily = "Consolas"
$proxyStats.FontSize = 12
$proxyStats.Background = "#F0F0F0"
$proxyStats.Padding = "15"
$proxyStats.Margin = "0,0,0,20"
$stackPanel.Children.Add($proxyStats)
# Prozentuale Verteilung
$percentValid = if ($totalUsers -gt 0) { [math]::Round(($validUsers / $totalUsers) * 100, 1) } else { 0 }
$percentWarnings = if ($totalUsers -gt 0) { [math]::Round(($usersWithWarnings / $totalUsers) * 100, 1) } else { 0 }
$percentErrors = if ($totalUsers -gt 0) { [math]::Round(($usersWithErrors / $totalUsers) * 100, 1) } else { 0 }
$distribution = New-Object System.Windows.Controls.TextBlock
$distribution.Text = @"
📈 VERTEILUNG
═══════════════════════════════════════
Kompatibel: $percentValid%
Warnungen: $percentWarnings%
Fehler: $percentErrors%
"@
$distribution.FontFamily = "Consolas"
$distribution.FontSize = 12
$distribution.Background = "#F0F0F0"
$distribution.Padding = "15"
$stackPanel.Children.Add($distribution)
$scrollViewer.Content = $stackPanel
$grid.Children.Add($scrollViewer)
$statsWindow.Content = $grid
Write-Log -Message "Statistik-Dashboard angezeigt" -Level INFO -Source "Statistics"
[void]$statsWindow.ShowDialog()
} catch {
Write-Log -Message "Fehler beim Erstellen der Statistik: $($_.Exception.Message)" -Level ERROR -Source "Statistics"
[System.Windows.MessageBox]::Show(
"Fehler beim Erstellen der Statistik:`n`n$($_.Exception.Message)",
"Statistik-Fehler",
[System.Windows.MessageBoxButton]::OK,
[System.Windows.MessageBoxImage]::Error
)
}
}
# History für Benutzer anzeigen
function Show-UserHistory {
param(
[Parameter(Mandatory=$true)]
$User
)
try {
Write-Log -Message "Lade History für $($User.SamAccountName)" -Level INFO -Source "History"
# History-Dateien für diesen Benutzer suchen
$historyFiles = @(Get-ChildItem -Path $script:HistoryFolder -Filter "$($User.SamAccountName)_*.csv" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending)
if ($historyFiles.Count -eq 0) {
[System.Windows.MessageBox]::Show(
"Keine History-Einträge für $($User.DisplayName) gefunden.",
"Keine History",
[System.Windows.MessageBoxButton]::OK,
[System.Windows.MessageBoxImage]::Information
)
return
}
# History-Fenster
$historyWindow = New-Object System.Windows.Window
$historyWindow.Title = "History - $($User.DisplayName)"
$historyWindow.Width = 900
$historyWindow.Height = 600
$historyWindow.WindowStartupLocation = 'CenterOwner'
$historyWindow.Owner = $window
$grid = New-Object System.Windows.Controls.Grid
$grid.Margin = "10"
$row1 = New-Object System.Windows.Controls.RowDefinition
$row1.Height = "Auto"
$row2 = New-Object System.Windows.Controls.RowDefinition
$row2.Height = "*"
$row3 = New-Object System.Windows.Controls.RowDefinition
$row3.Height = "Auto"
$grid.RowDefinitions.Add($row1)
$grid.RowDefinitions.Add($row2)
$grid.RowDefinitions.Add($row3)
# Header
$header = New-Object System.Windows.Controls.TextBlock
$header.Text = "📜 Änderungsverlauf für $($User.DisplayName) ($($User.SamAccountName))`n$($historyFiles.Count) History-Einträge gefunden"
$header.FontSize = 14
$header.FontWeight = "Bold"
$header.Margin = "0,0,0,10"
[System.Windows.Controls.Grid]::SetRow($header, 0)
$grid.Children.Add($header)
# Alle History-Einträge laden und kombinieren
$allHistory = @()
foreach ($file in $historyFiles) {
$entries = Import-Csv -Path $file.FullName -Encoding UTF8
$allHistory += $entries
}
# DataGrid
$dgHistory = New-Object System.Windows.Controls.DataGrid
$dgHistory.AutoGenerateColumns = $false
$dgHistory.IsReadOnly = $true
$dgHistory.AlternatingRowBackground = "LightGray"
$dgHistory.GridLinesVisibility = "All"
$dgHistory.CanUserSortColumns = $true
$col1 = New-Object System.Windows.Controls.DataGridTextColumn
$col1.Header = "Zeitpunkt"
$col1.Binding = New-Object System.Windows.Data.Binding("Timestamp")
$col1.Width = 150
$dgHistory.Columns.Add($col1)
$col2 = New-Object System.Windows.Controls.DataGridTextColumn
$col2.Header = "Aktion"
$col2.Binding = New-Object System.Windows.Data.Binding("Action")
$col2.Width = 150
$dgHistory.Columns.Add($col2)
$col3 = New-Object System.Windows.Controls.DataGridTextColumn
$col3.Header = "ProxyAddress"
$col3.Binding = New-Object System.Windows.Data.Binding("ProxyAddress")
$col3.Width = "*"
$dgHistory.Columns.Add($col3)
$col4 = New-Object System.Windows.Controls.DataGridTextColumn
$col4.Header = "Ausgeführt von"
$col4.Binding = New-Object System.Windows.Data.Binding("ExecutedBy")
$col4.Width = 120
$dgHistory.Columns.Add($col4)
$dgHistory.ItemsSource = $allHistory
[System.Windows.Controls.Grid]::SetRow($dgHistory, 1)
$grid.Children.Add($dgHistory)
# Schließen-Button
$btnClose = New-Object System.Windows.Controls.Button
$btnClose.Content = "Schließen"
$btnClose.Width = 100
$btnClose.Height = 30
$btnClose.Margin = "0,10,0,0"
$btnClose.HorizontalAlignment = "Right"
$btnClose.Add_Click({ $historyWindow.Close() })
[System.Windows.Controls.Grid]::SetRow($btnClose, 2)
$grid.Children.Add($btnClose)
$historyWindow.Content = $grid
Write-Log -Message "History angezeigt: $($allHistory.Count) Einträge" -Level INFO -Source "History"
[void]$historyWindow.ShowDialog()
} catch {
Write-Log -Message "Fehler beim Laden der History: $($_.Exception.Message)" -Level ERROR -Source "History"
[System.Windows.MessageBox]::Show(
"Fehler beim Laden der History:`n`n$($_.Exception.Message)",
"History-Fehler",
[System.Windows.MessageBoxButton]::OK,
[System.Windows.MessageBoxImage]::Error
)
}
}
# Alle ProxyAddresses exportieren
function Export-AllProxyAddresses {
param(
[Parameter(Mandatory=$true)]
$Users
)
try {
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$fileName = "ProxyAddresses_Export_$timestamp.csv"
$filePath = Join-Path $script:ExportFolder $fileName
$exportData = @()
foreach ($user in $Users) {
if ($user.ProxyAddresses) {
foreach ($proxy in $user.ProxyAddresses) {
$exportData += [PSCustomObject]@{
DisplayName = $user.DisplayName
SamAccountName = $user.SamAccountName
Mail = $user.Mail
ProxyAddress = $proxy
Type = if ($proxy -match '^([A-Za-z0-9]+):') { $matches[1] } else { "Unknown" }
IsPrimary = if ($proxy -cmatch '^[A-Z]+:') { "Ja" } else { "Nein" }
}
}
}
}
$exportData | Export-Csv -Path $filePath -NoTypeInformation -Encoding UTF8
Write-Log -Message "Export erstellt: $fileName ($($exportData.Count) Einträge)" -Level INFO -Source "Export"
[System.Windows.MessageBox]::Show(
"Export erfolgreich erstellt:`n`n$filePath`n`n$($exportData.Count) ProxyAddresses exportiert",
"Export erfolgreich",
[System.Windows.MessageBoxButton]::OK,
[System.Windows.MessageBoxImage]::Information
)
return $filePath
} catch {
Write-Log -Message "Fehler beim Export: $($_.Exception.Message)" -Level ERROR -Source "Export"
[System.Windows.MessageBox]::Show(
"Fehler beim Export:`n`n$($_.Exception.Message)",
"Export-Fehler",
[System.Windows.MessageBoxButton]::OK,
[System.Windows.MessageBoxImage]::Error
)
return $null
}
}
# Log-Ordner initialisieren
function Initialize-LogFolder {