Test-Pathコマンドレットを使う。-PathTypeオプションにContainerを指定する。Leafを指定するとファイルの判定になる。
PS > md abc Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2022/12/16 22:20 abc PS > mkdir 123 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2022/12/16 22:20 123 PS > Test-Path abc -PathType Container True PS > Test-Path 123 -PathType Leaf False