Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要帮助修复正在执行到powershell的批处理文件_Powershell_Batch File - Fatal编程技术网

我需要帮助修复正在执行到powershell的批处理文件

我需要帮助修复正在执行到powershell的批处理文件,powershell,batch-file,Powershell,Batch File,我尝试在批处理文件中调用这些powershell脚本,如下所示: Powershell.exe -executionpolicy remotesigned -File d:\1.ps1 Powershell.exe -executionpolicy remotesigned -File d:\2.ps1 Powershell.exe -executionpolicy remotesigned -File d:\3.ps1 Powershell.exe -executionpolicy re

我尝试在批处理文件中调用这些powershell脚本,如下所示:

Powershell.exe -executionpolicy remotesigned -File  d:\1.ps1
Powershell.exe -executionpolicy remotesigned -File  d:\2.ps1
Powershell.exe -executionpolicy remotesigned -File  d:\3.ps1
Powershell.exe -executionpolicy remotesigned -File  d:\4.ps1
我运行了该批处理文件,并针对
2.ps1
3.ps1
4.ps1

参数文件的参数d:\2.ps1不存在。提供文件d:\2.ps1(2.3.4)的访问路径,该文件作为参数-file的参数存在

文件位于我调用它们的驱动器中,3和4无法执行,因为它们连接到脚本
2.ps1


我不知道在
1.ps1
之后调用
2.ps1
有什么问题,因为它是同一个命令,如果我手动执行文件,它们运行得很好。

尝试这样调用:

PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "d:\1.ps1"

基本上,我要做的是在批处理文件中调用网络使用,1)在2)在每行末尾添加“ok”和“microsoft bla bla”,3)在3)删除每一个空格和每一个空行,4)在请求每行网络使用时添加,并生成一个“mapped drives.bat”“这个等式的结尾示例是:net use x:\\server\drive/persistent yes。bat映射驱动器的名称。bat脚本是否都已签名?或者换句话说,为什么要将RemoteSigned指定为执行策略?不确定这是否与您的问题有关,因为错误消息暗示powershell无法打开2.ps1文件。只是问一下。即使我去掉了远程签名,也会给我同样的错误吗?我不知道为什么。当你把所有路径都用双引号括起来时会发生什么?比如说<代码>-文件“D:\2.ps1”您的powershell脚本的真实名称和路径是什么?因为,老实说,在现实世界中,没有头脑清醒的人会用一位数的名字来创建脚本。