$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'