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
STDOUT/STDIN buffer size error when passing arguments into Windows PowerShell #14775
Comments
|
Unlike the CMD prompt, PowerShell doesn't automatically Expand Environmental Variables which leaves an invalid json file. This means that you will need to explicitly expand the In other works, your long/complex json configuration works fine for me when it is first expanded: $configuration = Get-Content .\configuration.json | ConvertFrom-Json
$configuration = [System.Environment]::ExpandEnvironmentVariables($configuration)
$block = {param([pscustomobject]$inputArgument) $PSVersionTable; Write-Host ('Test ' + $inputArgument.AxisUser.Name)}
powershell -nologo -noprofile $block -Args $configuration |
|
@iRon7 Thx for explanation! This will solve my main problem. The question is if PowerShell should or should not have the same behaviour here. |
Since Windows PowerShell, PowerShell Core has undergone quiet some changes along with the NewtonSoft JSON engine (see e.g.: PowerShell 7 Changes to JSON Cmdlets, this shows in minor discrepancies along with the error descriptions. |
|
Oh, I see... Make sense. The only thing which is a mystery to me is why PowerShell does not protest about the configuration JSON file until the JSON reaches some particular level (size). |
|
I need to correct my initial answer a bit as you (obviously) will need to expand the environment variables prior the $configuration = Get-Content .\configuration.json
$configuration = [System.Environment]::ExpandEnvironmentVariables($configuration) | ConvertFrom-Json
$block = {param([pscustomobject]$inputArgument) $PSVersionTable; Write-Host 'Test ' $inputArgument.AxisUser.Name}
powershell -nologo -noprofile $block -Args $configurationBut as you will see this will fail at the second statement, with:
And this is because |
|
Besides, why using the $configuration = Get-Content .\configuration.json | ConvertFrom-Json
$block = {$PSVersionTable; Write-Host 'Test' $Input.ProductNameUser.Name}
# powershell -nologo -noprofile $block -Args $configuration
Invoke-Command $Block -InputObject $configuration
Name Value
---- -----
PSVersion 7.1.1
PSEdition Core
GitCommitId 7.1.1
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Test String from json |
|
I have to redirect to Windows PowerShell. In addition, even after I expand the environmental variables in the JSON string, the problem with redirection to Windows PowerShell remains. |
|
It looks like this problem has nothing to do with the environmental variables in the JSON. I just used a JSON with no environmental variables with the same results. |
|
Agree, I guess it has something to do with the STDOUT/STDIN buffer size and leave it to the PowerShell guys to answer... A Minimal, Reproducible Example of this issue would be: powershell {''} -Args ('x' * 100000)Results in an error:
(Where the error doesn't appear with smaller strings, e.g.: |
|
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
2 similar comments
|
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
|
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
|
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |


This issue is partially an issue of Windows PowerShell and PowerShell.
When I try pass a PSCustomObject loaded from JSON from PowerShell into Windows PowerShell, it will fail once JSON pass a certain size level.
PowerShell 7.1.1 and Windows PowerShell throw different errors and passing through of PSCustomObject argument doesn't work from properly. It depends on the argument size or complexity, see this screenshot.
The problem disappears when I remove any two subkeys from
root\WebAppin the configuration JSON.Steps to reproduce
For a minimal, reproducible example, see this comment. When I debug the PS run, it pointed me to STDOUT/STDIN buffer size too.
Expected behavior
Windows PowerShell
PowerShell 7.1.1
Actual behavior
Windows PowerShell
PowerShell 7.1.1
Environment data
Configuration JSON
{ "SupportedPSVersion": "7.1.0", "Localhost": true, "SourceCodeLocalPath": "%USERPROFILE%\\source\\CompanyName\\ProductName\\", "AzureDevOpsUser": { "Name": "", "Password": "" }, "VPNUserName": "John.Doe", "ProductNameUser": { "Name": "String from json", "FullName": "ProductName DEV user", "Password": "123456", "Group": "Department" }, "NetworkHost": "0.0.0.0", "AppPool": { "Name": "ProductName" }, "Website": [ { "Name": "ProductNameWeb", "Port": 1810, "ApplicationPool": "ProductName", "BindingInformation": "*:1810:", "Id": 2, "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot", "SelfSignedCertificatePassword": "WithGreatPowerComesGreatResponsibility" }, { "Name": "ProductNameApp", "Port": 1985, "ApplicationPool": "ProductName", "BindingInformation": "*:1985:", "Id": 3, "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot" } ], "FrontendWebsiteId": 2, "BackendWebsiteId": 3, "FrontendEndpointToSubstitude": "ProductNamev2devweb1.ProductNamegraphics.tv", "BackendEndpointToSubstitude": "ProductNamev2devapp1.ProductNamegraphics.tv", "WebApp": { "Portal": { "FilePathToConfig": "%USERPROFILE%\\source\\CompanyName\\ProductName\\portal\\CompanyName.Portal.Web\\Root.Web.Release-Dev.config", "TargetAbsolutePathToConfig": "%SystemDrive%\\inetpub\\wwwroot\\Web.config", "ProjectsToPublish": [ { "RelativeProjectPath": "portal\\CompanyName.Portal.Web\\CompanyName.Portal.Web.csproj", "RelativePublishProfilePath": "portal\\CompanyName.Portal.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" }, { "RelativeProjectPath": "portal\\CompanyName.Portal.API\\CompanyName.Portal.API.csproj", "RelativePublishProfilePath": "portal\\CompanyName.Portal.API\\Properties\\PublishProfiles\\FolderProfile.pubxml" }, { "RelativeProjectPath": "portal\\CompanyName.Portal.Application.WebService\\CompanyName.Portal.Application.WebService.csproj", "RelativePublishProfilePath": "portal\\CompanyName.Portal.Application.WebService\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [], "AppToCreateOnFrontendWebsite": [ { "Name": "Portal", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Portal" }, { "Name": "PortalApi", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\PortalApi" } ], "AppToCreateOnBackendWebsite": [ { "Name": "Portal", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\CompanyName.Portal.Application.WebService" } ], "HomePageFiles": { "TargetWebApplication": "Portal", "Name": "HomePageFiles", "PhysicalPath": "\\\\0.0.0.0\\pogo\\ProductNamev2\\dev\\Portal\\HomePageFiles" } }, "Track": { "ProjectsToPublish": [ { "RelativeProjectPath": "track\\CompanyName.Track.Web\\CompanyName.Track.Web.csproj", "RelativePublishProfilePath": "track\\CompanyName.Track.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" }, { "RelativeProjectPath": "track\\CompanyName.Track.Api\\CompanyName.Track.Api.csproj", "RelativePublishProfilePath": "track\\CompanyName.Track.Api\\Properties\\PublishProfiles\\FolderProfile.pubxml" }, { "RelativeProjectPath": "track\\CompanyName.Track.WebService\\CompanyName.Track.WebService.csproj", "RelativePublishProfilePath": "track\\CompanyName.Track.WebService\\Properties\\PublishProfiles\\FolderProfile.pubxml" }, { "RelativeProjectPath": "track\\CompanyName.Track.ConfigurationDomain\\CompanyName.Track.ConfigurationDomain.csproj", "RelativePublishProfilePath": "track\\CompanyName.Track.ConfigurationDomain\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [ { "RelativePublishProfilePath": "track\\CompanyName.Track.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "bin\\Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\bin" }, { "RelativePublishProfilePath": "track\\CompanyName.Track.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\Shared" } ], "AppToCreateOnFrontendWebsite": [ { "Name": "Track", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Track" }, { "Name": "TrackApi", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\CompanyName.Track.Api" }, { "Name": "ConfigurationDomain", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\CompanyName.Track.ConfigurationDomain" } ], "AppToCreateOnBackendWebsite": [ { "Name": "Track", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\CompanyName.Track.WebService" } ], "Cache": { "LocalFolderPath": "%SystemDrive%\\inetpub\\wwwroot\\TrackCache", "Name": "TrackCache\\Cache", "PhysicalPath": "\\\\1.1.1.1\\pogo\\ProductNamev2\\dev\\track" }, "VueJS": { "RelativeSourcePath": "track\\CompanyName.Track.Web\\", "RelativeBuildPath": "track\\CompanyName.Track.Web\\src\\build", "Destination": "%SystemDrive%\\inetpub\\wwwroot\\Track\\src\\" } }, "ProductNameAPI": { "ProjectsToPublish": [ { "RelativeProjectPath": "ProductNameapi\\ProductNameAPI\\ProductNameAPI.csproj", "RelativePublishProfilePath": "ProductNameapi\\ProductNameAPI\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [], "AppToCreateOnFrontendWebsite": [ { "Name": "ProductNameApi", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\ProductNameApi" } ], "AppToCreateOnBackendWebsite": [] }, "Compose": { "ProjectsToPublish": [ { "RelativeProjectPath": "compose\\CompanyName.Compose.Web\\CompanyName.Compose.Web.csproj", "RelativePublishProfilePath": "compose\\CompanyName.Compose.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [ { "RelativePublishProfilePath": "compose\\CompanyName.Compose.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "bin\\Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\bin" } ], "AppToCreateOnFrontendWebsite": [ { "Name": "Compose", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Compose" } ], "AppToCreateOnBackendWebsite": [] }, "Charts": { "ProjectsToPublish": [ { "RelativeProjectPath": "charts\\CompanyName.Charts.Web\\CompanyName.Charts.Web.csproj", "RelativePublishProfilePath": "charts\\CompanyName.Charts.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [ { "RelativePublishProfilePath": "charts\\CompanyName.Charts.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "bin\\Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\bin" } ], "AppToCreateOnFrontendWebsite": [ { "Name": "Charts", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Charts" } ], "AppToCreateOnBackendWebsite": [], "VueJS": { "RelativeSourcePath": "charts\\CompanyName.Charts.Web\\", "RelativeBuildPath": "charts\\CompanyName.Charts.Web\\src\\build", "Destination": "%SystemDrive%\\inetpub\\wwwroot\\Charts\\src\\" } }, "Order": { "ProjectsToPublish": [ { "RelativeProjectPath": "order\\CompanyName.Order.Web\\CompanyName.Order.Web.csproj", "RelativePublishProfilePath": "order\\CompanyName.Order.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [ { "RelativePublishProfilePath": "order\\CompanyName.Order.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "bin\\Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\bin" } ], "AppToCreateOnFrontendWebsite": [ { "Name": "Order", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Order" } ], "AppToCreateOnBackendWebsite": [], "MediaFormatImages": { "LocalFolderPath": "%SystemDrive%\\inetpub\\wwwroot\\MediaFormatImages", "Name": "MediaFormatImages", "PhysicalPath": "\\\\1.1.1.1\\pogo\\ProductNamev2\\dev\\Order\\MediaFormatImages" } }, "Typefaces": { "ProjectsToPublish": [ { "RelativeProjectPath": "typefaces\\CompanyName.Typefaces.Web\\CompanyName.Typefaces.Web.csproj", "RelativePublishProfilePath": "typefaces\\CompanyName.Typefaces.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [ { "RelativePublishProfilePath": "typefaces\\CompanyName.Typefaces.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "bin\\Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\bin" } ], "AppToCreateOnFrontendWebsite": [ { "Name": "Typefaces", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Typefaces" } ], "AppToCreateOnBackendWebsite": [] }, "Transport": { "ProjectsToPublish": [ { "RelativeProjectPath": "transport\\CompanyName.Transport.Web\\CompanyName.Transport.Web.csproj", "RelativePublishProfilePath": "transport\\CompanyName.Transport.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml" } ], "SymbolicLinkToCreate": [ { "RelativePublishProfilePath": "transport\\CompanyName.Transport.Web\\Properties\\PublishProfiles\\FolderProfile.pubxml", "TargetRelativePath": "bin\\Shared", "SourcePath": "%SystemDrive%\\inetpub\\wwwroot\\Portal\\bin" } ], "AppToCreateOnFrontendWebsite": [ { "Name": "Transport", "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot\\Transport" } ], "AppToCreateOnBackendWebsite": [] } }, "NuGet": { "RestoreProjectForAzureCredentialManager": "%USERPROFILE%\\source\\CompanyName\\ProductName\\portal\\CompanyName.Portal.Web\\CompanyName.Portal.Web.csproj" } }The text was updated successfully, but these errors were encountered: