Created
July 26, 2022 02:11
-
-
Save vivek1986/05bb0b6f693b4a89e7173602afe69b89 to your computer and use it in GitHub Desktop.
Powershell Set Execution Policy
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
$Loc = Get-Location | |
"Security.Principal.Windows" | % { IEX "( [ $_`Principal ] [$_`Identity ]::GetCurrent() ).IsInRole( 'Administrator' )" } | ? { | |
$True | % { $Arguments = @('-NoProfile','-ExecutionPolicy Bypass','-NoExit','-File',"`"$($MyInvocation.MyCommand.Path)`"","\`"$Loc\`""); | |
Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $Arguments; } } | |
(Get-Location).ToString() | |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine | |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser | |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process | |
Read-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment