Check if Powershell is running in admin mode before running script (#493)
This commit is contained in:
parent
bbb500a639
commit
794bf53f49
|
@ -3,6 +3,13 @@
|
|||
# @manojampalam - removed ntrights.exe dependency
|
||||
# @bingbing8 - removed secedit.exe dependency
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (!([bool]([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")))
|
||||
{
|
||||
throw "You must be running as an administrator, please restart as administrator"
|
||||
}
|
||||
|
||||
$scriptpath = $MyInvocation.MyCommand.Path
|
||||
$scriptdir = Split-Path $scriptpath
|
||||
|
||||
|
@ -48,6 +55,7 @@ finally {
|
|||
}
|
||||
|
||||
# Fix the registry permissions
|
||||
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
|
||||
Import-Module $PSScriptRoot\OpenSSHUtils -Force
|
||||
Enable-Privilege SeRestorePrivilege | out-null
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
$scriptpath = $MyInvocation.MyCommand.Path
|
||||
if (!([bool]([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")))
|
||||
{
|
||||
throw "You must be running as an administrator, please restart as administrator"
|
||||
}
|
||||
|
||||
$scriptpath = $MyInvocation.MyCommand.Path
|
||||
$scriptdir = Split-Path $scriptpath
|
||||
$etwman = Join-Path $scriptdir "openssh-events.man"
|
||||
|
||||
|
|
Loading…
Reference in New Issue