问题描述
我正在尝试使用名为 adobe-licensing-toolkit.exe 的 adobe 工具生成一些 ID。 我需要在 100 台计算机上远程运行命令。 手动执行命令完美无缺
C:\temp\adobe-licensing-toolkit.exe -c -f \\XXXXXXX\c$\temp\IDs.csv
Adobe Licensing Toolkit (1.1.0.98)
Operation Successfully Completed
现在我尝试使用远程 PS 复制它,但没有成功。我觉得是参数问题。
Invoke-Command -ComputerName $comp -ScriptBlock { param($whatTodo,$targetCSV) &('C:\TEMP\adobe-licensing-toolkit.exe') --$whatTodo --$targetCSV "C:\temp\ID.csv"} -ArgumentList "generateChallengeKey","filepath"
如果我尝试在参数中使用UNC,结果是Operation Failed。
Invoke-Command -ComputerName $comp -ScriptBlock { param($whatTodo,$targetCSV) &('\\XXXXXXXX\c$\TEMP\adobe-licensing-toolkit.exe') --$whatTodo --$targetCSV "C:\temp\ID.csv"} -ArgumentList "generateChallengeKey","filepath"
我也尝试在参数中添加路径。在这种情况下,powershell 会抱怨。
Invoke-Command -Session $Server01 -ScriptBlock { param($whatTodo,$targetCSV) &('C:\TEMP\FRL\adobe-licensing-toolkit.exe') --$whatTodo --$targetCSV } -ArgumentList @("generateChallengeKey","filepath \\XXXXXXX\c$\temp\ID.csv")
unkNown option -- filepath \\XXXXX\c$\temp\ID.csv
+ CategoryInfo : NotSpecified: (unkNown option ...c$\temp\ID.csv:String) [],remoteexception
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : XXXXXXX
我感觉问题出在参数传递的方式上,但我还没有找到解决方案。
exe 文件已存在于所有目标计算机中。
有什么建议吗?
谢谢
解决方法
我假设您在路径中的所有远程计算机中都有工具包:“C:\TEMP\adobe-licensing-toolkit.exe”。你可以简单地使用
Invoke-Command -ComputerName $comp -ScriptBlock { & "C:\TEMP\adobe-licensing-toolkit.exe" -c -f \\XXXXX\$env:Computername-IDs.csv}
在共享路径中添加 $env:Computername 将为每台计算机生成唯一的文件。