-
Notifications
You must be signed in to change notification settings - Fork 235
fix *-Content calls in psedit scripts and set ComputerName default #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ public static PSCommand GetDetailsCommand() | |
{ | ||
PSCommand infoCommand = new PSCommand(); | ||
infoCommand.AddScript( | ||
"@{ 'computerName' = $env:ComputerName; 'processId' = $PID; 'instanceId' = $host.InstanceId }"); | ||
"@{ 'computerName' = if ($ExecutionContext.Host.Runspace.ConnectionInfo) {$ExecutionContext.Host.Runspace.ConnectionInfo.ComputerName} else {'localhost'}; 'processId' = $PID; 'instanceId' = $host.InstanceId }"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When connected to a remote session on Linux or macOS, does ComputerName contain anything? Aside from that I think this change is fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, when I tested on linux I could include a check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a remote session to a Linux machine ConnectionInfo was null? Pretty unfortunate if so, though I suppose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure the only time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about if ([string]::IsNullOrWhitespace([Environment]::MachineName)) {
'localhost'
} else {
[Environment]::MachineName
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@daviwil I thought PSRP in vscode-powershell wasn't allowed in PS 3 and 4? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remoting works in PS4, but we should make sure that it works on the local machine for PS3/4 too. Though if it works in PS 5.1, I would assume it works in PS 3/4 too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PS 3/4 have Let's go with that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I changed it to |
||
|
||
return infoCommand; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be a bit more performant (and PS canonical IMO) to do this:
$params['AsByteStream']=$true
. This way we modify the original hashtable without creating a new to merge with the original one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated 🙂