Powershell在PSSession中使用Start-Process打开记事本 [英] Powershell Using Start-Process in PSSession to Open Notepad

查看:246
本文介绍了Powershell在PSSession中使用Start-Process打开记事本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在远程计算机上创建了一个pssession并输入了该财产.在该会话中,我使用启动过程来启动记事本.我可以使用get-process命令以及远程计算机中的taskmgr确认记事本正在运行.但是,该过程的GUI端未显示.这是我一直在使用的顺序:

I've created a pssession on a remote computer and entered that possession. From within that session I use start-process to start notepad. I can confirm that notepad is running with the get-process command, and also with taskmgr in the remote computer. However, the GUI side of the process isn't showing. This is the sequence I've been using:

$server = New-PSSession -ComputerName myserver -Credential mycreds
Enter-PSSession $server

[$server]: PS C:\>Start-Process notepad -Wait -WindowStyle Maximized

该进程正在运行,但是当RDP进入框时,记事本无法打开.如果我从服务器打开记事本,则将开始一个新的记事本过程.我也尝试使用这样的动词参数:

The process is running, but while RDP'd to the box, notepad does not open. If I open notepad from the server, a new notepad process begins. I also tried by using the verb parameter like this:

[$server]: PS C:\>Start-Process notepad -Wait -WindowStyle Maximized -Verb Open

与结果相同...过程开始,但是没有显示记事本.我已经尝试过将它远程放置到盒子中(但是是从我的本地主机发出的),以及在移入服务器之前尝试过的.

Same result tho... Process starts, but no notepad shows. I've tried this while remoted into the box (but issued from my local host) as well as before remoting into the server.

推荐答案

这是因为您在远程计算机上的Powershell会话不会转到任何可见的桌面,而是转到不可见的系统桌面. Powershell远程会话的接收端是Windows服务.该过程已启动,但是您或其他任何人都看不到它.

That is because your powershell session on the remote machine does not go to any visible desktop, but to an invisible system desktop. The receiving end of your powershell remote session is a Windows service. The process is started, but nor you nor anyone else can ever see it.

如果考虑一下,由于多个用户可以RDP到同一台计算机,因此实际上没有理由假设远程Powershell会话最终会显示在任何用户桌面上.实际上,几乎在所有情况下您都不会想要它.

And if you think about it, since multiple users could RDP to the same machine, there is really no reason to assume a remote powershell session would end up showing on any of the users desktops. Actually, in almost all cases you wouldn't want it anyway.

psexec 可以执行您的操作需要,但您必须指定要显示在哪个会话(用户)中.

psexec with the -i parameter is able to do what you want, but you have to specify which of the sessions (users) you want it to show up in.

这篇关于Powershell在PSSession中使用Start-Process打开记事本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆