mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove the not-working 'run Update-Help from Get-Help when Get-Help runs for the first time' feature (#10974)
This commit is contained in:
committed by
Aditya Patwardhan
parent
9851b07b1d
commit
3768be1b21
@@ -178,27 +178,6 @@ namespace System.Management.Automation.Configuration
|
||||
: string.Concat(shellId, ":", "ExecutionPolicy");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Existing Key = HKLM\SOFTWARE\Microsoft\PowerShell
|
||||
/// Proposed value = Existing default. Probably "0"
|
||||
///
|
||||
/// Schema:
|
||||
/// {
|
||||
/// "DisablePromptToUpdateHelp" : bool
|
||||
/// }
|
||||
/// </summary>
|
||||
/// <returns>Boolean indicating whether Update-Help should prompt. If the value cannot be read, it defaults to false.</returns>
|
||||
internal bool GetDisablePromptToUpdateHelp()
|
||||
{
|
||||
return ReadValueFromFile<bool>(ConfigScope.AllUsers, "DisablePromptToUpdateHelp");
|
||||
}
|
||||
|
||||
internal void SetDisablePromptToUpdateHelp(bool prompt)
|
||||
{
|
||||
WriteValueToFile<bool>(ConfigScope.AllUsers, "DisablePromptToUpdateHelp", prompt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the names of experimental features enabled in the config file.
|
||||
/// </summary>
|
||||
internal string[] GetExperimentalFeatures()
|
||||
|
||||
@@ -246,19 +246,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
_timer.Start();
|
||||
|
||||
if (!Online.IsPresent && UpdatableHelpSystem.ShouldPromptToUpdateHelp() && HostUtilities.IsProcessInteractive(MyInvocation) && HasInternetConnection())
|
||||
{
|
||||
if (ShouldContinue(HelpDisplayStrings.UpdateHelpPromptBody, HelpDisplayStrings.UpdateHelpPromptTitle))
|
||||
{
|
||||
System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace).AddCommand("Update-Help").Invoke();
|
||||
#if LEGACYTELEMETRY
|
||||
_updatedHelp = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
UpdatableHelpSystem.SetDisablePromptToUpdateHelp();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -716,15 +703,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if we can connect to the internet.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool HasInternetConnection()
|
||||
{
|
||||
return true; // TODO:CORECLR wininet.dll is not present on NanoServer
|
||||
}
|
||||
|
||||
#region Helper methods for verification of parameters against NoLanguage mode
|
||||
|
||||
internal static void VerifyParameterForbiddenInRemoteRunspace(Cmdlet cmdlet, string parameterName)
|
||||
|
||||
@@ -1500,52 +1500,6 @@ namespace System.Management.Automation.Help
|
||||
return string.IsNullOrEmpty(defaultSourcePath) ? null : defaultSourcePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the DisablePromptToUpdatableHelp regkey.
|
||||
/// </summary>
|
||||
internal static void SetDisablePromptToUpdateHelp()
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerShellConfig.Instance.SetDisablePromptToUpdateHelp(true);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// Ignore AccessDenied related exceptions
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
// Ignore AccessDenied related exceptions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if it is necessary to prompt to update help.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static bool ShouldPromptToUpdateHelp()
|
||||
{
|
||||
#if UNIX
|
||||
// TODO: This workaround needs to be removed once updatable help
|
||||
// works on Linux.
|
||||
return false;
|
||||
#else
|
||||
try
|
||||
{
|
||||
if (!Utils.IsAdministrator())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return PowerShellConfig.Instance.GetDisablePromptToUpdateHelp();
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
@@ -143,9 +143,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
// Disable Get-Help prompt
|
||||
UpdatableHelpSystem.SetDisablePromptToUpdateHelp();
|
||||
|
||||
if (_path == null)
|
||||
{
|
||||
// Pull default source path from GP
|
||||
|
||||
@@ -449,12 +449,6 @@ To update help again, add the Force parameter to your command.</value>
|
||||
<data name="RootElementMustBeHelpItems" xml:space="preserve">
|
||||
<value>The root level element of the help content must be "helpItems".</value>
|
||||
</data>
|
||||
<data name="UpdateHelpPromptBody" xml:space="preserve">
|
||||
<value>The Update-Help cmdlet downloads the most current Help files for PowerShell modules, and installs them on your computer. For more information about the Update-Help cmdlet, see https://go.microsoft.com/fwlink/?LinkId=210614.</value>
|
||||
</data>
|
||||
<data name="UpdateHelpPromptTitle" xml:space="preserve">
|
||||
<value>Do you want to run Update-Help?</value>
|
||||
</data>
|
||||
<data name="SaveProgressActivityForModule" xml:space="preserve">
|
||||
<value>Saving Help for module {0}</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user