默认情况下,Powershell 脚本不起作用 [英] Powershell scripts don't work by default

查看:35
本文介绍了默认情况下,Powershell 脚本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想开始编写一个 powershell 脚本.我想从小处开始,简单地编写一个脚本,将本地文件夹替换为驱动器.很简单.我在使用旧的 DOS 命令工具之前已经完成了.

所以我想写的脚本是:

subst d: G:\CER

好的,所以我尝试通过按播放"按钮(即 F5)在 Powershell ISE 中执行脚本

那我能得到什么?

<块引用>

文件 G:\CER\Make_Stage.ps1 不能加载,因为 执行脚本在此系统上被禁用.请参阅get-help about_signing"更多细节.在行:0 字符:0

这是多么愚蠢,Powershell 脚本的开箱即用执行被禁用!即默认情况下!令人难以置信的是,默认情况下,这个新工具根本不起作用.Powershell 必须是最愚蠢的脚本 shell.

所以显然我必须在某处注册一些东西(希望不是用 MS).如果有人知道如何解决这个问题,我将不胜感激.

解决方案

要启用脚本,请以管理员身份打开 powershell 提示符并运行:

<前>Set-ExecutionPolicy RemoteSigned

这是 Lee 的一篇博文,讨论了 PowerShell 的安全原则(http://www.leeholmes.com/blog/2005/08/16/demonstration-of-monads-security-features/).

请记住,大多数计算机永远不会运行 PowerShell 脚本.

So I wanted to get started with writing a powershell script. I wanted to start small and simply write a script that substiutes a local file folder as a drive. Pretty simple. I've done it before using the old DOS command tools.

So the script I wanted to write is:

subst d: G:\CER

Ok, so I try to execute the script in the Powershell ISE by pressing the 'Play' button (i.e. F5)

So what do I get?

File G:\CER\Make_Stage.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details. At line:0 char:0

How stupid is this, that out of the box execution of powershell scripts are disabled! i.e. By default! Simply incredible that by default this new tool simply does not work. Powershell has to be the stupidest scripting shell out there.

So apparently I have to register something somewhere (hopefully not with MS). If anyone has an answer as to how to fix this, I'd appreciate it.

解决方案

To enable scripting, open a powershell prompt as Administrator and run:

Set-ExecutionPolicy RemoteSigned

Here's a blog post from Lee that talks about PowerShell's security principles (http://www.leeholmes.com/blog/2005/08/16/demonstration-of-monads-security-features/).

Keep in mind that most computer will never run a PowerShell script.

这篇关于默认情况下,Powershell 脚本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆