具有Power Shell的远程计算机上的Open .exe

问题描述 投票:0回答:1

我的.exe的位置为C:\ Program Files(x86)\ Intercede \ MyIDDesktop

我想创建脚本以在远程计算机上打开它。

当我执行脚本时:

invoke-command -computername {start-process -filepath C:\Program Files (x86)\Intercede\MYIDDesktop\MYIDDesktop.exe}

我收到参数错误。

我在哪里犯了错误?预先谢谢你。

powershell exe remote-desktop invoke-command
1个回答
3
投票

如果尚未启用PowerShell远程处理,并且您不是远程主机上的管理员,则不能使用Invoke-Command。

如上所述,您尚未提供计算机名称,因此无论如何都将无法使用。

其次,任何带有空格的东西都必须正确引用。有关该主题的报价或其他Web文章,请参见帮助。例如:

Quoting specifics

最后,正如Olaf所指出的,这确实是PowerShell初学者的东西,这意味着您确实应该花一些时间来加速。跳到Youtube并搜索“入门Powershell”,“中间PowerShell”,“高级PowerShell”等...,您将获得许多练习的细节。使用和掌握帮助文件。

无论如何...本质上,您的一行应该是这样的...

Invoke-Command -ComputerName 'SomeRemoteComputerName' -ScriptBlock {Start-Process -filepath 'C:\Program Files (x86)\Intercede\MYIDDesktop\MYIDDesktop.exe'} -Credential 'WhateverCredsNeededIfYourLoggedOnSessionDoesNotHaveAdminPermissionsOnTheRemoteTarget'

get function / cmdlet details

(Get-Command -Name Invoke-Command).Parameters.Keys
Get-help -Name Invoke-Command -Full
Get-help -Name Invoke-Command -Online
Get-help -Name Invoke-Command -Examples

即使有前面提到的,相对于给定的用例,在远程系统上运行“ exe”还有很多,您也没有指定。

© www.soinside.com 2019 - 2024. All rights reserved.