UNable to install PSScriptAnalyzer

When I try to click on the Analysis tab in the options dialog I get prompted to install PSScriptAnalyzer. When I say yes to install it I get an error. Here is a screenshot.

image

Is this a known issue? Is there a workaround? Any help on this would be greatly appreciated.

Thanks,

Jeff

Hey @bigloudjeff,

You can always install PSScriptAnalyzer from the gallery.

Install-Module PSScriptAnalyzer -Force -Scope CurrentUser

Can you please grab a log from %AppData%\PowerShell Tools for Visual Studio? Hopefully that will contain some more info on what went wrong.

Thanks Adam. The install-module method worked.

I tried to reply to this via email with the log attached but my email keeps bouncing. Can you please PM at jeff@bigloudjeff.com and I will send you the log.

Thanks,

Jeff

I’m having the same problem. I can install manually but I’d like to know the root cause of the failure. Here’s a log:

[35] INFO  PowerShellTools.Diagnostics.DiagnosticConfiguration (null) - Diagnostics enabled.
[35] INFO  PowerShellTools.PowerShellToolsPackage (null) - PowerShellToolsPackage()
[35] INFO  PowerShellTools.PowerShellToolsPackage (null) - InitializeAsync()
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Switch to main thread
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - PowerShell Tools Version: 5.7.14.0
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Visual Studio Version: 16.0
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Windows Version: Microsoft Windows NT 10.0.19044.0
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Current Culture: en-US
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Entering Initialize() of: PowerShellTools.PowerShellToolsPackage
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Adding language service
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Getting adapters factory
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - RefreshCommands
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done RefreshCommands
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - InitializePowerShellHost
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Opening PowerShell host connection
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Starting host path. Bitness: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Host path: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' Host arguments: '-NoExit  -NoProfile -NonInteractive -Command &{ Import-Module 'c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\3ajoktf3.5un\PowerShellProTools.VSCode.dll'; [PowerShellProTools.Common.ParentProcessWatcher]::WatchProcess(11656); }'
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Initializing debugging engine service ...
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Initializing run space with debugger
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Providing $profile variable to the local runspace.
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Done initializing runspace
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Starting host path. Bitness: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Host path: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' Host arguments: '-NoExit  -NoProfile -NonInteractive -Command &{ Import-Module 'c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\3ajoktf3.5un\PowerShellProTools.VSCode.dll'; [PowerShellProTools.Common.ParentProcessWatcher]::WatchProcess(11656); }'
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Finished opening PowerShell host connection
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Setting execution policy
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Initializing IntelliSense
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Debugger is ready
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Loading profiles
[12] INFO  PowerShellTools.HostService.ServiceCommon (null) - Checking runspace availability: Available
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Loading PowerShell Profiles
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done loading profiles
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Set repl location to solution dir
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Start executing ps script ...
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - DebuggerFinished
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Clearing all breakpoints
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Checking runspace availability: Available
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done InitializeInternal()
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - RegisterServices
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done RegisterServices
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Set PacakgeInitialized
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done InitializeAsync()
[9] DEBUG PowerShellTools.Classification.PowerShellTokenizationService (null) - Parsing input.
[9] DEBUG PowerShellTools.Classification.PowerShellTokenizationService (null) - Classifying tokens.
[9] DEBUG PowerShellTools.Classification.PowerShellTokenizationService (null) - Matching braces and regions.
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 4c7763bf-5faf-4264-a366-b7e1f27ba958, Id: 30'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 1496a755-94de-11d0-8c3f-00c04fc2aae2, Id: 2200'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 5efc7975-14bc-11cf-9b2b-00aa00573819, Id: 137'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 5efc7975-14bc-11cf-9b2b-00aa00573819, Id: 137'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 099073c0-b561-4bc1-a847-92657b89a00e, Id: 296'

I’m having the same problem. I can install manually but I’d like to know the root cause of the failure. Here’s a log:

[35] INFO  PowerShellTools.Diagnostics.DiagnosticConfiguration (null) - Diagnostics enabled.
[35] INFO  PowerShellTools.PowerShellToolsPackage (null) - PowerShellToolsPackage()
[35] INFO  PowerShellTools.PowerShellToolsPackage (null) - InitializeAsync()
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Switch to main thread
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - PowerShell Tools Version: 5.7.14.0
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Visual Studio Version: 16.0
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Windows Version: Microsoft Windows NT 10.0.19044.0
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Current Culture: en-US
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Entering Initialize() of: PowerShellTools.PowerShellToolsPackage
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Adding language service
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Getting adapters factory
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - RefreshCommands
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done RefreshCommands
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - InitializePowerShellHost
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Opening PowerShell host connection
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Starting host path. Bitness: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Host path: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' Host arguments: '-NoExit  -NoProfile -NonInteractive -Command &{ Import-Module 'c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\3ajoktf3.5un\PowerShellProTools.VSCode.dll'; [PowerShellProTools.Common.ParentProcessWatcher]::WatchProcess(11656); }'
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Initializing debugging engine service ...
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Initializing run space with debugger
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Providing $profile variable to the local runspace.
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Done initializing runspace
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Starting host path. Bitness: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
[1] DEBUG PowerShellTools.ServiceManagement.PowershellHostProcessHelper (null) - Host path: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' Host arguments: '-NoExit  -NoProfile -NonInteractive -Command &{ Import-Module 'c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\3ajoktf3.5un\PowerShellProTools.VSCode.dll'; [PowerShellProTools.Common.ParentProcessWatcher]::WatchProcess(11656); }'
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Finished opening PowerShell host connection
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Setting execution policy
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Initializing IntelliSense
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Debugger is ready
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Loading profiles
[12] INFO  PowerShellTools.HostService.ServiceCommon (null) - Checking runspace availability: Available
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Loading PowerShell Profiles
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done loading profiles
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Set repl location to solution dir
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Start executing ps script ...
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - DebuggerFinished
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Clearing all breakpoints
[1] INFO  PowerShellTools.HostService.ServiceCommon (null) - Checking runspace availability: Available
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done InitializeInternal()
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - RegisterServices
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done RegisterServices
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Set PacakgeInitialized
[1] INFO  PowerShellTools.PowerShellToolsPackage (null) - Done InitializeAsync()
[9] DEBUG PowerShellTools.Classification.PowerShellTokenizationService (null) - Parsing input.
[9] DEBUG PowerShellTools.Classification.PowerShellTokenizationService (null) - Classifying tokens.
[9] DEBUG PowerShellTools.Classification.PowerShellTokenizationService (null) - Matching braces and regions.
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 4c7763bf-5faf-4264-a366-b7e1f27ba958, Id: 30'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 1496a755-94de-11d0-8c3f-00c04fc2aae2, Id: 2200'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 5efc7975-14bc-11cf-9b2b-00aa00573819, Id: 137'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 5efc7975-14bc-11cf-9b2b-00aa00573819, Id: 137'
[1] DEBUG PowerShellTools.Intellisense.IntelliSenseManager (null) - Non-VSStd2K command: 'CommandGroup: 099073c0-b561-4bc1-a847-92657b89a00e, Id: 296'

Edit: See my post here for more information.

It looks like the module install is failing due to permission issues.

I tried installing it manually from an admin prompt and it worked. But it installed in C:\Program Files (x86)\WindowsPowerShell\Modules instead of C:\Program Files\WindowsPowerShell\Modules

Screenshot: https://user-images.githubusercontent.com/33441569/166111609-0f41240f-23a3-40e8-9818-50fc2172dff2.png

So Visual Studio is still prompting me to install PSScriptAnalyzer… probably because it’s expecting it to be present in the 64bit powershell module folder instead of x86.

I’m all sorts of confused. Any help at all would be hugely appreciated.