File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
src/PowerShellEditorServices/Session Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,17 @@ public class RemoteFileManager
4747 $filePathName = $_.FullName
4848
4949 # 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
5161
5262 # Notify client for file open.
5363 New-Event -SourceIdentifier PSESRemoteSessionOpenFile -EventArguments @($filePathName, $contentBytes) > $null
@@ -85,7 +95,18 @@ public class RemoteFileManager
8595 [byte[]] $Content
8696 )
8797
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
89110 " ;
90111
91112 #endregion
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public static PSCommand GetDetailsCommand()
5656 {
5757 PSCommand infoCommand = new PSCommand ( ) ;
5858 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 }" ) ;
6060
6161 return infoCommand ;
6262 }
You can’t perform that action at this time.
0 commit comments