Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.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 - Fatal编程技术网

PowerShell远程启动进程';行不通

PowerShell远程启动进程';行不通,powershell,Powershell,我想以“测试”用户的身份在远程服务器上启动一个进程,但它就是不起作用,我也不知道为什么 $PW = convertto-securestring -AsPlainText -Force -String 'XXXX' $CRED = new-object -typename System.Management.Automation.PSCredential -argumentlist "domain\test", $PW $Server = new-pssession -computername

我想以“测试”用户的身份在远程服务器上启动一个进程,但它就是不起作用,我也不知道为什么

$PW = convertto-securestring -AsPlainText -Force -String 'XXXX'
$CRED = new-object -typename System.Management.Automation.PSCredential -argumentlist "domain\test", $PW
$Server = new-pssession -computername ServerName -credential $CRED

Invoke-Command -session $Server -ScriptBlock {
    $APP = "C:\test\app.exe"
    if ((Get-Process -Name app -ErrorAction SilentlyContinue) -eq $null) {
        write-host "not running" 
        Start-Process -FilePath $APP
    }
    else {
        write-host "running"
    }
}

Remove-PSSession $Server
如果我将RDP导入远程服务器并直接运行代码,它将启动应用程序,但如果我使用
Invoke命令
通过计算机运行代码,它不会启动任何东西

我试图通过RDP查看远程服务器上发生的进程,但什么也没发生。该应用程序必须在我在脚本和RDP会话中使用的特定用户“测试”下运行

远程服务器为Win2012R2,PSversion为4.0


我的机器上的PSversion是5.1

您无法使用psremoting启动交互式应用程序。

经过各种测试后,似乎无法通过psremoting启动此应用程序

我的解决办法是

1) 重新启动后,使用PSTools中的“autogon.exe”以所需用户身份登录

2) 计划在用户登录TaskScheduler时运行此应用程序


工作正常。

不得不问,您是否遵循了中列出的说明:是的,首先要做的是启用psremoting。。。。哈哈。。在Powershell之外,使用PStools中的PSRemote在相关服务器/系统上运行应用程序怎么样?也累了,失败了。我认为问题可能在于此应用程序是否支持远程运行或仅在本地运行。您是希望看到应用程序以交互方式运行(例如启动窗口)还是可以非交互方式运行(例如在后台)?