Created
June 28, 2017 17:16
-
-
Save blazejwiecha/ddff1be7781eaf0b42363f4d347aac61 to your computer and use it in GitHub Desktop.
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
param([switch]$Elevated) | |
function Test-Admin { | |
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) | |
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
if ((Test-Admin) -eq $false) { | |
if ($elevated) | |
{ | |
# tried to elevate, did not work, aborting | |
} | |
else { | |
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) | |
} | |
exit | |
} | |
'running with full privileges' | |
md -Path 'C:\Windows\perfc' | |
Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment