Test-Pathコマンドレットを使う。オプションを何も指定しなければ、いずれかが存在すればTrueを返す。ファイルかディレクトリどちらかに限定したい場合は、-typeオプションにLeafを指定しればファイル、Containerを指定すればディレクトリが対象になる。
PS > Test-Path C:\Windows\win.ini True PS > Test-Path C:\Windows True PS > Test-Path C:\Windows\win.inii False PS > Test-Path C:\Windowss False PS > Test-Path -type Leaf C:\Windows\win.ini True PS > Test-Path -type Leaf C:\Windows False PS > Test-Path -type Container C:\Windows\win.ini False PS > Test-Path -type Container C:\Windows True