-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.axaml
More file actions
325 lines (305 loc) · 19.6 KB
/
Copy pathMainWindow.axaml
File metadata and controls
325 lines (305 loc) · 19.6 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
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PowerShell_Automation_Sample.MainWindow"
Title="PowerShell Automation Sample"
Width="1200"
Height="1000">
<Grid RowDefinitions="*,5,*">
<!-- Top Section: Tabbed Content -->
<Grid Grid.Row="0">
<TabControl>
<TabItem Header="Script Editor">
<Grid RowDefinitions="*,Auto">
<!-- Script Editor -->
<TextBox x:Name="ScriptEditor"
Grid.Row="0"
AcceptsReturn="True"
AcceptsTab="True"
TextWrapping="NoWrap"
FontFamily="Consolas"
FontSize="12"
Watermark="Enter PowerShell script here..."
Padding="10"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"/>
<!-- Script Actions -->
<DockPanel Grid.Row="1"
Margin="10"
LastChildFill="False">
<StackPanel DockPanel.Dock="Left"
Orientation="Horizontal"
Spacing="10">
<Button x:Name="ConnectRunspaceButton"
Content="Connect Runspace"
Click="ConnectRunspaceButton_Click"/>
<Button x:Name="RunScriptButton"
Content="Run Script"
Click="RunScriptButton_Click"/>
<Button x:Name="DisconnectRunspaceButton"
Content="Disconnect Runspace"
Click="DisconnectRunspaceButton_Click"/>
</StackPanel>
<StackPanel DockPanel.Dock="Right"
Orientation="Horizontal"
Spacing="6"
VerticalAlignment="Center">
<TextBlock Text="Runspace:" VerticalAlignment="Center"/>
<Border x:Name="RunspaceStatusIndicator"
Width="10" Height="10"
CornerRadius="5"
Background="Red"
VerticalAlignment="Center"/>
<TextBlock x:Name="RunspaceStatusText"
Text="Disconnected"
VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Grid>
</TabItem>
<TabItem Header="Configuration">
<ScrollViewer>
<StackPanel Margin="10" Spacing="15" x:CompileBindings="False">
<!-- Connect Runspaces -->
<StackPanel Spacing="4">
<!-- Section title plus the "Remember settings"
opt-in on the same row. The checkbox is
anchored to the right with DockPanel so it
sits flush against the right edge of the
Configuration content. -->
<DockPanel LastChildFill="False">
<TextBlock DockPanel.Dock="Left"
Text="Connect Runspaces"
FontWeight="Bold"
VerticalAlignment="Center"/>
<CheckBox x:Name="OutOfProcessRunspaceCheckBox"
DockPanel.Dock="Left"
Margin="10,0,0,0"
Content="Create out-of-process runspace"
VerticalAlignment="Center"
ToolTip.Tip="Creates the runspace out-of-process so the child pwsh.exe (and all module memory it allocates) is fully reclaimed when you disconnect. Useful as a workaround for modules with known memory leaks. Cmdlet results cross a process boundary so live .NET objects are returned as PSObject property bags. Interactive MSAL/WAM sign-in inside the child has no console to anchor to — prefer device code or certificate authentication."/>
<CheckBox x:Name="RememberSettingsCheckBox"
DockPanel.Dock="Right"
Content="Remember settings"
VerticalAlignment="Center"
Click="RememberSettingsCheckBox_Click"
ToolTip.Tip="When checked, the current Configuration tab values (including passwords) and the Script Editor contents are saved to an encrypted file next to the application on exit, and reloaded on next launch. The file is encrypted with Windows DPAPI (current user) so only your Windows account on this machine can read it. Unchecking this option deletes the saved file."/>
</DockPanel>
<TextBlock Text="Select one or more runspace sources. PowerShell URL and the online modules may be combined."
Foreground="Gray"
TextWrapping="Wrap"/>
<StackPanel Spacing="4">
<CheckBox x:Name="PowerShellUrlCheckBox"
Content="PowerShell URL"/>
<!-- PowerShell URL details: only meaningful while the URL checkbox is checked. -->
<StackPanel Margin="22,0,0,0"
Spacing="4"
IsVisible="{Binding #PowerShellUrlCheckBox.IsChecked}">
<Grid ColumnDefinitions="2*,10,*">
<StackPanel Grid.Column="0" Spacing="4">
<TextBlock Text="PowerShell URL" FontWeight="Bold"/>
<TextBox x:Name="PowerShellUrlTextBox"
Watermark="https://outlook.office365.com/powershell-liveid/"/>
</StackPanel>
<StackPanel Grid.Column="2" Spacing="4">
<TextBlock Text="Configuration Name" FontWeight="Bold"/>
<TextBox x:Name="ConfigurationNameTextBox"
Text="Microsoft.Exchange"
Watermark="Microsoft.Exchange"/>
</StackPanel>
</Grid>
</StackPanel>
<CheckBox x:Name="ExchangeOnlineModuleCheckBox"
Content="Exchange Online"
IsChecked="True"/>
<StackPanel Orientation="Horizontal" Spacing="0">
<CheckBox x:Name="SharePointOnlineModuleCheckBox"
Content="SharePoint Online"
VerticalAlignment="Center"
IsCheckedChanged="SharePointOnlineModuleCheckBox_IsCheckedChanged"/>
<TextBox x:Name="SharePointOnlineUrlTextBox"
Margin="6,0,0,0"
MinWidth="320"
VerticalAlignment="Center"
Watermark="https://contoso-admin.sharepoint.com"
IsVisible="{Binding #SharePointOnlineModuleCheckBox.IsChecked}"/>
</StackPanel>
<CheckBox x:Name="MicrosoftTeamsModuleCheckBox"
Content="Microsoft Teams"/>
<CheckBox x:Name="EntraIdModuleCheckBox"
Content="Entra ID"/>
<CheckBox x:Name="AzureInformationProtectionModuleCheckBox"
Content="Azure Information Protection"/>
</StackPanel>
</StackPanel>
<!-- Authentication Settings -->
<StackPanel Spacing="4">
<TextBlock Text="Authentication Settings" FontWeight="Bold"/>
<StackPanel Spacing="6">
<RadioButton x:Name="LoggedOnUserRadio"
GroupName="AuthMode"
Content="Logged on user's credentials"/>
<RadioButton x:Name="SpecifiedCredentialsRadio"
GroupName="AuthMode"
Content="Specified credentials"
IsChecked="True"/>
<StackPanel Margin="22,0,0,0"
Spacing="4"
IsVisible="{Binding #SpecifiedCredentialsRadio.IsChecked}">
<TextBlock Text="Username"/>
<TextBox x:Name="UsernameTextBox"/>
<TextBlock Text="Password"/>
<TextBox x:Name="PasswordTextBox" PasswordChar="*"/>
<CheckBox x:Name="ExchangeOnlineDeviceAuthCheckBox"
Content="Use device code authentication for Exchange Online (cross-platform)"
ToolTip.Tip="Adds -Device to Connect-ExchangeOnline. Sign-in code is shown in the Output tab. Recommended for Linux/macOS or any host without a WAM broker. Username/password above are ignored when this is selected."/>
</StackPanel>
<RadioButton x:Name="CertificateRadio"
GroupName="AuthMode"
Content="Certificate"/>
<StackPanel Margin="22,0,0,0"
Spacing="6"
IsVisible="{Binding #CertificateRadio.IsChecked}">
<TextBlock Text="Certificate Source"/>
<StackPanel Orientation="Horizontal" Spacing="10">
<RadioButton x:Name="CertStoreRadio"
GroupName="CertSource"
Content="Certificate Store"
IsChecked="True"/>
<RadioButton x:Name="CertFileRadio"
GroupName="CertSource"
Content="File System"/>
</StackPanel>
<!-- Certificate Store selection -->
<StackPanel Spacing="4"
IsVisible="{Binding #CertStoreRadio.IsChecked}">
<TextBlock Text="Select certificate from store"/>
<ComboBox x:Name="CertStoreComboBox"
PlaceholderText="No certificate selected"
HorizontalAlignment="Stretch">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Subject}"/>
<TextBlock Text="{Binding Thumbprint}"
FontSize="10"
Foreground="Gray"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button x:Name="RefreshCertStoreButton"
Content="Refresh"
Click="RefreshCertStoreButton_Click"/>
</StackPanel>
<!-- Certificate File selection -->
<StackPanel Spacing="4"
IsVisible="{Binding #CertFileRadio.IsChecked}">
<TextBlock Text="Select certificate file (.pfx, .cer)"/>
<StackPanel Orientation="Horizontal" Spacing="6">
<TextBox x:Name="CertFilePathTextBox"
Width="300"
Watermark="Path to certificate file"/>
<Button x:Name="BrowseCertFileButton"
Content="Browse..."
Click="BrowseCertFileButton_Click"/>
</StackPanel>
<TextBlock Text="Password (if required)"/>
<TextBox x:Name="CertFilePasswordTextBox" PasswordChar="*"/>
</StackPanel>
<!-- Certificate-auth parameters (apply to both Exchange Online and SharePoint Online). -->
<StackPanel Spacing="4">
<TextBlock Text="AppId (Azure AD application/client ID)"/>
<TextBox x:Name="AppIdTextBox"
Watermark="00000000-0000-0000-0000-000000000000"/>
<TextBlock Text="Organization (tenant)"/>
<TextBox x:Name="OrganizationTextBox"
Watermark="contoso.onmicrosoft.com"/>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</ScrollViewer>
</TabItem>
</TabControl>
<!-- Theme toggle overlaid in the TabControl's tab-strip row,
anchored to the top-right so it sits to the right of the
tabs at the same vertical level. -->
<ToggleSwitch x:Name="ThemeToggle"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,4,8,0"
OffContent="Light"
OnContent="Dark"
IsCheckedChanged="ThemeToggle_IsCheckedChanged"
ToolTip.Tip="Toggle between light and dark theme."/>
</Grid>
<!-- Splitter -->
<GridSplitter Grid.Row="1"
Background="Gray"
ResizeDirection="Rows"
HorizontalAlignment="Stretch"/>
<!-- Bottom Section: Logs with Tabs -->
<Grid Grid.Row="2">
<TabControl x:Name="LogTabControl">
<TabItem Header="Output">
<ScrollViewer>
<SelectableTextBlock x:Name="OutputLog"
Text=""
Padding="10"
TextWrapping="Wrap"
FontFamily="Consolas"/>
</ScrollViewer>
</TabItem>
<TabItem Header="Errors">
<ScrollViewer>
<SelectableTextBlock x:Name="ErrorsLog"
Text=""
Padding="10"
TextWrapping="Wrap"
FontFamily="Consolas"/>
</ScrollViewer>
</TabItem>
<TabItem Header="Verbose">
<ScrollViewer>
<SelectableTextBlock x:Name="VerboseLog"
Text=""
Padding="10"
TextWrapping="Wrap"
FontFamily="Consolas"/>
</ScrollViewer>
</TabItem>
<TabItem Header="Automation">
<ScrollViewer>
<SelectableTextBlock x:Name="AutomationLog"
Text=""
Padding="10"
TextWrapping="Wrap"
FontFamily="Consolas"/>
</ScrollViewer>
</TabItem>
</TabControl>
<!-- Log actions overlaid in the TabControl's tab-strip row,
anchored to the top-right. To Top / To Bottom scroll the
currently shown log; Clear empties it. -->
<StackPanel Orientation="Horizontal"
Spacing="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,4,8,0">
<Button x:Name="ScrollLogTopButton"
Content="To Top"
Click="ScrollLogTopButton_Click"/>
<Button x:Name="ScrollLogBottomButton"
Content="To Bottom"
Click="ScrollLogBottomButton_Click"/>
<Button x:Name="ClearLogButton"
Content="Clear"
Click="ClearLogButton_Click"/>
</StackPanel>
</Grid>
</Grid>
</Window>