1-
1+ # Requires -Version 5.1
2+
23# Requires -Version 5.1
34<#
45. SYNOPSIS
@@ -52,9 +53,9 @@ Add-Type -AssemblyName WindowsBase
5253 <Window.Resources>
5354 <Style x:Key="ConfirmBoxButton" TargetType="{x:Type Button}">
5455 <Setter Property="Background" Value="White" />
55- <Setter Property="FontSize" Value="14 " />
56- <Setter Property="Width" Value="95 "/>
57- <Setter Property="Height" Value="32 "/>
56+ <Setter Property="FontSize" Value="16 " />
57+ <Setter Property="Width" Value="80 "/>
58+ <Setter Property="Height" Value="50 "/>
5859 <Setter Property="BorderBrush" Value="Black"/>
5960 <Setter Property="BorderThickness" Value="2"/>
6061 <Setter Property="FontWeight" Value="Bold"/>
@@ -69,9 +70,18 @@ Add-Type -AssemblyName WindowsBase
6970 </ControlTemplate>
7071 </Setter.Value>
7172 </Setter>
73+ <Setter Property="Effect">
74+ <Setter.Value>
75+ <DropShadowEffect Color="Black"
76+ Opacity="0.3"
77+ BlurRadius="4"
78+ ShadowDepth="2"
79+ Direction="315"/>
80+ </Setter.Value>
81+ </Setter>
7282 <Style.Triggers>
7383 <Trigger Property="IsMouseOver" Value="True">
74- <Setter Property="Background" Value="#443E8DDD " />
84+ <Setter Property="Background" Value="#FFCAE3FC " />
7585 <Setter Property="BorderBrush" Value="Black" />
7686 <Setter Property="Foreground" Value="Black" />
7787 </Trigger>
@@ -82,6 +92,43 @@ Add-Type -AssemblyName WindowsBase
8292 </Trigger>
8393 </Style.Triggers>
8494 </Style>
95+ <!-- Styles pour les boutons -->
96+ <Style x:Key="ButtonStyle" TargetType="Button">
97+ <Setter Property="Margin" Value="5,0,0,0"/>
98+ <Setter Property="FontSize" Value="12"/>
99+ <Setter Property="Cursor" Value="Hand"/>
100+ <Setter Property="Background" Value="White"/>
101+ <Setter Property="Foreground" Value="Black"/>
102+ <Setter Property="BorderThickness" Value="1"/>
103+ <Setter Property="Template">
104+ <Setter.Value>
105+ <ControlTemplate TargetType="{x:Type Button}">
106+ <Border CornerRadius="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
107+ <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" />
108+ </Border>
109+ </ControlTemplate>
110+ </Setter.Value>
111+ </Setter>
112+ <Setter Property="Effect">
113+ <Setter.Value>
114+ <DropShadowEffect Color="Black"
115+ Opacity="0.3"
116+ BlurRadius="4"
117+ ShadowDepth="2"
118+ Direction="315"/>
119+ </Setter.Value>
120+ </Setter>
121+ <Style.Triggers>
122+ <Trigger Property="IsMouseOver" Value="True">
123+ <Setter Property="Background" Value="#FFCAE3FC" />
124+ <Setter Property="Foreground" Value="Black" />
125+ </Trigger>
126+ <Trigger Property="IsPressed" Value="True">
127+ <Setter Property="Background" Value="#FF3E8DDD" />
128+ <Setter Property="Foreground" Value="White" />
129+ </Trigger>
130+ </Style.Triggers>
131+ </Style>
85132 <!-- DataGrid style -->
86133 <Style x:Key="DataGridStyle1" TargetType="{x:Type DataGrid}">
87134 <Setter Property="Margin" Value="0"/>
@@ -106,37 +153,6 @@ Add-Type -AssemblyName WindowsBase
106153 <Setter Property="FontWeight" Value="Bold" />
107154 <Setter Property="HorizontalContentAlignment" Value="Left" />
108155 </Style>
109-
110- <!-- Styles pour les boutons -->
111- <Style x:Key="ButtonStyle" TargetType="Button">
112- <Setter Property="Padding" Value="15,8"/>
113- <Setter Property="Margin" Value="5"/>
114- <Setter Property="FontSize" Value="14"/>
115- <Setter Property="Cursor" Value="Hand"/>
116- <Setter Property="Background" Value="#0078D4"/>
117- <Setter Property="Foreground" Value="White"/>
118- <Setter Property="BorderThickness" Value="0"/>
119- <Style.Triggers>
120- <Trigger Property="IsMouseOver" Value="True">
121- <Setter Property="Background" Value="#005A9E"/>
122- </Trigger>
123- </Style.Triggers>
124- </Style>
125- <!-- Style pour le bouton Fermer -->
126- <Style x:Key="CloseButtonStyle" TargetType="Button">
127- <Setter Property="Padding" Value="15,8"/>
128- <Setter Property="Margin" Value="5"/>
129- <Setter Property="FontSize" Value="14"/>
130- <Setter Property="Cursor" Value="Hand"/>
131- <Setter Property="Background" Value="#6C757D"/>
132- <Setter Property="Foreground" Value="White"/>
133- <Setter Property="BorderThickness" Value="0"/>
134- <Style.Triggers>
135- <Trigger Property="IsMouseOver" Value="True">
136- <Setter Property="Background" Value="#5A6268"/>
137- </Trigger>
138- </Style.Triggers>
139- </Style>
140156 <!-- Style pour les TextBox -->
141157 <Style x:Key="TextBoxStyle" TargetType="TextBox">
142158 <Setter Property="Padding" Value="5"/>
@@ -156,7 +172,7 @@ Add-Type -AssemblyName WindowsBase
156172 </Grid.RowDefinitions>
157173
158174 <!-- Info - Model - Buttons -->
159- <StackPanel Grid.Row="0" HorizontalAlignment="Left" Margin="10,10,0,0" >
175+ <WrapPanel Grid.Row="0" HorizontalAlignment="Left" Margin="10,10,0,0" Orientation="Horizontal" >
160176 <Border BorderThickness="1" BorderBrush="Gray" Background="#66D0D0D0" CornerRadius="5">
161177 <WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" Width="240" Margin="5,2,0,0" >
162178 <TextBox x:Name="WinVer" FontWeight="SemiBold" Margin="0,0,0,3" Text="Windows 11 Pro 24H2"
@@ -173,10 +189,7 @@ Add-Type -AssemblyName WindowsBase
173189 <TextBlock x:Name="tbSecureBoot" FontSize="14" Margin="0,-4,0,0" Width="30" />
174190 </WrapPanel>
175191 </Border>
176- </StackPanel>
177- <StackPanel Grid.Row="0" HorizontalAlignment="Left" Margin="270,10,0,0" >
178- <Border BorderThickness="1" BorderBrush="Gray" Background="#66D0D0D0" CornerRadius="5">
179-
192+ <Border BorderThickness="1" BorderBrush="Gray" Background="#66D0D0D0" CornerRadius="5" Margin="10,0,0,0">
180193 <Grid Margin="5,0,0,4.5">
181194 <Grid.ColumnDefinitions>
182195 <ColumnDefinition Width="70"/>
@@ -212,15 +225,14 @@ Add-Type -AssemblyName WindowsBase
212225
213226 </Grid>
214227 </Border>
215- </StackPanel>
216- <StackPanel Grid.Row="0"
217- Orientation="Horizontal"
218- HorizontalAlignment="Right">
219- <Button x:Name="btnExecute" Content="Check" FontWeight="SemiBold"
220- Style="{StaticResource ConfirmBoxButton}" Margin="0,5,30,5" />
221- <Button x:Name="btnClose" Content="Close"
222- Style="{StaticResource ConfirmBoxButton}" Margin="0,5,66,5"/>
223- </StackPanel>
228+ <Button x:Name="btnExecute" Content="Check" Style="{StaticResource ConfirmBoxButton}" Margin="15,0,0,0" />
229+ <WrapPanel Orientation="Vertical" Width="190" Margin="20,0,00,0">
230+ <Button x:Name="Set_Reg_0x5944" Content="SET AvailableUpdates to 0x5944" Margin="0,0,0,3" Width="190" Height="18" FontWeight="SemiBold" Style="{StaticResource ButtonStyle}" />
231+ <Button x:Name="Start_Task" Content="Start "Secure-Boot-Update" Task" Margin="0,0,0,3" Width="190" Height="18" FontWeight="SemiBold" Style="{StaticResource ButtonStyle}" />
232+ <Button x:Name="Log_CSV" Content="Create/Append logs to CSV" Margin="0,0,0,0" Width="190" Height="18" FontWeight="SemiBold" Style="{StaticResource ButtonStyle}" />
233+ </WrapPanel>
234+ </WrapPanel>
235+
224236
225237
226238
@@ -365,29 +377,72 @@ Add-Type -AssemblyName WindowsBase
365377 <TextBlock x:Name="Event_Icon" Text="" FontSize="12" FontWeight="SemiBold" Width="30" Foreground="#FF324873" Margin="0,0,0,0" TextAlignment="Center"/>
366378 <TextBlock x:Name="Event_Message" Text="Message" FontSize="12" FontWeight="SemiBold" Width="500" Foreground="#FF324873" TextAlignment="Left" />
367379 </WrapPanel>
368- <WrapPanel Orientation="Horizontal" Margin="10,0,0,0" Width="727" x:Name="WrapPanel_ErrorEvent" Visibility="Visible ">
380+ <WrapPanel Orientation="Horizontal" Margin="10,0,0,0" Width="727" x:Name="WrapPanel_ErrorEvent" Visibility="Collapsed ">
369381 <TextBlock x:Name="Error_Num" Text="" FontSize="12" FontWeight="SemiBold" Width="60" Foreground="Black" Margin="0,0,0,0" TextAlignment="Center"/>
370382 <TextBlock x:Name="Error_Status" Text="" FontSize="12" FontWeight="SemiBold" Width="50" Foreground="Black" Margin="0,0,0,0" TextAlignment="Right"/>
371383 <TextBlock x:Name="Error_Icon" Text="" FontSize="12" FontWeight="SemiBold" Width="30" Foreground="Black" Margin="0,0,0,0" TextAlignment="Center"/>
372384 <TextBlock x:Name="Error_Message" Text="" FontSize="11" FontWeight="Normal" Width="578" Foreground="Black" TextAlignment="Left" TextWrapping="Wrap" />
373385 </WrapPanel>
374- <WrapPanel Orientation="Horizontal" Margin="10,0,0,0" Width="727" >
375- <TextBlock x:Name="_1808_Num" Text="1808" FontSize="12" FontWeight="SemiBold" Width="60" Foreground="Black" Margin="0,0,0,0" TextAlignment="Center"/>
376- <TextBlock x:Name="_1808_Status" Text="" FontSize="12" FontWeight="SemiBold" Width="50" Foreground="Black" Margin="0,0,0,0" TextAlignment="Right"/>
377- <TextBlock x:Name="_1808_Icon" Text="" FontSize="12" FontWeight="SemiBold" Width="30" Foreground="Black" Margin="0,0,0,0" TextAlignment="Center"/>
378- <TextBlock x:Name="_1808_Message" Text="" FontSize="12" FontWeight="SemiBold" Width="578" Foreground="Black" TextAlignment="Left" TextWrapping="Wrap" />
386+ <WrapPanel Orientation="Horizontal" Margin="10,0,0,0" Width="727" >
387+ <TextBlock x:Name="_1808_Num" Text="1808" FontSize="12" FontWeight="SemiBold" Width="60" Foreground="Black" Margin="0,0,0,0" TextAlignment="Center"/>
388+ <TextBlock x:Name="_1808_Status" Text="??? " FontSize="12" FontWeight="SemiBold" Width="50" Foreground="Black" Margin="0,0,0,0" TextAlignment="Right"/>
389+ <TextBlock x:Name="_1808_Icon" Text="" FontSize="12" FontWeight="SemiBold" Width="30" Foreground="Black" Margin="0,0,0,0" TextAlignment="Center"/>
390+ <TextBlock x:Name="_1808_Message" Text="" FontSize="12" FontWeight="SemiBold" Width="578" Foreground="Black" TextAlignment="Left" TextWrapping="Wrap" />
379391 </WrapPanel>
380392 </WrapPanel>
381-
393+
382394 <!-- Barre de statut -->
383- <Border Grid.Row="4" x:Name="BorderStatus" Width="600" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,10,0,17" Height="40"
384- Background="#F0F0F0" CornerRadius="10" BorderBrush="#FF324873" BorderThickness="1.5" >
385- <StackPanel Orientation="Horizontal">
386- <TextBlock Text="Info :" FontWeight="Bold" FontSize="20" Margin="10,0,10,0" Padding="0,5,0,0" />
387- <TextBlock x:Name="TxtStatus" Text="" Foreground="#FF324873" FontSize="20"
388- FontWeight="Bold" Padding="10,5,0,0" Margin="0,0,0,0" Width="509" />
395+
396+ <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Left" Width="820">
397+
398+ <Border x:Name="BorderStatus" Width="500" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,10,0,17" Height="40"
399+ Background="#F0F0F0" CornerRadius="10" BorderBrush="#FF324873" BorderThickness="1.5" >
400+ <StackPanel Orientation="Horizontal">
401+ <TextBlock Text="Info :" FontWeight="Bold" FontSize="20" Margin="10,0,10,0" Padding="0,5,0,0" />
402+ <TextBlock x:Name="TxtStatus" Text="Data retrieval completed successfully" Foreground="#FF324873" FontSize="20"
403+ FontWeight="Bold" Padding="0,5,0,0" Margin="0,0,0,0" Width="400" />
404+ </StackPanel>
405+ </Border>
406+
407+ <StackPanel x:Name="Cmd_Button" Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Bottom" Margin="60,0,0,10" Background="Transparent" >
408+ <Border Background="#1A2B4A" Width="225" Height="55" Margin="0,0,0,0" CornerRadius="8" >
409+ <Canvas Width="220" Height="55">
410+
411+ <!-- Shield -->
412+ <Path Data="M25,6 L43,12 L43,26 C43,36 35,44 25,48 C15,44 7,36 7,26 L7,12 Z"
413+ Fill="#2E86DE" Stroke="#5BA3F5" StrokeThickness="3"/>
414+
415+ <!-- Checkmark -->
416+ <Polyline Points="24,21 34,32 50,15"
417+ Fill="Transparent" Stroke="#01D210" StrokeThickness="6"
418+ StrokeStartLineCap="Round" StrokeEndLineCap="Round"
419+ StrokeLineJoin="Round"/>
420+
421+ <!-- Check -->
422+ <TextBlock Canvas.Left="60" Canvas.Top="1"
423+ Text="Check" FontFamily="Segoe UI" FontSize="20"
424+ FontWeight="Bold" Foreground="White"/>
425+ <!-- CA -->
426+ <TextBlock Canvas.Left="119" Canvas.Top="1"
427+ Text="CA" FontFamily="Segoe UI" FontSize="20"
428+ FontWeight="Bold" Foreground="#2E86DE"/>
429+ <!-- 2023 -->
430+ <TextBlock Canvas.Left="146" Canvas.Top="1"
431+ Text="2023" FontFamily="Segoe UI" FontSize="20"
432+ FontWeight="Bold" Foreground="#5BA3F5"/>
433+ <!-- Subtitle -->
434+ <TextBlock Canvas.Left="61" Canvas.Top="26"
435+ Text="UEFI Certificate Monitor" FontFamily="Segoe UI"
436+ FontSize="9" Foreground="#8AAFD4"/>
437+ <!-- Version -->
438+ <TextBlock Canvas.Left="61" Canvas.Top="38"
439+ Text="Version : 1.1.0" FontFamily="Segoe UI"
440+ FontSize="10" FontWeight="Bold" Foreground="#8AAFD4"/>
441+ </Canvas>
442+ </Border>
443+
389444 </StackPanel>
390- </Border >
445+ </StackPanel >
391446 </Grid>
392447</Window>
393448
@@ -420,7 +475,9 @@ function Get-XamlControl {
420475
421476# region Retrieve required controls
422477$btnExecute = Get-XamlControl - Name " btnExecute"
423- $btnClose = Get-XamlControl - Name " btnClose"
478+ $Set_Reg_0x5944 = Get-XamlControl - Name " Set_Reg_0x5944"
479+ $Start_Task = Get-XamlControl - Name " Start_Task"
480+ $Log_CSV = Get-XamlControl - Name " Log_CSV"
424481
425482$PK_Grid = Get-XamlControl - Name " PK_Grid"
426483$PKDefault_Grid = Get-XamlControl - Name " PKDefault_Grid"
@@ -1071,10 +1128,70 @@ if ($btnExecute) {
10711128 })
10721129}
10731130
1074- # Close button
1075- if ($btnClose ) {
1076- $btnClose.Add_Click ({
1077- $window.Close ()
1131+ # Set AvailableUpdates to 0x5944
1132+ if ($Set_Reg_0x5944 ) {
1133+ $Set_Reg_0x5944.Add_Click ({
1134+ try {
1135+ Set-ItemProperty - Path " HKLM:\SYSTEM\CurrentControlSet\Control\SecureBoot" `
1136+ - Name " AvailableUpdates" `
1137+ - Value 0x5944 `
1138+ - Type DWord - Force
1139+ Update-StatusLabel - Message " AvailableUpdates set to 0x5944" - Color " Green"
1140+ }
1141+ catch {
1142+ Update-StatusLabel - Message " Error setting AvailableUpdates : $_ " - Color " Red"
1143+ }
1144+ })
1145+ }
1146+
1147+ # Start Task "\Microsoft\Windows\PI\Secure-Boot-Update"
1148+ if ($Start_Task ) {
1149+ $Start_Task.Add_Click ({
1150+ try {
1151+ Start-ScheduledTask - TaskName " \Microsoft\Windows\PI\Secure-Boot-Update"
1152+ Update-StatusLabel - Message " Task started successfully" - Color " Green"
1153+ }
1154+ catch {
1155+ Update-StatusLabel - Message " Error starting task : $_ " - Color " Red"
1156+ }
1157+ })
1158+ }
1159+
1160+ # Create or Append log in CSV format with current data (one line per click)
1161+ if ($Log_CSV ) {
1162+ $Log_CSV.Add_Click ({
1163+ try {
1164+ $csvPath = Join-Path - Path $PSScriptRoot - ChildPath " Log_CheckCA2023.csv"
1165+
1166+ # Nettoyer SystemFamily : supprimer "Think" si présent
1167+ $systemFamilyClean = $SystemFamily.Text -replace " ThinkPad" , " " -replace " ThinkCentre" , " " -replace " ThinkStation" , " " -replace " ThinkBook" , " " -replace " ^\s+|\s+$" , " "
1168+
1169+ # Construire la ligne de données
1170+ $row = [PSCustomObject ]@ {
1171+ " Machine Type" = $MachineType.Text
1172+ " System Family" = $systemFamilyClean
1173+ " Bios Version" = $BiosVer.Text
1174+ " Bios Date" = $BiosDate.Text
1175+ " AvailableUpdates" = $Reg1_HexValue.Text
1176+ " UEFICA2023Status" = $Reg2_Value.Text
1177+ " WindowsUEFICA2023Capable" = $Reg3_HexValue.Text
1178+ " UEFICA2023ErrorEvent" = $Reg4_DecValue.Text
1179+ " 1808 Event" = $_1808_Status.Text
1180+ " Date/Time" = (Get-Date - Format " yyyy-MM-dd HH:mm:ss" )
1181+ }
1182+
1183+ # Créer ou ajouter au CSV
1184+ if (Test-Path $csvPath ) {
1185+ $row | Export-Csv - Path $csvPath - Append - NoTypeInformation - Encoding UTF8 - Delimiter " ;"
1186+ } else {
1187+ $row | Export-Csv - Path $csvPath - NoTypeInformation - Encoding UTF8 - Delimiter " ;"
1188+ }
1189+
1190+ Update-StatusLabel - Message " Log saved : $csvPath " - Color " Green"
1191+ }
1192+ catch {
1193+ Update-StatusLabel - Message " Error saving log : $_ " - Color " Red"
1194+ }
10781195 })
10791196}
10801197
0 commit comments