@@ -67,6 +67,13 @@ $global:EphemeralTrustedServers = @()
67
67
$global :LocalStoragePath = " HKCU:\SOFTWARE\PowerRemoteDesktop_Viewer"
68
68
$global :LocalStoragePath_TrustedServers = -join ($global :LocalStoragePath , " \TrustedServers" )
69
69
70
+ enum ClipboardMode {
71
+ Disabled = 1
72
+ Receive = 2
73
+ Send = 3
74
+ Both = 4
75
+ }
76
+
70
77
function Write-Banner
71
78
{
72
79
<#
@@ -1152,6 +1159,9 @@ $global:IngressEventScriptBlock = {
1152
1159
1153
1160
" ClipboardUpdated"
1154
1161
{
1162
+ if ($Param.Clipboard -eq " Disabled" -or $Param.Clipboard -eq " Send" )
1163
+ { continue }
1164
+
1155
1165
if (-not ($aEvent.PSobject.Properties.name -match " Text" ))
1156
1166
{ continue }
1157
1167
@@ -1226,7 +1236,7 @@ $global:EgressEventScriptBlock = {
1226
1236
{
1227
1237
$eventTriggered = $false
1228
1238
1229
- if ($Param.SynchronizeClipboard )
1239
+ if ($Param.Clipboard -eq " Both " -or $Param .Clipboard -eq " Send " )
1230
1240
{
1231
1241
# IDEA: Check for existing clipboard change event or implement a custom clipboard
1232
1242
# change detector using "WM_CLIPBOARDUPDATE" for example (WITHOUT INLINE C#)
@@ -1401,9 +1411,12 @@ function Invoke-RemoteDesktopViewer
1401
1411
. PARAMETER DisableVerbosity
1402
1412
Disable verbosity (not recommended)
1403
1413
1404
- . PARAMETER DisableClipboard
1405
- This option disable Clipboard synchronization with remote peer. By default Clipboard synchronization
1406
- is enabled and will synchronize only if both Viewer and Server have Clipboard synchronization enabled.
1414
+ . PARAMETER Clipboard
1415
+ Define clipboard synchronization rules:
1416
+ - "Disabled": Completely disable clipboard synchronization.
1417
+ - "Receive": Update local clipboard with remote clipboard only.
1418
+ - "Send": Send local clipboard to remote peer.
1419
+ - "Both": Clipboards are fully synchronized between Viewer and Server.
1407
1420
1408
1421
. EXAMPLE
1409
1422
Invoke-RemoteDesktopViewer -ServerAddress "192.168.0.10" -ServerPort "2801" -SecurePassword (ConvertTo-SecureString -String "s3cr3t!" -AsPlainText -Force)
@@ -1421,7 +1434,7 @@ function Invoke-RemoteDesktopViewer
1421
1434
[String ] $Password ,
1422
1435
1423
1436
[switch ] $DisableVerbosity ,
1424
- [switch ] $DisableClipboard
1437
+ [ClipboardMode ] $Clipboard = " Both "
1425
1438
)
1426
1439
1427
1440
[System.Collections.Generic.List [PSCustomObject ]]$runspaces = @ ()
@@ -1819,6 +1832,7 @@ function Invoke-RemoteDesktopViewer
1819
1832
$param = New-Object - TypeName PSCustomObject - Property @ {
1820
1833
Client = $session.ClientEvents
1821
1834
VirtualDesktopSyncHash = $virtualDesktopSyncHash
1835
+ Clipboard = $Clipboard
1822
1836
}
1823
1837
1824
1838
$newRunspace = (New-RunSpace - ScriptBlock $global :IngressEventScriptBlock - Param $param )
@@ -1829,7 +1843,7 @@ function Invoke-RemoteDesktopViewer
1829
1843
1830
1844
$param = New-Object - TypeName PSCustomObject - Property @ {
1831
1845
OutputEventSyncHash = $outputEventSyncHash
1832
- SynchronizeClipboard = -not $DisableClipboard
1846
+ Clipboard = $Clipboard
1833
1847
}
1834
1848
1835
1849
$newRunspace = (New-RunSpace - ScriptBlock $global :EgressEventScriptBlock - Param $param )
0 commit comments