forked from chocolatey-archive/chocolatey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ps1
17 lines (16 loc) · 964 Bytes
/
test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$scriptPath = (Split-Path -parent $MyInvocation.MyCommand.path)
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object System.Security.Principal.WindowsPrincipal( $identity )
$isAdmin = $principal.IsInRole( [System.Security.Principal.WindowsBuiltInRole]::Administrator )
$pesterDir = (dir $env:ChocolateyInstall/lib/Pester*)[-1]
if(-not $isAdmin){
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName="$env:windir\System32\WindowsPowerShell\v1.0\powershell.exe"
$psi.Verb="runas"
$psi.Arguments="-NoProfile -ExecutionPolicy unrestricted -Command `". { CD '$scriptPath';. '$pesterDir\tools\bin\pester.bat'; `$ec = `$?;if(!`$ec){Write-Host 'Press any key to continue ...';`$host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');exit 1} } `""
$s = [System.Diagnostics.Process]::Start($psi)
$s.WaitForExit()
exit $s.ExitCode
} else {
. "$pesterDir\tools\bin\pester.bat"
}