I've lost a handful of hair today trying to figure out the best way to grab the data from the clipboard on a remote server. I thought simply:
$cred = New-Object System.Management.Automation.PSCredential('USERNAME', $password);
Invoke-Command -ComputerName 'theFQDN' -Credential $cred -ScriptBlock {
Get-Clipboard
}
would do the trick but it's always null and nothing is returned, no errors. I've tried doing with commandline:
$cred = New-Object System.Management.Automation.PSCredential('USERNAME', $password);
Invoke-Command -ComputerName 'theFQDN' -Credential $cred -ScriptBlock {
cmd.exe /c "powershell Get-Clipboard"
}
Manually, it works fine and dandy, but passing it through Invoke-Command
returns nothing and I've most certainly confirmed it has data in the clipboard.
Any help is appreciated.
ADDENDUM (after realizing this might be more complicated than originally thought):
The whole process is that an app will automatically copy some string to clipboard on a remote server. I need to grab that data off the clipboard and was hoping the Invoke-Command
would do it for me.