PowerShell 表示“此系统上禁用了脚本执行。”
我正在尝试运行一个从 cmd.exe
调用 PowerShell 脚本的 cmd
文件,但收到此错误:
Management_Install.ps1
无法加载,因为此系统上禁用了脚本执行。
我运行了以下命令:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
当我从 PowerShell 运行 Get-ExecutionPolicy
时,它返回 Unrestricted
。
Get-ExecutionPolicy
输出:
Unrestricted
cd“C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts” powershell .\Management_Install.ps1 1
警告:运行 x86 PowerShell...
无法加载文件
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\Management_Install.ps1
,因为在此系统上禁用了脚本的执行。请参阅“get-help about_signing
”了解更多详细信息。行:1 个字符:25
.\Management_Install.ps1
<<<<< 1
类别信息:未指定:(:) []、PSSecurityException
FullyQualifiedErrorId:运行时异常
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts>暂停
按任意键继续。 。 .
系统是Windows Server 2008 R2。
我做错了什么?
I am trying to run a cmd
file that calls a PowerShell script from cmd.exe
, but I am getting this error:
Management_Install.ps1
cannot be loaded because the execution of scripts is disabled on this system.
I ran this command:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
When I run Get-ExecutionPolicy
from PowerShell, it returns Unrestricted
.
Get-ExecutionPolicy
Output:
Unrestricted
cd "C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts"
powershell .\Management_Install.ps1 1WARNING: Running x86 PowerShell...
File
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\Management_Install.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:1 char:25
.\Management_Install.ps1
<<<< 1
CategoryInfo : NotSpecified: (:) [], PSSecurityException
FullyQualifiedErrorId : RuntimeException
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts> PAUSE
Press any key to continue . . .
The system is Windows Server 2008 R2.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
在 PowerShell ISE 编辑器中,我发现运行以下行首先允许的脚本。
In the PowerShell ISE editor I found running the following line first allowed scripts.
在 powershell 中
要检查当前执行策略,请使用以下命令:
Get-ExecutionPolicy
要将执行策略更改为“无限制”,允许运行任何没有数字签名的脚本,请使用以下命令:
Set -ExecutionPolicy Unrestricted
这个解决方案对我有用,但要小心涉及的安全风险。
In powershell
To check the current execution policy, use the following command:
Get-ExecutionPolicy
To change the execution policy to Unrestricted, which allows running any script without digital signatures, use the following command:
Set-ExecutionPolicy Unrestricted
This solution worked for me, but be careful of the security risks involved.
在 VS 代码中只需运行以下命令:
In VS code just run this command:
如果您使用的是 Windows Server 2008 R2,则有一个 x64和 x86 版本的 PowerShell 都必须设置其执行策略。您是否在两台主机上都设置了执行策略?
作为管理员,您可以通过在 PowerShell 窗口中输入以下内容来设置执行策略:
有关详细信息,请参阅使用 Set-ExecutionPolicy Cmdlet。
完成后,您可以将策略设置回其默认值:
您可能会看到错误:
因此您可能需要像这样运行命令(如注释中所示):
If you're using Windows Server 2008 R2 then there is an x64 and x86 version of PowerShell both of which have to have their execution policies set. Did you set the execution policy on both hosts?
As an Administrator, you can set the execution policy by typing this into your PowerShell window:
For more information, see Using the Set-ExecutionPolicy Cmdlet.
When you are done, you can set the policy back to its default value with:
You may see an error:
So you may need to run the command like this (as seen in comments):
您可以通过在运行 PowerShell 时添加
-ExecutionPolicy Bypass
来绕过单个文件的此策略You can bypass this policy for a single file by adding
-ExecutionPolicy Bypass
when running PowerShell我遇到了类似的问题,并注意到 Windows Server 2012cmd >,正在运行 x64 版本。
对于Windows 11、Windows 10、Windows 7、Windows 8、Windows Server 2008 R2 strong> 或 Windows Server 2012,以管理员身份运行以下命令:
x86(32 位)
打开
C:\Windows\SysWOW64\cmd.exe
运行命令
powershell Set-ExecutionPolicy RemoteSigned
x64(64 位)
打开
C:\Windows\system32\cmd.exe
运行命令
powershell Set-ExecutionPolicy RemoteSigned
您可以使用以下命令检查模式
echo %PROCESSOR_ARCHITECTURE%
[Environment]::Is64BitProcess
参考文献:
MSDN - Windows PowerShell 执行策略
Windows - 32 位与 64 位目录说明
I had a similar issue and noted that the default
cmd
on Windows Server 2012, was running the x64 one.For Windows 11, Windows 10, Windows 7, Windows 8, Windows Server 2008 R2 or Windows Server 2012, run the following commands as Administrator:
x86 (32 bit)
Open
C:\Windows\SysWOW64\cmd.exe
Run the command
powershell Set-ExecutionPolicy RemoteSigned
x64 (64 bit)
Open
C:\Windows\system32\cmd.exe
Run the command
powershell Set-ExecutionPolicy RemoteSigned
You can check mode using
echo %PROCESSOR_ARCHITECTURE%
[Environment]::Is64BitProcess
References:
MSDN - Windows PowerShell execution policies
Windows - 32bit vs 64bit directory explanation
大多数现有答案都解释了如何,但很少有人解释为什么。在执行互联网上陌生人的代码(尤其是禁用安全措施的代码)之前,您应该确切地了解自己在做什么。这里有关于这个问题的更多细节。
从 TechNet 关于执行策略页面:
其好处,如 PowerShell 基础知识 - 执行策略和代码签名包括:
要检查当前的执行策略,您可以运行
Get-ExecutionPolicy
。但你来这里可能是因为你想改变它。为此,您需要运行
Set-ExecutionPolicy
cmdlet 。更新执行策略时,您需要做出两个主要决定。
执行策略类型:
受限
† - 系统上不能执行本地、远程或下载的脚本。AllSigned
- 所有运行的脚本都需要进行数字签名。RemoteSigned
- 所有远程脚本 (UNC) 或下载的都需要签名。无限制
- 任何类型的脚本都不需要签名。新更改的范围
LocalMachine
† - 执行策略影响计算机的所有用户。CurrentUser
- 执行策略仅影响当前用户。进程
- 执行策略仅影响当前的 Windows PowerShell 进程。† = 默认
例如:如果您想仅将当前用户的策略更改为 RemoteSigned,您需要运行以下命令:
注意 :为了更改执行策略,您必须以管理员身份运行 PowerShell。
如果您处于常规模式并尝试更改执行策略,您将收到以下错误:
如果您想要加强对您自己的未从 Internet 下载的脚本(或至少不包含 UNC 元数据)的内部限制,您可以强制策略仅运行已签名的脚本。要签署您自己的脚本,您可以按照 Scott Hanselman 的文章中的说明进行操作:签署 PowerShell 脚本 。
注意:大多数人每次打开 PowerShell 时都可能会收到此错误,因为 PowerShell 启动时尝试执行的第一件事是执行用户配置文件脚本,该脚本会按照您喜欢的方式设置您的环境。
该文件通常位于:
您可以通过运行 PowerShell 变量找到确切位置
如果配置文件中没有您关心的内容,并且不想对安全设置大惊小怪,您可以将其删除,PowerShell 不会找不到它无法执行的任何内容。
Most of the existing answers explain the How, but very few explain the Why. And before you go around executing code from strangers on the Internet, especially code that disables security measures, you should understand exactly what you're doing. So here's a little more detail on this problem.
From the TechNet About Execution Policies Page:
The benefits of which, as enumerated by PowerShell Basics - Execution Policy and Code Signing, are:
To check your current execution policy, you can run
Get-ExecutionPolicy
. But you're probably here because you want to change it.To do so you'll run the
Set-ExecutionPolicy
cmdlet.You'll have two major decisions to make when updating the execution policy.
Execution Policy Type:
Restricted
† - No Script either local, remote or downloaded can be executed on the system.AllSigned
- All script that are ran require to be digitally signed.RemoteSigned
- All remote scripts (UNC) or downloaded need to be signed.Unrestricted
- No signature for any type of script is required.Scope of new Change
LocalMachine
† - The execution policy affects all users of the computer.CurrentUser
- The execution policy affects only the current user.Process
- The execution policy affects only the current Windows PowerShell process.† = Default
For example: if you wanted to change the policy to RemoteSigned for just the CurrentUser, you'd run the following command:
Note: In order to change the Execution policy, you must be running PowerShell As Administrator.
If you are in regular mode and try to change the execution policy, you'll get the following error:
If you want to tighten up the internal restrictions on your own scripts that have not been downloaded from the Internet (or at least don't contain the UNC metadata), you can force the policy to only run signed scripts. To sign your own scripts, you can follow the instructions on Scott Hanselman's article on Signing PowerShell Scripts.
Note: Most people are likely to get this error whenever they open PowerShell because the first thing PowerShell tries to do when it launches is execute your user profile script that sets up your environment however you like it.
The file is typically located in:
You can find the exact location by running the PowerShell variable
If there's nothing that you care about in the profile, and don't want to fuss with your security settings, you can just delete it and PowerShell won't find anything that it cannot execute.
我们可以通过下面的命令获取当前
ExecutionPolicy
的状态:默认是Restricted。为了允许执行 PowerShell 脚本,我们需要将此 ExecutionPolicy 设置为无限制或绕过。
我们可以使用以下任意 PowerShell 命令将当前用户的策略设置为“绕过”:
无限制策略加载所有配置文件并运行所有脚本。如果您运行从 Internet 下载的未签名脚本,系统会在运行前提示您授予权限。
而在绕过策略中,不会阻止任何内容,并且在脚本执行期间不会出现警告或提示。绕过
ExecutionPolicy
比Unrestricted
更宽松。We can get the status of current
ExecutionPolicy
by the command below:By default it is Restricted. To allow the execution of PowerShell scripts we need to set this ExecutionPolicy either as Unrestricted or Bypass.
We can set the policy for Current User as
Bypass
by using any of the below PowerShell commands:Unrestricted policy loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
Whereas in Bypass policy, nothing is blocked and there are no warnings or prompts during script execution. Bypass
ExecutionPolicy
is more relaxed thanUnrestricted
.在脚本之前运行此命令也可以解决问题:
Also running this command before the script also solves the issue:
如果您所在的环境不是管理员,您可以专门为您设置执行策略 (
CurrentUser
),并且不需要管理员。您可以将其设置为
RemoteSigned
:或
Unrestricted
:您可以在帮助条目中阅读有关获取和设置执行策略的所有内容:
If you are in an environment where you are not an administrator, you can set the Execution Policy just for you (
CurrentUser
), and it will not require administrator.You can set it to
RemoteSigned
:or
Unrestricted
:You can read all about Getting and Setting Execution policy in the help entries:
在 Windows 7 中:
转到“开始”菜单并搜索“Windows PowerShell ISE”。
右键单击 x86 版本并选择“以管理员身份运行”。
在顶部,粘贴
Set-ExecutionPolicy RemoteSigned
;运行脚本。选择“是”。对 64 位版本的 Powershell ISE(非 x86 版本)也重复这些步骤。
In Windows 7:
Go to Start Menu and search for "Windows PowerShell ISE".
Right click the x86 version and choose "Run as administrator".
In the top part, paste
Set-ExecutionPolicy RemoteSigned
; run the script. Choose "Yes".Repeat these steps for the 64-bit version of Powershell ISE too (the non x86 version).
RemoteSigned:您自己创建的所有脚本都将运行,并且从 Internet 下载的所有脚本都需要由受信任的发布者签名。
好的,只需键入以下内容即可更改策略:
RemoteSigned: all scripts you created yourself will be run, and all scripts downloaded from the Internet will need to be signed by a trusted publisher.
OK, change the policy by simply typing:
首先,您需要打开 PowerShell 窗口并运行此命令。
set-ExecutionPolicy RemoteSigned -Scope CurrentUser
然后它会要求你确认。输入 Y 并按 Enter。
当您运行此命令时,您可以看到您的系统已将当前用户的所有策略设置为远程。完成此过程将需要几秒钟的时间。
图像将显示如下:
检查执行策略是否已设置。类型:
Get-ExecutionPolicy
如果已设置,输出将如下所示:
< img src="https://i.sstatic.net/0wTAV.png" alt="在此处输入图像描述">
First, you need to open the PowerShell window and run this command.
set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Then it will ask you to confirm. Type Y and press Enter.
When you run this command, you can see that your system has set all policies for the current user as remotely. It will take a few seconds to complete this process.
The image will be shown like below:
To check if the execution policy has set. Type:
Get-ExecutionPolicy
If it was set, the output would be like this:
我使用的是 Windows 10,无法运行任何命令。给我一些线索的唯一命令是:
[x64]
但这不起作用。这是有限的。可能是 Windows10 的新安全策略。我有这个错误:
所以我找到了另一种方法(解决方案):
现在打开 PowerShell 并享受吧;)
I'm using Windows 10 and was unable to run any command. The only command that gave me some clues was this:
[x64]
But this didn't work. It was limited. Probably new security policies for Windows10. I had this error:
So I found another way (solution):
Now open PowerShell and enjoy ;)
打开 Windows PowerShell 命令窗口并运行以下查询来更改
ExecutionPolicy
:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
如果要求确认更改,按 Y 并按 Enter。
Open a Windows PowerShell command window and run the below query to change
ExecutionPolicy
:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
If it asks for confirming changes, press Y and hit Enter.
你应该运行这个命令:
You should run this command:
这对我有用
This worked for me
Win + R 并键入复制粘贴命令,然后按确定:
并执行脚本。
然后恢复更改,例如:
Win + R and type copy paste command and press OK:
And execute your script.
Then revert changes like:
在 Windows 中打开命令提示符。
如果问题仅与 PowerShell 相关,请使用以下命令:
Open the command prompt in Windows.
If the problem is only with PowerShell, use the following command:
设置执行策略是特定于环境的。如果您尝试从正在运行的 x86 ISE 执行脚本,您有使用 x86 PowerShell 设置执行策略。同样,如果您运行 64 位 ISE,则必须使用 64 位 PowerShell 设置策略。
Setting the execution policy is environment-specific. If you are trying to execute a script from the running x86 ISE you have to use the x86 PowerShell to set the execution policy. Likewise, if you are running the 64-bit ISE you have to set the policy with the 64-bit PowerShell.
类型:gpedit。 msc(组策略编辑器)
根据需要设置策略。 我将其设置为“允许所有脚本”。
现在运行运行命令,无论您使用什么。相信应用程序将运行。享受:)
Type: gpedit. msc (Group Policy Editor)
Set the policy as needed. I set mine to "Allow all scripts".
Now run the run command what ever you are using.. Trust this the app will runs.. Enjoy :)
现有答案中有很多信息,但让我尝试系统概述:
Context
PowerShell 的有效执行策略适用:
存储在文件中的PowerShell代码,这意味着:
*.ps1
)*.psm1
)(在 PowerShell 中实现的模块)*.Format.ps1xml
和*.Types.ps1xml
) - 即使这些文件碰巧不包含嵌入的PowerShell 脚本块。Get-ChildItem
),除了随模块附带的第三方二进制 cmdlet包括格式化和类型扩展文件,如上所述。-Command
参数(除非这些命令直接或间接调用上面定义的脚本文件)。仅在 Windows 上(即,在类 Unix 平台(Linux、macOS)上)执行策略不适用,并且没有限制放置在执行 PowerShell 代码上)
在 Windows 的工作站版本中,默认情况下禁用脚本文件执行(策略
受限
),需要对策略进行持续修改才能启用它,或者仅限当前进程修改,例如调用 PowerShell CLI 时通过-ExecutionPolicy
参数,powershell.exe
(Windows PowerShell 版本)/pwsh.exe
( PowerShell(核心)7 版)。在最近的服务器版本的Windows中,默认策略是
RemoteSigned
,这意味着虽然本地存储的脚本(包括在文件共享)可以执行,从网络下载的脚本只有在经过签名后才会执行。执行策略单独维护:
对于两个PowerShell版本:
适用于32位和64位版本的Windows PowerShell(两者均已预安装)
LocalMachine
范围将是特定于位的。对于给定的 PowerShell 版本/位数组合,可以在多个范围内设置执行策略,但只有一个有效策略,基于优先规则 - 见下文。
详细信息
在 Windows 上的 PowerShell 中,默认情况下在工作站中禁用脚本文件执行Windows 版本(在 Unix 上,执行策略不适用);也就是说,Windows 工作站版本中的默认执行策略是
Restricted
,而在服务器版本中,它是远程签名
;请参阅概念性 about_Execution_Policies 帮助主题了解所有可用策略的说明。要设置允许脚本执行的(本地)策略,请使用
Set-ExecutionPolicy
,策略为AllSigned
、RemoteSigned
、无限制
或绕过
,按安全性降序排列。使用-Scope
参数,Set-ExecutionPolicy
可以针对三个范围(见下文); 更改LocalMachine
范围的策略需要提升(以管理员身份运行)。提供安全性和便利性之间的平衡的常用策略是
RemoteSigned
,它允许本地 em> 脚本 - 包括来自网络共享 - 执行而不包含签名,同时要求对从互联网下载的脚本进行签名(假设下载机制标记为脚本源自互联网,网络浏览器默认执行此操作)。例如,要将当前用户的执行策略设置为RemoteSigned
,请运行以下命令:要在给定范围内取消设置先前设置的策略,请使用
未定义
策略。PowerShell CLI (
powershell.exe
用于 Windows PowerShell,pwsh.exe
for PowerShell(核心)7< /em>) 也接受特定于流程的-ExecutionPolicy
参数,该参数通常用于临时策略覆盖(仅适用于正在创建的进程,相当于Set-ExecutionPolicy -Scope Process ...
);例如:重要:
执行策略也可以通过组策略对象 (GPO),在这种情况下,它们不能使用
Set-ExecutionPolicy
或通过 CLI 的-ExecutionPolicy
进行更改或覆盖> 参数:请参阅about_Group_Policy_Settings< /a>可以在各种范围中设置执行策略,其中哪一个有效取决于其优先级(运行
Get-ExecutionPolicy
-列出
以查看所有范围及其各自的策略),按降序:MachinePolicy
(通过 GPO;无法在本地覆盖)[1]UserPolicy
(通过 GPO;无法在本地覆盖)[1]进程
(仅限当前进程;通常通过 CLI 设置临时进程)CurrentUser
(由Set-ExecutionPolicy
设置)LocalMachine
(由Set-ExecutionPolicy
设置,具有管理员权限)[ 1] 这适用于域范围内的 GPO。 本地 GPO可以在本地修改,即通过
gpedit.msc
或直接通过注册表(在机器<的情况下)< /em> 策略需要管理权限。There's great information in the existing answers, but let me attempt a systematic overview:
Context
PowerShell's effective execution policy applies:
to PowerShell code stored in files, which means:
*.ps1
)*.psm1
) (modules implemented in PowerShell)*.Format.ps1xml
and*.Types.ps1xml
) - even if those files happen not to contain embedded PowerShell script blocks.Get-ChildItem
), except for third-party binary cmdlets that come with modules that encompass formatting and type-extension files, as discussed above.-Command
parameter (unless these commands directly or indirectly call script files as defined above).on Windows only (that is, on Unix-like platforms (Linux, macOS) execution policies do not apply and no restrictions are placed on executing PowerShell code)
In workstation editions of Windows, script-file execution is disabled by default (policy
Restricted
), requiring either a persistent modification of the policy to enable it, or a current-process-only modification such as via the-ExecutionPolicy
parameter when calling the PowerShell CLI,powershell.exe
(Windows PowerShell edition) /pwsh.exe
(PowerShell (Core) 7 edition).In recent server editions of Windows, the default policy is
RemoteSigned
, meaning that while locally stored scripts (including on file shares) may be executed, downloaded-from-the-web scripts only execute if they're signed.Execution policies are maintained separately:
for the two PowerShell editions:
for the 32-bit and 64-bit versions of Windows PowerShell (both of which are preinstalled)
LocalMachine
scope would be bitness-specific.For a given edition / bitness combination of PowerShell, the execution policies can be set in multiple scopes, but there's only ever one effective policy, based on precedence rules - see below.
Details
In PowerShell on Windows, script-file execution is disabled by default in workstation editions of Windows (on Unix, execution policies do not apply); that is, the default execution policy in workstation editions of Windows is
Restricted
, whereas in server editions, it isRemoteSigned
; see the conceptual about_Execution_Policies help topic for a description of all available policies.To set a (local) policy that permits script execution, use
Set-ExecutionPolicy
with a policy ofAllSigned
,RemoteSigned
,Unrestricted
, orBypass
, in descending order of security. There are three scopes thatSet-ExecutionPolicy
can target, using the-Scope
parameter (see below); changing theLocalMachine
scope's policy requires elevation (running as admin).A frequently used policy that provides a balance between security and convenience is
RemoteSigned
, which allows local scripts - including from network shares - to execute without containing a signature, while requiring scripts downloaded from the internet to be signed (assuming that the downloading mechanism marks such as scripts as internet-originated, which web browsers do by default). For instance, to set the current user's execution policy toRemoteSigned
, run the following:To unset a previously set policy in a given scope, use the
Undefined
policy.The PowerShell CLI (
powershell.exe
for Windows PowerShell,pwsh.exe
for PowerShell (Core) 7) accepts a process-specific-ExecutionPolicy <policy>
argument too, which is often used for ad-hoc policy overrides (only for the process being created, the equivalent ofSet-ExecutionPolicy -Scope Process ...
); e.g.:Important:
Execution policies can also be set via Group Policy Objects (GPOs), in which case they can not be changed or overridden with
Set-ExecutionPolicy
or via the CLI's-ExecutionPolicy
parameter: see about_Group_Policy_SettingsExecution policies can be set in various scopes, and which one is in effect is determined by their precedence (run
Get-ExecutionPolicy
-List
to see all scopes and their respective policies), in descending order:MachinePolicy
(via GPO; cannot be overridden locally)[1]UserPolicy
(via GPO; cannot be overridden locally)[1]Process
(current process only; typically set ad-hoc via the CLI)CurrentUser
(as set bySet-ExecutionPolicy
)LocalMachine
(as set bySet-ExecutionPolicy
, with admin rights)[1] This applies to domain-wide GPOs. Local GPOs can be modified locally, namely via
gpedit.msc
or directly via the registry, which in the case of the machine policy requires administrative privileges.您可以尝试此操作并选择“全部”选项
you may try this and select "All" Option
您还可以使用以下命令绕过此问题:
您还可以阅读 Scott Sutherland 撰写的这篇文章,其中解释了在没有管理员权限的情况下绕过 PowerShell
Set-ExecutionPolicy
的 15 种不同方法:绕过 PowerShell 执行策略的 15 种方法
You can also bypass this by using the following command:
You can also read this article by Scott Sutherland that explains 15 different ways to bypass the PowerShell
Set-ExecutionPolicy
if you don't have administrator privileges:15 Ways to Bypass the PowerShell Execution Policy
我也遇到过类似的问题。试试这个。
由于我使用的是 Windows,因此我按照以下步骤操作。
以管理员身份打开命令提示符,然后转到此路径:
在此文件夹(目录)中查找文件 ng.ps1
然后删除它(del ng.ps1)。
您还可以在此之后清除 npm 缓存,尽管没有此步骤它也应该可以工作。
I have also faced a similar issue. Try this.
As I'm using Windows, I followed the steps as given below.
Open a command prompt as an administrator and then go to this path:
Look for the file ng.ps1 in this folder (directory)
and then delete it (del ng.ps1).
You can also clear npm cache after this though it should work without this step as well.
如果您安装了 Git,只需使用 Git Bash。
If you have Git installed, just use Git Bash.
在PowerShell中以管理员模式执行此命令将解决该问题。
Executing this command in administrator mode in PowerShell will solve the problem.
在Window 10中:
如果您不是管理员,您可以使用这个:
它像魅力一样解决了我的问题!
In Window 10:
If you are not administrator, you can use this:
It solved my problem like a charm!
对于Windows 11...
确实非常简单。只需打开设置应用程序即可。
导航到隐私和安全:
单击对于开发人员并滚动到底部并找到 PowerShell 选项,在该选项下选中“更改”复选框执行策略...远程脚本”。
For Windows 11...
It is indeed very easy. Just open the settings application.
Navigate to Privacy and Security:
Click on For Developers and scroll to the bottom and find the PowerShell option under which check the checkbox stating "Change the execution policy ... remote scripts".