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