Remote Powershell popup message

怎甘沉沦 提交于 2019-12-08 05:28:21

问题


I'm attempting to create a remote powershell popup window to any users logged into a target computer.

I have found a simple script that does create a popup window:

(New-Object -ComObject wscript.shell).popup("THIS IS A TEST MESSAGE")

However, I cannot run this script on remote devices. We have powershell remoting restricted in our environment so I cannot use the invoke-command cmdlet in powershell.

I have bypassed this restriction in the past by using the Invoke-WmiMethod cmdlet and creating a new process remotely to achieve the desired results, like such:

Invoke-WmiMethod -Class Win32_Process -ComputerName $computer -Name Create -ArgumentList "C:\Program Files\Test\Test.exe -argument"

However, I cannot seem to find a way to generate a remote popup window using this method.

Does anybody have any great ideas on how I can accomplish my goal?


回答1:


I figured this out. I used the msg.exe application to display my message and used powershell Invoke-WmiMethod to execute the command locally on the PC as we have remote messaging disabled:

Invoke-WmiMethod -Class Win32_Process -ComputerName HostPC -Name Create -ArgumentList "C:\Windows\System32\msg.exe * This is a test message."



回答2:


I edited the script samples above with Powershell to make it easier to run with variables so you don't have to edit the file every time.

$server = read-host -prompt 'Input server name';
$message = read-host -prompt 'add text string'; 
Invoke-WmiMethod -Class win32_process -ComputerName $server -Name create -ArgumentList  "c:\windows\system32\msg.exe * $message" 

Thanks to Maumee River for the original answer



来源:https://stackoverflow.com/questions/29013411/remote-powershell-popup-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!