I have a batch file that is calling a PowerShell script. The PowerShell script performs various tasks before and after adding a computer to the domain. After the machine is added to the domain, Group Policy sets the execution policy to “RemoteSigned.” I have not had an issue using the “ExecutionPolicy -bypass” switch when opening a PowerShell script in the past. Why does PowerShell think the script is a remote script after adding the machine to the domain? Is there something I need to change or add to the batch file?
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -NoExit -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
Edit: I forgot to add that when running the script, I receive the error:
" File C:… cannot be loaded. The file “FILE.ps1” is not digitally signed. You cannot run this script on the current system."