File tree 2 files changed +24
-3
lines changed
src/PowerShellEditorServices/Session
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,17 @@ public class RemoteFileManager
47
47
$filePathName = $_.FullName
48
48
49
49
# Get file contents
50
- $contentBytes = Get-Content -Path $filePathName -Raw -Encoding Byte
50
+ $params = @{ Path=$filePathName; Raw=$true }
51
+ if ($PSVersionTable.PSEdition -eq 'Core')
52
+ {
53
+ $params['AsByteStream']=$true
54
+ }
55
+ else
56
+ {
57
+ $params['Encoding']='Byte'
58
+ }
59
+
60
+ $contentBytes = Get-Content @params
51
61
52
62
# Notify client for file open.
53
63
New-Event -SourceIdentifier PSESRemoteSessionOpenFile -EventArguments @($filePathName, $contentBytes) > $null
@@ -85,7 +95,18 @@ public class RemoteFileManager
85
95
[byte[]] $Content
86
96
)
87
97
88
- Set-Content -Path $RemoteFilePath -Value $Content -Encoding Byte -Force 2>&1
98
+ # Set file contents
99
+ $params = @{ Path=$RemoteFilePath; Value=$Content; Force=$true }
100
+ if ($PSVersionTable.PSEdition -eq 'Core')
101
+ {
102
+ $params['AsByteStream']=$true
103
+ }
104
+ else
105
+ {
106
+ $params['Encoding']='Byte'
107
+ }
108
+
109
+ Set-Content @params 2>&1
89
110
" ;
90
111
91
112
#endregion
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public static PSCommand GetDetailsCommand()
56
56
{
57
57
PSCommand infoCommand = new PSCommand ( ) ;
58
58
infoCommand . AddScript (
59
- "@{ 'computerName' = $env:ComputerName ; 'processId' = $PID; 'instanceId' = $host.InstanceId }" ) ;
59
+ "@{ 'computerName' = if ([Environment]::MachineName) {[Environment]::MachineName} else {'localhost'} ; 'processId' = $PID; 'instanceId' = $host.InstanceId }" ) ;
60
60
61
61
return infoCommand ;
62
62
}
You can’t perform that action at this time.
0 commit comments