In Every day, sysadmins have to perform various standard operations on the numerous files and folders on their Windows servers like creating directory and copy files from one location to another, finding duplicated files etc., Here we will discuss how create a directory with the help of Powershell. For this, please open PowerShell console with administrative privileges.

Method 1: Using a file system object

$filesystemOBJ = new-object -ComObject scripting.filesystemobject
$filesystemOBJ.CreateFolder(“C:\dotnet-helpers\TestFolder1”)

Method 2: Using the new-item command

The New-Item cmdlet creates a new item and sets its value. The types of items that can be created depend on the location of the item.

new-item C:\dotnet-helpers\TestFolder2 -itemtype directory

Method 3: Using system.io.directory object

[system.io.directory]::CreateDirectory(“C:\dotnet-helpers\TestFolder3”)

Method 4: Use the md command

md C:\dotnet-helpers\TestFolder4

Output:

 

What do you think?

I hope you have an idea of  different methods for Creating a Directory with PowerShell. I would like to have feedback from my posts readers. Your valuable feedback, question, or comments about this article are always welcome.