I was working next to someone the other day, and there were two monitors connected to each PC, and he had just dragged a script from his right monitor to the left to read. It occurred to me that it would be handy to have a grid-connected view of desktops/monitors, and you could essentially drag and drop windows between computers.
Needless to say this probably isn't going to be achievable in 10 lines of powershell script, but as a version 0.01 of the concept, this script will take a file and a computer as parameters, and copy the file remotely and start notepad on the interactive desktop of the remote machine.
param (
$file = "",
$computer = ""
)
#
# 30/05/2008, Wayne Martin, Initial version
#
# Description:
# Poke a file into a notepad.exe process in the interactive desktop on a remote machine.
#
# Assumptions, this script works on the assumption that:
# psexec.exe is available on the host
# the account running the powershell script has administrative access to the remote computer
# WMI is accessible on the remote machine (queries remote temp directory and windir)
#
# Usage
# Copy a text file to a remote machine and start notepad on the interactive desktop
# . .\PokeInfo.ps1 -f textfile.txt -m RemoteMachine1
#
# Notes
# psexec.exe is required on the host
# This could also be achieved by using win32_Schedulejob interactive now+1, but this assumes schedule is running on the remote machine and time is synchronised
#
# References:
# http://blogs.msdn.com/powershell/archive/2007/01/16/managing-processes-in-powershell.aspx
#
write-output ("Copying and remotely loading " + $file + " on " + $computer)
$envTemp = (get-WMIObject -computerName $computer -class win32_environment -property VariableValue -filter "Name='Temp' AND SystemVariable=True").VariableValue
$windir = (get-WMIObject -computerName $computer -class win32_operatingsystem -property WindowsDirectory).WindowsDirectory
$tempfile = [System.IO.Path]::GetRandomFileName()
$localDest = $envTemp.Replace("%SystemRoot%", $windir) + "\" + $tempfile
$UNCDest = "\\" + $computer + "\" + $localDest.Replace(":", "$")
copy-item -path $file -dest $UNCdest
$cmd = "\\" + $computer + " /i /d notepad " + $localdest
write-output ("Running " + $cmd)
[diagnostics.process]::start("psexec.exe", "$cmd")
Wayne's World of IT (WWoIT), Copyright 2008 Wayne Martin.
Read more!