Skip to content

Commit 40b9638

Browse files
committed
Fix #416: Suppress errors from Get-Command and Get-Help
1 parent 5ad22be commit 40b9638

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/PowerShellEditorServices/Language/CommandHelpers.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ public class CommandHelpers
2121
/// <param name="powerShellContext">The PowerShellContext to use for running Get-Command.</param>
2222
/// <returns>A CommandInfo object with details about the specified command.</returns>
2323
public static async Task<CommandInfo> GetCommandInfo(
24-
string commandName,
24+
string commandName,
2525
PowerShellContext powerShellContext)
2626
{
2727
PSCommand command = new PSCommand();
2828
command.AddCommand(@"Microsoft.PowerShell.Core\Get-Command");
2929
command.AddArgument(commandName);
30+
command.AddParameter("ErrorAction", "Ignore");
3031

3132
return
3233
(await powerShellContext
@@ -43,7 +44,7 @@ public static async Task<CommandInfo> GetCommandInfo(
4344
/// <param name="powerShellContext">The PowerShellContext to use for getting command documentation.</param>
4445
/// <returns></returns>
4546
public static async Task<string> GetCommandSynopsis(
46-
CommandInfo commandInfo,
47+
CommandInfo commandInfo,
4748
PowerShellContext powerShellContext)
4849
{
4950
string synopsisString = string.Empty;
@@ -58,6 +59,7 @@ public static async Task<string> GetCommandSynopsis(
5859
PSCommand command = new PSCommand();
5960
command.AddCommand(@"Microsoft.PowerShell.Core\Get-Help");
6061
command.AddArgument(commandInfo);
62+
command.AddParameter("ErrorAction", "Ignore");
6163

6264
var results = await powerShellContext.ExecuteCommand<PSObject>(command, false, false);
6365
helpObject = results.FirstOrDefault();

0 commit comments

Comments
 (0)