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.
53 Answers
PetSerAl is correct, added to by SimonSOut-Null is your best bet but as SimonS stated > $null is quicker
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\barAs a side note, I've tested this PowerShell Version
PS> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 15063 1155 1 Make a function
function silentMkdir { $sink = mkdir $args }Make an alias in the current shell only that uses that function
Set-Alias -Name mkdir -Value silentMkdir -Scope PrivatePS: I'm new to Powershell but this seemed to work. Without the -Scope Private mkdir will be changed for scripts called from this shell. With -Scope Private that issue seems to go away.