Execution Policy Issue - ExecutionPolicy -bypass not working

This topic contains 1 reply, has 1 voice, and was last updated by  Jeff 3 months, 1 week ago.

  • Author
  • #93489


    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."

  • #93492


    Ah – Turns out the user that was getting this error copied the script to their home drive and THEN to a USB drive, which blocked the file. I think Unblock-File works in this instance, but don't think this will be an issue in the future since the file won't be copied that way...

You must be logged in to reply to this topic.