Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

PSScriptAnalyzer writes unnecessary warning when using custom rules #176

Closed
johlju opened this issue Jul 27, 2017 · 5 comments
Closed

PSScriptAnalyzer writes unnecessary warning when using custom rules #176

johlju opened this issue Jul 27, 2017 · 5 comments

Comments

@johlju
Copy link
Contributor

johlju commented Jul 27, 2017

When running PSSA Custom rules it outputs a warning. This is probably PSScriptAnalyzer that is doing something (doing a Write-Host or similar? Just guessing).
If it is PSScriptAnalyzer, is it worth opening up a issue in that repo?

More information from @PlagueHO in PR #162.

A command that prompts the user failed because the host program or the command type does not
support user interaction. The host was attempting to request confirmation with the following message: The
Update-Help cmdlet downloads the most current Help files for Windows PowerShell modules, and installs 
them on your computer. For more information about the Update-Help cmdlet, see 
http://go.microsoft.com/fwlink/?LinkId=210614.

Opening this issue to track this.

@PlagueHO
Copy link
Collaborator

I was thinking about this yesterday. I think it is actually calling Update-Help. I've no idea what is calling the Update-Help (PSSA maybe?).

I plan to do some investigation on this over the weekend. Worst case scenario I might be able to suppress this call to Update-Help with a Mock. But I just can't figure out what/why it would be called.

@johlju
Copy link
Contributor Author

johlju commented Jul 28, 2017

It must be something when PSSA is called with the CustomRulePath parameter. I thought I could follow the C# code and see what it does, but didn't have time to look into it.

Might not be related, but I saw they had the same issue over at PSake and apparently it showed this warning when they called Write-Host in one scenario. So maybe this warning is printed when some command tries to do something interactive but the code is not running interactive (in a console).

@PlagueHO
Copy link
Collaborator

You may be right - the actual command that is being run may just be a red-herring. I'll see if I can track it down this weekend.

@PlagueHO
Copy link
Collaborator

PlagueHO commented Aug 2, 2017

It looks like this was an issue in versions of PSSA prior to 1.2.0. It looks like they fixed this in v1.2.0 (see CHANGELOG.md).

I think the solution here is to check for the version of PSSA installed and either recommend the user upgrades (if in user mode) or force an update if in AppVeyor.

@PlagueHO
Copy link
Collaborator

PlagueHO commented Aug 2, 2017

Ignore previous comment. This problem was only identified but was not fixed. A solution has been identified.

See https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Engine/ScriptAnalyzer.cs#L1120

What I'll do is set the registry key HKLM:\Software\Microsoft\PowerShell\DisablePromptToUpdateHelp to 1 when running in AppVeyor. This should suppress the warning.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants