Powershell silent mkdir
18,770
Solution 1
PetSerAl is correct, added to by SimonS
Out-Null
is your best bet but as SimonS stated > $null
is quicker
Solution 2
Just to add another solution: mkdir
returns an object and if I just execute the code below, I don't have any output. Further more, I can use $dir
to make my own output if needed
$dir = mkdir c:\foo\bar
As a side note, I've tested this PowerShell Version
PS> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 15063 1155
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
Is there a way to use mkdir (aka md) in powershell without verbose output? Currently, the output is as follows:
PS C:\Users\myusername> mkdir foobar Directory: C:\Users\myusername Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 2016-12-07 9:35 AM foobar PS C:\Users\myusername>
Unless there's an error to report, I'd like it to be silent, as in
PS C:\Users\myusername> mkdir foobar PS C:\Users\myusername>
Is there a way to do this? I'm using Powershell version 2.
-
Admin over 7 yearsThanks! I would have marked PetSerAl's answer as correct, but since I can't this one gets the kudos.
-
FizxMike about 6 yearsnope, doesn't work in PS for win 10.
-
FizxMike about 6 yearsInstead, this seems to fail silently: [system.io.directory]::CreateDirectory("C:\test")
-
Lachie White about 6 years@FizxMike sorry just seen this, works for me on a pretty regular basis on windows 10.
-
Honza P. over 4 yearsThis one seems to me as cool, clean and practical solution. Thanks.