Last active
April 28, 2018 12:43
-
-
Save mnaoumov/fe950c42fca4ad2482df2878b3bf9aaa to your computer and use it in GitHub Desktop.
Setup environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
powershell -NoExit -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri https://gist.githubusercontent.com/mnaoumov/fe950c42fca4ad2482df2878b3bf9aaa/raw/Setup.ps1 -UseBasicParsing | Invoke-Expression" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Version 4 | |
[CmdletBinding()] | |
param | |
( | |
) | |
$ErrorActionPreference = "Stop" | |
Set-StrictMode -Version Latest | |
trap { throw $Error[0] } | |
function Main { | |
if (-not $PSCommandPath) { | |
Invoke-WebRequest -Uri https://gist.githubusercontent.com/mnaoumov/fe950c42fca4ad2482df2878b3bf9aaa/raw/Setup.ps1 -OutFile '~\Setup.ps1' | |
} | |
if (-not $PSCommandPath -or -not (Test-Administrator)) { | |
$scriptPath = Resolve-Path '~\Setup.ps1' | |
Start-Process -FilePath powershell.exe -ArgumentList "-NoExit -NoProfile -ExecutionPolicy Bypass -File $scriptPath" -Verb RunAs | |
Read-Host -Prompt "Executing as admin. Press Enter to close" | |
exit | |
} | |
Read-Host -Prompt "Execution finished. Press Enter to close" | |
} | |
function Test-Administrator { | |
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
} | |
Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment