Line break handling in PowerShell #4805

Closed
opened 2026-01-30 23:56:59 +00:00 by claunia · 2 comments
Owner

Originally created by @simoniscasesensitive on GitHub (Nov 4, 2019).

Environment

Windows 10, PS 6, Windows Terminal.

Win32NT 10.0.18362.0 Microsoft Windows NT 10.0.18362.0
PSVersion 5.1.18362.145
BuildVersion 10.0.18362.145
Windows Terminal version 0.6.2951.0

In addition to trying the ootb PowerShell experience, I've added in a profile matching my SharePoint Online Management Shell shortcut (other than the GUID which I just modified from the standard PS one). Behaviour below replicated in both windows/environments.

{ "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bc}", "name": "SPO PowerShell", "commandline": "powershell.exe -NoExit -Command \"Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking;\" ", "hidden": false },

Steps to reproduce

Fairly simple really, I have a variable assignment in PowerShell that breaks over multiple lines for readability, but PS in Terminal interprets as multiple commands.
I completely accept there may be a simple modification to the way I've been doing it that'll make it work in PS as delivered by Windows terminal. Problem may be sitting between chair and keyboard.

I've tried:
$MyDocs = [environment]::getfolderpath("mydocuments")

`
$Dlls = ("$MyDocs\ISAPI16\05Microsoft.SharePoint.Client.Runtime.dll",
"$MyDocs\ISAPI16\02Microsoft.SharePoint.Client.Publishing.dll",
"$MyDocs\ISAPI16\04Microsoft.SharePoint.Client.Taxonomy.dll",
"$MyDocs\ISAPI16\31Microsoft.SharePoint.Security.dll",
"$MyDocs\ISAPI16\09Microsoft.SharePoint.Client.UserProfiles.dll")'

and with single backticks after each line (edit: as Quotes are designated by backticks, they've been stripped from this code entry, but they were there, and produce the same result
$MyDocs = [environment]::getfolderpath("mydocuments")

$Dlls = ("$MyDocs\ISAPI16\05Microsoft.SharePoint.Client.Runtime.dll",
"$MyDocs\ISAPI16\02Microsoft.SharePoint.Client.Publishing.dll", "$MyDocs\ISAPI16\04Microsoft.SharePoint.Client.Taxonomy.dll",
"$MyDocs\ISAPI16\31Microsoft.SharePoint.Security.dll",`
"$MyDocs\ISAPI16\09Microsoft.SharePoint.Client.UserProfiles.dll")'

Expected behavior

In my regular PowerShell console and in SharePoint Online Management Console it assigns a variable with a collection of paths, which can be iterated through with foreach.

Actual behavior

Interpreted as a series of incomplete commands, 1 per line.

Line breaking bug

Can of course be mitigated by replacing all commands broken over multiple lines with the same commands on a single line, so not P0, but fairly annoying, as I have quite a few, including a giant if() statement

Tags

#PowerShell

Originally created by @simoniscasesensitive on GitHub (Nov 4, 2019). # Environment Windows 10, PS 6, Windows Terminal. Win32NT 10.0.18362.0 Microsoft Windows NT 10.0.18362.0 PSVersion 5.1.18362.145 BuildVersion 10.0.18362.145 Windows Terminal version 0.6.2951.0 In addition to trying the ootb PowerShell experience, I've added in a profile matching my SharePoint Online Management Shell shortcut (other than the GUID which I just modified from the standard PS one). Behaviour below replicated in both windows/environments. `{ "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bc}", "name": "SPO PowerShell", "commandline": "powershell.exe -NoExit -Command \"Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking;\" ", "hidden": false },` # Steps to reproduce Fairly simple really, I have a variable assignment in PowerShell that breaks over multiple lines for readability, but PS in Terminal interprets as multiple commands. I completely accept there may be a simple modification to the way I've been doing it that'll make it work in PS as delivered by Windows terminal. Problem may be sitting between chair and keyboard. I've tried: $MyDocs = [environment]::getfolderpath("mydocuments") ` $Dlls = ("$MyDocs\ISAPI16\05Microsoft.SharePoint.Client.Runtime.dll", "$MyDocs\ISAPI16\02Microsoft.SharePoint.Client.Publishing.dll", "$MyDocs\ISAPI16\04Microsoft.SharePoint.Client.Taxonomy.dll", "$MyDocs\ISAPI16\31Microsoft.SharePoint.Security.dll", "$MyDocs\ISAPI16\09Microsoft.SharePoint.Client.UserProfiles.dll")' and with single backticks after each line (edit: as Quotes are designated by backticks, they've been stripped from this code entry, but they **_were_** there, and produce the same result $MyDocs = [environment]::getfolderpath("mydocuments") `$Dlls = ("$MyDocs\ISAPI16\05Microsoft.SharePoint.Client.Runtime.dll",` "$MyDocs\ISAPI16\02Microsoft.SharePoint.Client.Publishing.dll",` "$MyDocs\ISAPI16\04Microsoft.SharePoint.Client.Taxonomy.dll",` "$MyDocs\ISAPI16\31Microsoft.SharePoint.Security.dll",` "$MyDocs\ISAPI16\09Microsoft.SharePoint.Client.UserProfiles.dll")' # Expected behavior In my regular PowerShell console and in SharePoint Online Management Console it assigns a variable with a collection of paths, which can be iterated through with foreach. # Actual behavior Interpreted as a series of incomplete commands, 1 per line. ![Line breaking bug](https://user-images.githubusercontent.com/25006517/68110657-4f206600-fee5-11e9-8483-3adadd5b16e9.png) Can of course be mitigated by replacing all commands broken over multiple lines with the same commands on a single line, so not P0, but fairly annoying, as I have quite a few, including a giant if() statement # Tags #PowerShell
claunia added the Resolution-Duplicate label 2026-01-30 23:56:59 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 4, 2019):

/dup #1091

@DHowett-MSFT commented on GitHub (Nov 4, 2019): /dup #1091
Author
Owner

@ghost commented on GitHub (Nov 4, 2019):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Nov 4, 2019): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4805