Hi @daryush salahshur ,
When you try to run a PowerShell script that has not been signed by a trusted publisher, you may get the following security error:
"script.ps1 :File path\script.ps1 cannot be loaded. The file path\script.ps1 is not digitally signed. You cannot run this script on the current system."
This security error can occur when the PowerShell's execution policy is set to Allsigned or Remotesigned and the script isn't signed.
There are different methods to overcome this error. You may choose to either sign the PowerShell script, change the execution policy, bypass the policy or unblock the file so that it can run once on that session.
First of all check your execution policy using the cmdlet Get-ExecutionPolicy -list
PS C:\> Get-ExecutionPolicy -list
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
The default execution policy is RemoteSigned. The easiest but unsecure method of getting rid of this error message is to change the ExecutionPolicy using the SetExecutionPolicy cmdlet. The following command sets the execution policy to unrestricted.
Set-ExecutionPolicy unrestricted
Press Y to confirm the change when prompted. The policy change is updated in the registry and will remain until you change it again. Instead of changing the execution policy permanently you could set a different policy for a single PowerShell session. This is done using the ExecutionPolicy parameter of powershell.exe
powershell.exe -executionpolicy -bypass
If you trust the contents of the script are safe then you can unblock it to run on your session using the Unblock-File cmdlet
Unblock-File -Path C:\Users \ moon \ AppData \ Roaming \ npm\tsc.ps1
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.