如何让我的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
答案 0 :(得分:3)
This Technet article建议您尝试Get-ExecutionPolicy
检查脚本执行策略,然后将其设置为AllSigned
或Unrestricted
。另外,请确保按照此".\scriptname.ps1"