Reputation: 25938
How can I get my PowerShell script to execute?
When I run my script I get the error:
File cannot be loaded because the execution of scripts is disabled on this system
Can you help me to get my script to run?
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
Upvotes: 1
Views: 9964
Reputation: 27849
This Technet article suggests trying Get-ExecutionPolicy
to check your script execution policy, and then set it to AllSigned
or Unrestricted
. Also, make sure you run the script like this ".\scriptname.ps1"
Upvotes: 3