0

I'm trying to send automated emails with Powershell Send-MailMessage. It works fine on my old computer and I copied the script to my new computer. I xported a new CliXml file for credentials but when I try and run the powershell script nothing happens.

I tried running the script directly in Powershell and see that the issue seems to be the Execution policy. On my old computer it says the LocalMachine is Unrestricted but for the new computer it says all are Undefined. Should I change the new computer to Unrestricted? Could that cause other problems down the road? Is there a better way? Below is the output for my new computer. Thanks.


PS C:\Windows\system32> c:/q/TestEmail.ps1
c:/q/TestEmail.ps1 : File C:\q\TestEmail.ps1 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.
At line:1 char:1
+ c:/q/TestEmail.ps1
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Windows\system32> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined
ks-man
  • 167
  • 2
  • 14
  • 1
    Related - https://stackoverflow.com/q/4037939/62576. Also, did you do as it suggested and look at `about_Execution_Policies` at the link that was provided? That should tell you about the available options and discuss which is applicable. – Ken White Feb 17 '23 at 02:46

0 Answers0