我有两个Powershell脚本可以很好地协同工作:
=IF(ISBLANK(B2),"",CONCATENATE("ABC",TEXT(ROW(1:1),"000000")))
脚本,它接受运行Method
的参数。Invoke-RestMethod
脚本,将参数发送到Caller
。在Method
中,我定义参数并发送它们:
Caller
在$file = "\\Share\Location\STUDENTS.txt"
$username = "d155a9dd-be60-9dcb-9009-02d634192545"
$type = "person"
$operation = "refresh"
& "\\Share\Location\Batch\method.ps1" $file $username $type $operation
中,我回显变量并显示响应,对于以下输出:
Method
到目前为止,这么好。现在,我需要将FILE: \\Share\Location\STUDENTS.txt
USER: d155a9dd-be60-9dcb-9009-02d634192545
TYPE: person
OPER: refresh
Success: Feed File Uploaded. Use the reference code 53a7c62c7f4a412889af3b15d712525b to track these records in the logs.
改为Windows批处理文件,以便在调用Caller
时绕过执行策略。我无法使用Method
参数,因为Windows 10在命令行中不支持UNC路径,所以我改为使用-File
参数:
-Command
但我从THAT脚本得到的输出是:
@ECHO OFF
SET feedfile='\\Share\Location\STUDENTS.txt'
SET integration='d155a9dd-be60-9dcb-9009-02d634192545'
SET datatype='person'
SET action='refresh'
SET pscommand="& '\\Share\Location\Batch\method.ps1' %feedfile% %integration% %datatype% %action%"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command %pscommand%
在任何一种情况下都会发送相同的Web请求 - 它与批处理文件一起失败,但与Powershell脚本完美配合。问题是什么?