diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index 828b8c52cf..415471362c 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -4275,10 +4275,17 @@ namespace System.Management.Automation continue; var fileInfo = new FileInfo(entry); - if ((fileInfo.Attributes & FileAttributes.Hidden) != 0) + try { - PSObject wrapper = PSObject.AsPSObject(entry); - psobjs.Add(wrapper); + if ((fileInfo.Attributes & FileAttributes.Hidden) != 0) + { + PSObject wrapper = PSObject.AsPSObject(entry); + psobjs.Add(wrapper); + } + } + catch + { + // do nothing if can't get file attributes } } }