简体   繁体   中英

Unable to execute PowerShell Script

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM