Skip to content

Test-DscConfiguration not returning value in Powershell Integrated Console #2953

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

Closed
marvelcz89 opened this issue Sep 15, 2020 · 8 comments
Closed

Comments

@marvelcz89
Copy link

marvelcz89 commented Sep 15, 2020

Issue Description

Invoking Test-DscConfiguration does not return value when invoked for the first time in session in Powershell Integrated Console and also a few seconds afterwards.
The functionality is restored after several seconds after first Test-DscConfiguration call but the initial queries are already faulty..
Here is the screenshot of the behavior: https://gyazo.com/4e3696d65e3e0de34cb2cdf6a9680bf6

No faults when used in regular VS Code terminal, ISE, or directly invoking the .EXE

I was able to replicate the issue on a freshly installed VM both W10 1909 and WS 2016 1909 + VS Code 1.49 and Powershell Extension 2020.6.0 for PS versions 5.1 and 7.0.3

EDIT1: Additional information

  1. Saving to a variable does not provide result: https://gyazo.com/8564392a43a0fb6d977da0cb5d14cef1
  2. Invoking with -Verbose works consistently, might be related why i can not reproduce with Diagnostic log mode: https://gyazo.com/eceda3d54e84ce2ca9076f5269a3a321
  3. Invoking with -Verbose and redirecting verbose output does not work as workaround: https://gyazo.com/f82b2db98a2b81d37821b543a1cf3d0e

EDIT2: Additional information
I have added additional behaviour examples in posts below.

Workaround

I added following configuration to avoid using Integrated console:

  1. "powershell.integratedConsole.showOnStartup": false
  2. "terminal.integrated.shell.windows": "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe"
    or
  3. "terminal.integrated.shell.windows": "C:\Program Files\PowerShell\7\pwsh.exe"

Attached Logs

The issue not occuring with Diagnostics mode for some reason :(

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.18363
VSCode 1.49.0
PowerShell Extension Version 2020.6.0

PowerShell Information

Name Value
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0 6.1.0 6.2.0 7.0.3
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
bracket-pair-colorizer-2 CoenraadS 0.2.0
gc-excelviewer GrapeCity 3.0.40
gitlens eamodio 10.2.2
powershell ms-vscode 2020.6.0
rainbow-csv mechatroner 1.7.1
reg ionutvmi 1.0.1
team ms-vsts 1.161.0
vscode-icons vscode-icons-team 10.2.0
xml DotJoshJohnson 2.5.1
@ghost ghost added the Needs: Triage Maintainer attention needed! label Sep 15, 2020
@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented Sep 15, 2020

@marvelcz89 thanks for the info-- I wonder if you assign it to a variable if you are able to retrieve a result i.e. maybe the command is being returned but not printed properly?
Also would be great if this also occurs with any other command ex. $true

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Sep 15, 2020
@marvelcz89
Copy link
Author

@SydneyhSmith I have added some additional information to EDIT1.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 15, 2020
@SydneyhSmith
Copy link
Collaborator

Thanks @marvelcz89 that is very helpful-- it would be great if you tried this one again with a slight variation: Saving to a variable does not provide result: https://gyazo.com/8564392a43a0fb6d977da0cb5d14cef1
Could you please run the first line again, and then after that just run $test for the next 2-4 times.

$test = Test-DSCConfiguration 
$test 

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 22, 2020
@marvelcz89
Copy link
Author

Hello @SydneyhSmith
Wall of text incomming with more examples. Every example was executed in fresh powershell integrated terminal, and multiple times to ensure consistency. The examples below were done in Powershell 5.1.18362.145 i am not including tests from PS Core 7.0 where i found the same issue as well.

Additional example 1 code:
$Test = Test-DscConfiguration
and then
$Test

Additional example 1 result:
Returned value correctly: https://gyazo.com/88242a1bc34210ff944e910a0748b5f6

Additional example 2 code:

$Test = Test-DscConfiguration 
$Test

Additional example 2 result:
Expected result is TRUE but nothing is returned: https://gyazo.com/f51f1d9543db83106f69e2a0a6f03a76

Additional example 3 code:

$Test = Test-DscConfiguration
$Test
$Test
$Test
$Test
$Test

Additional example 3 result:
During about a dozen of invocations all in fresh terminal the first two $Test calls added a blank line.
Re-invoking in same session fixed the issue: https://gyazo.com/f28740e918f6410dfa4305ffe4526d66

Additional example 4 code:
Here i was thinking, if first Test-DscConfiguration cmdlet calls in terminal sessions return nothing, aka $null, the follwing should print something at least ...

if (Test-DscConfiguration) {
   Write-Host "OK"
}
else {
   Write-Host "RIP"
}

Additional example 4 result:
Nothing was printed in console: https://gyazo.com/70f2c0805dfb4e437e5fc3d812d7510c

Additional example 5 code:
Since example 4 did not do anything, the following should not work either right?

$Result = "NothingYet"
if (Test-DscConfiguration) {
    $Result = "OK"
}
else {
    $Result = "RIP"
}
Write-Host $Result

Additional example 5 result:
However the script worked as expected unlike example 4: https://gyazo.com/95ce1fc8506dd3497471caf239a1aebc

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 23, 2020
@SydneyhSmith
Copy link
Collaborator

@marvelcz89 thanks so much for taking the time to test all these examples, they are very helpful for us! I do want to confirm that these were all done using F8 (rather than being pasted into the terminal), is that correct?
Looks like this issue will be resolved by PowerShell/PowerShellEditorServices#1295

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 24, 2020
@marvelcz89
Copy link
Author

@SydneyhSmith The issue occurs in F8 selective execution, F5 script execution, and also when manually typing and executing in PS integrated console.
Regarding the mentioned issue #1295, does that mean that DSC is not yet supported by the Powershell extension for VS Code?
When i implement the workaround as described in the 1st post, it resolves the invocation issue but the intelisense is incomplete as it still uses its hidden integrated console as source. Or can this be resolved by additional reconfiguration?

Many thanks for information!

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 26, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Sep 28, 2020

DSC is supported, but is currently buggy due to deeper issues in the extension as described in #2745. Because DSC features only get used by some users (compared to features like intellisense), we don't hear about bugs in it as often as we probably should.

I don't know if you can fix the intellisense issue with reconfiguration (the hidden integrated console you describe is just the state of the PowerShell process -- without that, you have no intellisense). We're working on fixing the intellisense issue, but we're not quite there yet.

@SydneyhSmith SydneyhSmith added Area-Extension Terminal Issue-Bug A bug to squash. and removed Needs: Maintainer Attention Maintainer attention needed! labels Sep 29, 2020
@marvelcz89
Copy link
Author

Hello @SydneyhSmith,
I have stopped having the issue with Test-DscConfiguration cmdlet on VS Code version 1.51.1 and Windows Server 2019 1809 build 17763.737, Powershell extension version still 2020.6.0.

Commenting here to let everyone know.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 12, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants