[Error Solve] ps1 cannot be loaded because running scripts is disabled on this system.

1. Problem

If i use powershell batch file(ps1) when i use mstsc(remote desktop), i see the problem. I cannot use batch file in my computer. How can i solve this problem?

PS C:\Users\Administrator\Desktop\window_test> .\test_batch.ps1
.\test_batch.ps1 : File C:\Users\Administrator\Desktop\window_test\test_batch.ps1 cannot be loaded because running
 scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwli
At line:1 char:1
+ .\test_batch.ps1
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

2. Solution

In this situation, we can use Set-ExecutionPolicy RemoteSigned command. I recommned that you run this cmd in administrator mode. After using this cmd, in my case, i can use ps1 file when you remote desktop. If you want to disable run when you remote desktop, you use Set-ExecutionPolicy Restricted command.

PS C:\Users\Administrator\Desktop\window_test> Set-ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
PS C:\Users\Administrator\Desktop\window_test>
PS C:\Users\Administrator\Desktop\window_test>
PS C:\Users\Administrator\Desktop\window_test> .\test_batch.bat
.\test_batch.bat : The term '.\test_batch.bat' is not recognized as the name of a cmdlet, function, script file, or opera
ble program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ .\test_batch.bat
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.\test_batch.bat:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\Administrator\Desktop\window_test>