-
Notifications
You must be signed in to change notification settings - Fork 501
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
Cannot execute PowerShell scripts with PowerShell Extension v2022.11.0 after the latest upgrade #4278
Comments
Did you have any workspace folders open, or were you testing sans-workspace? Installing PSScriptAnalyzer should have no effect as it is loaded from the bundled modules path folder, but your logs indicate a failure to resolve the workspace path. Perhaps enable diagnostic logging and try to repro? Thanks! |
I noticed this behavior on 2 different systems however I have not been able to repro the issue thus far. I downloaded and installed 1.73.0 as well as PowerShell extension 2022.10.0 on two separate test machines. Also installing the same modules that I had loaded on my systems that reported the issue. No errors reported before or after updating to 2022.11.0. If no one else has come across then likely something within our environment for further review. I think this can be closed out for now. If it returns, then next steps are I will enable diagnostic logging. |
Sounds good, thanks! |
Issue returned today and this was the error message. I enabled Diagnostic logging and after about 20 minutes the issue resolved itself after multiple attempts. Also attached EditorServices logs from working and failed sessions. Will investigate again if it returns next week. EditorServices_good.log
|
Can you explain the timeline of events for me? I'm most curious about how you're activating the extension. Is it unactivated, and then you're activating it by starting a debug configuration to debug a script? |
Same problem $PSVersionTable I am working in this version of powershell and as of yesterday I am constantly seeing the issue above and am completely perplexed as to how this is happening. |
I think this is another issue caused by PowerShell/PowerShellEditorServices#1947, oof. |
@joshuahipple can you please try the latest PowerShell Preview for VS Code and see if this is fixed? |
@andschwa - Thanks for the update. I did discover the steps to reproduce the issue. Repro steps:
Interesting to note that the error did not manifest if running a separate script (example: CIM_test_2.ps1) first then run the AzureAD script from step 3. Good news!! I tested the PowerShell Preview for VS Code and then it resolved the issue and could not be repro. Thanks again for working to help resolve this issue. P.S. I am aware that AzureADPreview is being deprecated by Microsoft but there are still several identity cmdlets that have not made it to the Microsoft.Graph module and are needed such as Get-MgPrivilegedAccessResourceRoleAssignment . |
Thanks for those repro steps! They confirm my suspicion that it was caused by the GAC returning an older version of Newtonsoft.Json (which was being loaded from the AzureAD module's directory) and that this mismatched version was the cause of the problem. |
This issue has been marked as fixed. It has been automatically closed for housekeeping purposes. |
Prerequisites
Summary
Issue:
Cannot execute PowerShell scripts with PowerShell Extension v2022.11.0 after the latest upgrade. Standalone commands run fine in the Terminal window but scripts open will not execute. After reading through the logs I discovered the following workaround which has fixed the issue.
Workaround- Install the psscriptanalyzer module:
install-module psscriptanalyzer -force -scope AllUsers
Error message:
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', 'Import-Module 'c:\Users\xxxxxxx.vscode\extensions\ms-vscode.powershell-2022.11.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2022.11.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\xxxxxxx.vscode\extensions\ms-vscode.powershell-2022.11.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2022.11.0
Copyright (c) Microsoft Corporation.
https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'Normal' -LogPath 'c:\Users\xxxxxxx\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1669041740-cc28b74a-49e7-4f2c-9e4b-db582deda4051669041688081\EditorServices.log' -SessionDetailsPath 'c:\Users\xxxxxxx\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-1372-299504.json' -FeatureFlags @() '" terminated with exit code: 1.
vscode-powershell.log
11/21/2022 9:42:20 AM [NORMAL] - PowerShell Extension v2022.11.0
11/21/2022 9:42:20 AM [NORMAL] - powershell.exe started.
11/21/2022 9:42:22 AM [NORMAL] - Session file found!
11/21/2022 9:42:22 AM [NORMAL] - Session details: {"status":"started","languageServiceTransport":"NamedPipe","languageServicePipeName":"\\.\pipe\PSES_kmvut4z3.cbi","debugServiceTransport":"NamedPipe","debugServicePipeName":"\\.\pipe\PSES_blhdox0v.t1d"}
11/21/2022 9:42:47 AM [ERROR] - The PowerShell Extension Terminal has stopped, would you like to restart it? IntelliSense and other features will not work without it!
11/21/2022 9:53:18 AM [NORMAL] - Terminating PowerShell process...
11/21/2022 9:53:18 AM [NORMAL] - Waiting for session file...
11/21/2022 9:53:20 AM [NORMAL] - Session file found!
11/21/2022 9:53:20 AM [NORMAL] - Language service socket connected.
EditorServices.log
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveRelativeScriptPath(String baseFilePath, String relativePath)
2022-11-21 09:42:27.243 -05:00 [INF] Unable to find PSSA settings file at 'PSScriptAnalyzerSettings.psd1'. Loading default rules.
2022-11-21 09:42:27.243 -05:00 [INF] PSScriptAnalyzer settings file not found. Falling back to default rules
2022-11-21 09:53:22.729 -05:00 [INF] ReadLine overridden with 'Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.PsrlReadLine'
2022-11-21 09:53:24.502 -05:00 [WRN] No ConfigurationItems have been defined, configuration won't surface any configuration from the client!
2022-11-21 09:53:24.542 -05:00 [ERR] Could not resolve Script Analyzer settings path due to null or empty workspaceRootPath.
2022-11-21 09:53:25.371 -05:00 [ERR] Could not resolve relative script path
baseFilePath =
relativePath = PSScriptAnalyzerSettings.psd1
PowerShell Version
Visual Studio Code Version
Extension Version
ms-vscode.powershell@2022.11.0
Steps to Reproduce
Currently this issue only appears on systems that had Code installed that then upgraded to the latest version of the PowerShell extension.
Visuals
No response
Logs
No response
The text was updated successfully, but these errors were encountered: