Revert "Self-elevate OpenSSH overwrite script"
This reverts commit b13fdb492e.
This commit is contained in:
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
The repository root contains `.\overwrite_openssh_license.ps1`.
|
The repository root contains `.\overwrite_openssh_license.ps1`.
|
||||||
|
|
||||||
The script relaunches itself elevated when needed, then overwrites
|
The script overwrites `C:\Windows\System32\OpenSSH\LICENSE.txt` with:
|
||||||
`C:\Windows\System32\OpenSSH\LICENSE.txt` with:
|
|
||||||
|
|
||||||
```text
|
```text
|
||||||
hello world
|
hello world
|
||||||
|
|||||||
@@ -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'
|
$targetPath = 'C:\Windows\System32\OpenSSH\LICENSE.txt'
|
||||||
|
|
||||||
Set-Content -Path $targetPath -Value 'hello world'
|
Set-Content -Path $targetPath -Value 'hello world'
|
||||||
|
|||||||
Reference in New Issue
Block a user