[英]execution policy error while calling powershell script from batch file, powershell v 1.0
我創建了一個PowerShell腳本來從子文件夾中獲取文件。 這是在手動輸入Set-ExecutionPolicy unrestricted
后從PowerShell控制台運行時Set-ExecutionPolicy unrestricted
,但是當我從批處理文件中調用相同的腳本時
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe D:\programs\abc\bin\xyz_clean.ps1
它會拋出一個錯誤:
無法加載xyz_clean.ps1,因為在此系統上禁用了腳本的執行。
您可以從命令窗口調用powershell:
C:\> powershell /?
C:\> powershell -executionpolicy unrestricted -file \\server\file.ps1
然后將其保存為.bat文件:
C:\> echo powershell -executionpolicy unrestricted -file \\server\file.ps1 > file.bat
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.