在这个答案中 ,Sam表示为了让Windows相信我的Powershellconfiguration文件来执行,每当我打开一个PowerShell shell时,我应该可以and click "Properties." At the bottom of the dialogue box click "Unblock" and click "Properties." At the bottom of the dialogue box click "Unblock" ; 当我这样做时,我根本没有看到任何取消阻止checkbox。
我也不想通过设置Set-ExecutionPolicy Unrestricted来运行任何旧脚本。 我想在PowerShellconfiguration文件中自动加载在我select的networking上的PowerShell提示符下的function。
Instead when I load it I get the following error: . : File \\redirected.domain.org\Redirected\yy-xxx\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + . '\\redirected.domain.org\Redirected\yy-xxx\My Documents\WindowsPowerShell\Microsof ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
这似乎是微软防止你知道你在使用电脑,而不是一些美化的纸的方式。
有没有办法让我的powershellconfiguration文件加载,只需打开Powershell而不打开自己的其他漏洞?
我觉得有两个问题。
您可以使用:
Set-ExecutionPolicy RemoteSigned
它告诉PowerShell执行本地脚本,但不是任何非本地脚本。
非本地脚本可以是存储在本地机器上的脚本,但是已经从互联网下载并且在其NTFS备用数据stream中具有:Zone.Identifier:$DATA 26 。 文件属性对话框中的unblock会删除该数据stream,并使文件“真正”为本地文件。 完成之后,您可以在PowerShell中运行它。
但似乎你的configuration文件位于远程服务器上,所以它永远不会是本地的。
您可以将configuration文件复制到本地计算机,并确保它被解除封锁,您可以使用Unblock-File cmdlet。
或者,您可以将您的configuration文件保存为远程文件,但需要使用数字签名进行签名,但为此您需要工作站信任的代码签名证书。