diff --git a/Microsoft/Disable_Fast_Startup.ps1 b/Microsoft/Disable_Fast_Startup.ps1 new file mode 100644 index 0000000..bc5592a --- /dev/null +++ b/Microsoft/Disable_Fast_Startup.ps1 @@ -0,0 +1,55 @@ +# Script by Timur@0x01337.com +# Date: 2023-11-24 +<# +.DESCRIPTION +Disables the Fast Startup feature. + +Requires administrator privileges. + +.PARAMETER help +Displays a detailed usage description of this script. + +.EXAMPLE +PS> .\Disable-Fast-Startup.ps1 + +.EXAMPLE +PS> .\Disable-Fast-Startup.ps1 -help +#> + +# Getting command line parameters +param ( + [parameter(Mandatory = $false)][switch]$help +) + +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +if (!$isAdmin) { + Write-Error "This script requires administrator privileges" + exit 1 +} + +# Writing help message +if ($help) { + get-help $MyInvocation.MyCommand.Path -Full + exit 0 +} + +$command = "powercfg" +$arguments = "/H off" + +Write-Host "Running $command $arguments" +try { + $process = Start-Process -Wait -PassThru -NoNewWindow -FilePath $command -ArgumentList $arguments +} +catch { + Write-Error "Error: $_, exit code: $($process.ExitCode)" + exit 1 +} + +if (!$process -or $process.ExitCode -ne 0) { + Write-Error "$command $arguments failed, exit code: $($process.ExitCode)" + exit 1 +} + +Write-Host "$command $arguments finish, exit code: $($process.ExitCode)" +exit 0