批处理文件以执行Powershell脚本 [英] Batch file to execute a Powershell script
问题描述
我有一个Powershell脚本,可以将CSV文件转换为Excel,但是我想创建一个批处理文件来执行该Powershell脚本.当我尝试收到错误消息时:
I have a Powershell script which converts a CSV file to Excel, however I want to create a Batch file to execute that Powershell script. When I try to I get an error message:
error processing aurguments. there is no option with the following name: execution policy.
Syntax
powershell_ise.exe[[-File] <listoffiles>][-Help]-[MTA][-Noprofile]
批处理文件脚本为:
@echo off
Powershell_ise.exe -executionpolicy remotesigned -File C:\Users\siddhary\Desktop\csv_to_xlsx .ps1
但是,当我打开Powershell_ise.exe
,然后从桌面&运行,它成功运行.但是,当我尝试使用批处理文件执行此操作时,会收到上述错误消息.
请帮忙.
however when I open the Powershell_ise.exe
, then open the script from desktop & run, it runs succesfully. But when I try to do it with a batch file I get the above error message.
Please help.
推荐答案
错误消息告诉您确切的问题所在. Powershell_ise.exe不接受-executionpolicy参数.您可以运行以下命令自己进行验证:
The error message is telling you exactly what's wrong. Powershell_ise.exe does not accept an -executionpolicy parameter. You can verify this yourself by running:
powershell_ise.exe /?
这篇关于批处理文件以执行Powershell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!