You can ignore errors in PowerShell with the -ErrorAction SilentlyContinue
parameter (you can shorten this to -ea 0
). The full PowerShell command is
New-Item /foo/bar/baz -ItemType Directory -ea 0
You can shorten this to
md /foo/bar/baz -ea 0
(You can also type mkdir
instead of md
if you prefer.)
Note that PowerShell will output the DirectoryInfo
object it creates when using New-Item -ItemType Directory
(or the md
or mkdir
aliases). If you don’t want any output, you can pipe to Out-Null
.