Fixed a flaw in the admin check

This commit is contained in:
Olai Vike Bøe 2024-05-27 09:00:26 +02:00
parent 6aa29dbf34
commit 97af9654c9

View file

@ -128,12 +128,14 @@ if ($config.options.enableForcedVersion) {
}
}
# Check if the script is running with administrative privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Log-Message "Error: the config 'enableNumberedVersion' requires administrative privileges to run."
}
else {
if ($config.options.enableNumberedVersion) {
& $PSScriptRoot\Rename.ps1
}
if ($config.options.enableNumberedVersion) {
# Check if the script is running with administrative privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Log-Message "Error: the config 'enableNumberedVersion' requires administrative privileges to run."
}
else {
if ($config.options.enableNumberedVersion) {
& $PSScriptRoot\Rename.ps1
}
}
}