-
Notifications
You must be signed in to change notification settings - Fork 481
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
Integrated PowerShell -- Nested ForEach-Object Failing to Concatenate Strings #1846
Comments
Thanks for opening an issue @BinaryInk. Can you please provide your environment information. The easiest way is by pasting this into your Integrated Console: & {"### VSCode version: $(code -v)"; "`n### VSCode extensions:`n$(code --list-extensions --show-versions | Out-String)"; "`n### PSES version: $($pseditor.EditorServicesVersion)"; "`n### PowerShell version:`n$($PSVersionTable | Out-String)"} |
Can you also tell us where the script is located (is it on the file system, a new folder, or put directly into the terminal) and how you executed it (did you press F5 for example?) |
Ah I think I have a way to reproduce this behaviour:
If you press the up key, this gets put into PSReadLine properly and it all works. F5 seems to do this as well... |
Nailed it!
Sorry, sent that out before I left work for the day. I was using the highlight and “run selection” (F8) method as you found out, didn’t think to mention it in my report, my bad!
I was just using VSCode as a scratch pad, so no saved file, just in memory.
I can provide environment information tomorrow if it is still needed.
From: Robert Holt <notifications@github.com>
Sent: Wednesday, April 3, 2019 8:00 PM
To: PowerShell/vscode-powershell <vscode-powershell@noreply.github.com>
Cc: BinaryInk <brady.greenwood@live.com>; Mention <mention@noreply.github.com>
Subject: Re: [PowerShell/vscode-powershell] Integrated PowerShell -- Nested ForEach-Object Failing to Concatenate Strings (#1846)
Ah I think I have a way to reproduce this behaviour:
* Copy program into editor and save
* Highlight all lines
* Press F8
If you press the up key, this gets put into PSReadLine properly and it all works.
F5 seems to do this as well...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1846 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALft_tUKycyXV_wu0zeU3GAOCpAACLjGks5vdU6QgaJpZM4cbms->.
|
If I found this because I was looking to see if anyone suggested that yet because that would then cause the 'selected' code to be highlighted in the terminal. |
Interesting, 1 change makes it work correctly, instead of the string $SearchBaseSuffix = 'ou=Workstations,ou=Machines in Production,dc=xxxx,dc=xxx'
$Departments = -split 'Alpha
Beta
Gamma
Zulu'
$OS = 'Windows 7','Windows 10'
$FormFactors = 'Convertibles','Laptops','Desktops'
$Departments | % {
$currDept = $_
Write-Host $currDept
$OS | % {
$currOS = $_
$FormFactors | % {
$currForm = $_
write-host "ou=$currDept,ou=$currForm,ou=$currOS,$SearchBaseSuffix"
# Get-ADComputer -Filter * -Prop 'Description' -SearchBase "ou=$$currDept,ou=$currForm,ou=$currOS,$SearchBaseSuffix" | ft
}
}
} |
Ah, its caused because, at least on Windows, F8 copies |
Realizing that its an issue of So this is not an issue of the PowerShell extension, but a shortfall in the script to be able to handle different conditions. The best option is probably something along the lines of building the array with separated string elements, or using the |
… or add the |
That's a really great investigation, thanks @msftrncs! |
Issue Type: Bug
Simply put, it's not putting in $currDept (from the first ForEach-Object loop) in the string as expected, except for the last pass. Code and Outputs below.
CODE---------------------
OUTPUTS------------
Integrated Powershell Output (Incorrect):
Expected Output (Tested, Confirmed in a 'regular' PowerShell session within Code and in a separate PowerShell terminal):
Extension version: 1.12.0
VS Code version: Code 1.32.3 (a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4, 2019-03-14T23:43:35.476Z)
OS version: Windows_NT x64 10.0.17763
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: