无法执行PowerShell脚本

时间:2013-05-01 03:32:58

标签: windows powershell

如何让我的PowerShell脚本执行?

当我运行脚本时,我收到错误:
File cannot be loaded because the execution of scripts is disabled on this system

你能帮助我让我的脚本运行吗?

set-executionpolicy unrestricted
#Set-ExecutionPolicy RemoteSigned

$target=[IO.File]::ReadAllText(".\usermenuTest1.4d")
$output=[IO.File]::ReadAllText(".\usermenuTest2.4d")

($output -replace $target) | Set-Content "usermenuTest2.4d.new"

Start-Sleep -s 10

1 个答案:

答案 0 :(得分:3)

This Technet article建议您尝试Get-ExecutionPolicy检查脚本执行策略,然后将其设置为AllSignedUnrestricted。另外,请确保按照此".\scriptname.ps1"

运行脚本