RemoteSigned. Requires that all scripts and configuration files downloaded from the Internet are signed by a trusted publisher. The default execution policy for Windows server computers.
RemoteSigned 参数要求所有网络下载的脚本和配置文件必须有可信发布者的签名(和HTTPS或Windows自带的签名机制类似),这也是 Windows Powershell 默认的策略。
未经过签名的脚本在 RemoteSigned 策略下运行会产生这样的结果
PS> .\Start-ActivityTracker.ps1
.\Start-ActivityTracker.ps1 : File .\Start-ActivityTracker.ps1 cannot be loaded.
The file .\Start-ActivityTracker.ps1 is not digitally signed.
The script will not execute on the system.
For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\Start-ActivityTracker.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
参考 set-executionpolicy
Set-ExecutionPolicy 是一个 Powershell 的 cmd-let ,用途是设定 powershell 脚本的安全策略。即决定什么 .ps 脚本可以被运行,什么脚本不允许运行。详细介绍看上面的参考文档。
RemoteSigned 参数要求所有网络下载的脚本和配置文件必须有可信发布者的签名(和HTTPS或Windows自带的签名机制类似),这也是 Windows Powershell 默认的策略。
未经过签名的脚本在 RemoteSigned 策略下运行会产生这样的结果