From 990dca9e49ce42cf64c2de9740a92b6fce6aa5c2 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 3 Aug 2025 16:36:30 +0000 Subject: [PATCH] Upload files to "/" --- boot.ps1 | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 boot.ps1 diff --git a/boot.ps1 b/boot.ps1 new file mode 100644 index 0000000..ed53d97 --- /dev/null +++ b/boot.ps1 @@ -0,0 +1,82 @@ +#requires -version 4.0 +#requires -runasadministrator + +#Retrieving all events with ID 100 + +$BootEvents = Get-WinEvent -FilterHashtable @{ + logname='Microsoft-Windows-Diagnostics-Performance/Operational'; + id=100} + +#Building a boot history with, for each boot, the duration of the boot process + +$BootHistory = $BootEvents | Select-Object TimeCreated, LevelDisplayName, + @{ + n="BootStartTime"; + e={Get-Date -Date (([xml]$_.ToXml()).Event.EventData.Data | + Where-Object {$_.name -eq "BootStartTime"})."#text"} + }, + @{ + n="BootEndTime"; + e={Get-Date -Date (([xml]$_.ToXml()).Event.EventData.Data | + Where-Object {$_.name -eq "BootEndTime"})."#text"} + }, + @{ + n="MainPathBootTime"; + e={([timespan]::FromMilliseconds((([xml]$_.ToXml()).Event.EventData.Data | + Where-Object {$_.name -eq "MainPathBootTime"})."#text"))} + }, + @{ + n="BootPostBootTime"; + e={([timespan]::FromMilliseconds((([xml]$_.ToXml()).Event.EventData.Data | + Where-Object {$_.name -eq "BootPostBootTime"})."#text"))} + } + +$BootStartTime = $BootHistory.bootstarttime + +$MainPathBootTime = $BootHistory.MainPathBootTime + +$PostBootTime = $BootHistory.BootPostBootTime + +$LastBootDate = $BootStartTime | Select-Object -First 1 + +$OldestRecordedBoot = $BootStartTime | Select-Object -last 1 + +$BootFrequencyInDays = ($LastBootDate - $OldestRecordedBoot).days / $BootStartTime.Count + +$AvgMainBootDuration = [timespan]::FromSeconds((($MainPathBootTime.totalseconds | + Measure -A).average)).ToString("hh\:mm\:ss") + +$AvgPostBootDuration = [timespan]::FromSeconds((($PostBootTime.totalseconds | + Measure -A).average)).ToString("hh\:mm\:ss") + +$ActualWindowsBootTime = (Get-Date) - ` + ([timespan]::FromMilliseconds([Math]::Abs([Environment]::TickCount))) + +$LastEvent12 = Get-WinEvent -FilterHashtable @{ + LogName='System'; + ProviderName='Microsoft-Windows-Kernel-General'; + ID=12} -MaxEvents 1 | Select -ExpandProperty TimeCreated + + +#Building an object containing a quick summary of your last computer boot, as +#well as of the average boot duration. + +$BootInformation = 1 | Select-Object BootFrequencyInDays, AvgMainBootDuration, ` + AvgPostBootDuration, LastBootDate, OldestRecordedBoot, ` + ActualWindowsBootTime, LastEvent12 +$BootInformation.BootFrequencyInDays = $BootFrequencyInDays +$BootInformation.AvgMainBootDuration = $AvgMainBootDuration +$BootInformation.AvgPostBootDuration = $AvgPostBootDuration +$BootInformation.LastBootDate = $LastBootDate +$BootInformation.OldestRecordedBoot = $OldestRecordedBoot +$BootInformation.ActualWindowsBootTime = $ActualWindowsBootTime +$BootInformation.LastEvent12 = $LastEvent12 + +#Grouping boot events by Level, in order to see if your computer boot duration is below or +#beyond the thresholds defined in the Registry +$BootAnalysis = Get-WinEvent -FilterHashtable @{ + logname='Microsoft-Windows-Diagnostics-Performance/Operational'; + id=100} | + Group-Object LevelDisplayName + +$BootHistory | Out-Gridview \ No newline at end of file