I'm having trouble with PowerShell script. I'm getting an error when running it
cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
Script is not being run as admin.
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $MyInvocation.MyCommand.Definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
break
}
Set-ExecutionPolicy Bypass -Scope Process -Force
# Rest code
Seems like the line with execution policy is not being executed.
The command
Set-ExecutionPolicy Unrestricted
didn't help as well.
Powershell.exe -ExecutionPolicy ByPass -File "Your file name here"
– Olaf