Link to home
Start Free TrialLog in
Avatar of DBThomson76
DBThomson76Flag for United States of America

asked on

Windows Form on Remote Computer

Is it possible to have a Windows Form sent to a remoter computer?

This is the code that I was able to put together that show a form on my computer. I am trying to figure out how (if possible to send this to a remote computer:

Add-Type -AssemblyName System.Windows.Forms

$Form = New-Object system.Windows.Forms.Form

$Form.Text = "Reboot Message"

$Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")

$Form.Icon = $Icon

$Form.AutoSize = $True

$Form.AutoSizeMode = "GrowAndShrink"
    # or GrowOnly

#$Form.AutoScroll = $True

$Form.BackColor = "Red"
    # color names are static properties of System.Drawing.Color
    # you can also use ARGB values, such as "#FFFFEBCD"

#$Form.Opacity = 0.7
    # 1.0 is fully opaque; 0.0 is invisible

$Form.StartPosition = "CenterScreen"
    # CenterScreen, Manual, WindowsDefaultLocation, WindowsDefaultBounds, CenterParent

$Font = New-Object System.Drawing.Font("Times New Roman",24,[System.Drawing.FontStyle]::Italic)
    # Font styles are: Regular, Bold, Italic, Underline, Strikeout

$Form.Font = $Font

$Label = New-Object System.Windows.Forms.Label

$Label.Text = "Please reboot your computer at your earliest convenience, Thank you!"

$Label.AutoSize = $True

$Form.Controls.Add($Label)

$Form.ShowDialog()


TIA!
SOLUTION
Avatar of Hello There
Hello There

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DBThomson76

ASKER

I did find that one but I was hoping to be able to use Windows Forms as I included in my original message.

Please let me know if it is not possible to use PowerShell to run this Windows Form to a remote computer.

Thank you!
you could invoke-command on the remote computer.
i.e. Invoke-Command -Computername $RemoteComputer -ScriptBlock { Get-ChildItem "C:\Program Files" }


ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hello There
Hello There

The author closes the question by selecting one or more answers as solutions or helpful posts.
Do not mark your comment as the solution, mark the post that actually helped you. This will help someone in the future to see the solution. Thanks.