PowerShell「dir /s」でのObjectNotFoundとPathNotFoundエラー対処方法

実現したいこと

以下のコマンドを実行できるようにする

dir /s

初歩的な質問かもしれませんが、
調べても全く分からなかったため質問させていただきます。
よろしくお願いいたします。

前提

動作環境
MacBookAirにBootCampを入れ、windows11にアップグレードして使用

dir単体実行は正常に動作しました

発生している問題・エラーメッセージ

> dir /s dir : パス 'C:\s' が存在しないため検出できません。 発生場所 行:1 文字:1 + dir /s + ~~~~~~ + CategoryInfo : ObjectNotFound: (C:\s:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

試したこと

以下コマンドの実行
(usernameの部分は書き換えています
念のため?個人情報、、なのか?と思ったため)

①パス指定が必要なのかと思い以下実行

> dir C:\Users\username\Desktop\test\batch /s dir : 2 番目のパス フラグメントを ドライブ名または UNC 名にすることはできません。 パラメーター名:path2 発生場所 行:1 文字:1 + dir C:\Users\username\Desktop\test\batch /s + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (C:\Users\username\Desktop\test\batch:String) [Get-ChildItem]、ArgumentExce ption + FullyQualifiedErrorId : DirArgumentError,Microsoft.PowerShell.Commands.GetChildItemCommand

②指定方法を変えて実行

> dir C Users\username\Desktop\test\batch /s Get-ChildItem : 引数 '/s' を受け入れる位置指定パラメーターが見つかりません。 発生場所 行:1 文字:1 + dir C \Users\username\Desktop\test\batch /s + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-ChildItem]、ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

③パラメータとして認識させるため以下実行

> dir /s ("C:\Users\username\Desktop\test\batch") dir : パス 'C:\s' が存在しないため検出できません。 発生場所 行:1 文字:1 + dir /s ("C:\Users\username\Desktop\test\batch") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\s:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

コメントを投稿

0 コメント