SebMa
SebMa

Reputation: 4699

Why dir -Force -r >$null returns "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.GetChildItemCommand" exception on my USB pendrive

Why does dir -Force -Recurse >$null return System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.GetChildItemCommand exception on my USB pendrive.

I first did a chkdsk e: /x /r and then I tried this :

PS E:\> dir -Force -Recurse >$null
dir : The system cannot find the file specified
At line:1 char:1
+ dir -Force -r >$null
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ChildItem], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.GetChildItemCommand

PS E:\>

I expect the dir to continue until the end without the stdout being mingled with the list of all the files.

EDIT0 : Adding -ErrorAction SilentlyContinue still show the error message somehow :

PS E:\> dir -Force -ErrorAction SilentlyContinue -r >$null
dir : The system cannot find the file specified
At line:1 char:1
+ dir -Force -ErrorAction SilentlyContinue -r >$null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ChildItem], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.GetChildItemCommand

PS E:\>

Upvotes: 0

Views: 39

Answers (0)

Related Questions