By default, when you use the New-Item cmdlet in PowerShell to create a new file or folder, the resulting file or folder will be shown in the output along with the date and time that it was created.
There are two ways to use the New-Item cmdlet to create a new item while hiding this output:
Method 1: Use $null
= -Path c:\users\bobbi\data1\south_data -ItemType Directory
-Path c:\users\bobbi\data1\south_data -ItemType Directory)
Both of these methods will create a new folder named south_data in the path that we specified while hiding the output.
We can use the Dir command to list out all files in this current directory:
Suppose that we would like to create a new folder in this directory named south_data.
-Path c:\users\bobbi\data1\south_data -ItemType Directory
By default, this new folder is shown in the output along with the date and time that it was created.
= -Path c:\users\bobbi\data1\south_data -ItemType Directory
Notice that no output was shown when we used the New-Item cmdlet this time and when we used the Dir command we can see that the folder named south_data was indeed created.
-Path c:\users\bobbi\data1\south_data -ItemType Directory)
Feel free to use whichever method you prefer.
Note: You can find the complete documentation for the New-Item cmdlet in PowerShell here.
PowerShell: How to Copy and Rename a File
PowerShell: How to List Files in Directory by Date
PowerShell: How to Rename File Extension of Multiple Files