Skip to content

Instantly share code, notes, and snippets.

@vivek1986
Created July 26, 2022 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivek1986/05bb0b6f693b4a89e7173602afe69b89 to your computer and use it in GitHub Desktop.
Save vivek1986/05bb0b6f693b4a89e7173602afe69b89 to your computer and use it in GitHub Desktop.
Powershell Set Execution Policy
$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