diff --git a/docs/overwrite_openssh_license_script.md b/docs/overwrite_openssh_license_script.md index a3280fa..118efe6 100644 --- a/docs/overwrite_openssh_license_script.md +++ b/docs/overwrite_openssh_license_script.md @@ -2,8 +2,7 @@ The repository root contains `.\overwrite_openssh_license.ps1`. -The script relaunches itself elevated when needed, then overwrites -`C:\Windows\System32\OpenSSH\LICENSE.txt` with: +The script overwrites `C:\Windows\System32\OpenSSH\LICENSE.txt` with: ```text hello world diff --git a/overwrite_openssh_license.ps1 b/overwrite_openssh_license.ps1 index 244d5d6..d1669ab 100644 --- a/overwrite_openssh_license.ps1 +++ b/overwrite_openssh_license.ps1 @@ -1,26 +1,3 @@ -$currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() -$currentPrincipal = [Security.Principal.WindowsPrincipal]::new($currentIdentity) -$isElevated = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) - -if (-not $isElevated) -{ - $shellPath = Join-Path $PSHOME 'pwsh.exe' - - if (-not (Test-Path $shellPath)) - { - $shellPath = 'powershell.exe' - } - - Start-Process -FilePath $shellPath -Verb RunAs -ArgumentList @( - '-ExecutionPolicy', - 'Bypass', - '-File', - $PSCommandPath - ) - - exit -} - $targetPath = 'C:\Windows\System32\OpenSSH\LICENSE.txt' Set-Content -Path $targetPath -Value 'hello world'