Skip to content

Commit 80b788a

Browse files
committed
Script Analyzer shouldn't automatically update help for modules
1 parent e406f26 commit 80b788a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Engine/ScriptAnalyzer.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,7 @@ private List<ExternalRule> GetExternalRule(string[] moduleNames)
554554
{
555555
posh.AddCommand("Get-Module").AddParameter("Name", moduleName).AddParameter("ListAvailable");
556556
shortModuleName = posh.Invoke<PSModuleInfo>().First().Name;
557-
558-
// Invokes Update-Help for this module
559-
// Required since when invoking Get-Help later on, the cmdlet prompts for Update-Help interactively
560-
// By invoking Update-Help first, Get-Help will not prompt for downloading help later
561-
posh.AddCommand("Update-Help").AddParameter("Module", shortModuleName).AddParameter("Force");
562-
posh.Invoke();
563-
557+
564558
// Invokes Get-Command and Get-Help for each functions in the module.
565559
posh.Commands.Clear();
566560
posh.AddCommand("Get-Command").AddParameter("Module", shortModuleName);
@@ -586,6 +580,11 @@ private List<ExternalRule> GetExternalRule(string[] moduleNames)
586580
//Only add functions that are defined as rules.
587581
if (param != null)
588582
{
583+
// On a new image, when Get-Help is run the first time, PowerShell offers to download updated help content
584+
// using Update-Help. This results in an interactive prompt - which we cannot handle
585+
// Workaround to prevent Update-Help from running is to set the following reg key
586+
// HKLM:\Software\Microsoft\PowerShell\DisablePromptToUpdateHelp
587+
// OR execute Update-Help in an elevated admin mode before running ScriptAnalyzer
589588
posh.AddCommand("Get-Help").AddParameter("Name", funcInfo.Name);
590589
Collection<PSObject> helpContent = posh.Invoke();
591590

0 commit comments

Comments
 (0)