Course Overview

/

Creating Directories Using Objects

Creating Directories Using Objects

What can be used to create a file?

Creating Files and Folders on any system is inevitable, it’s a must for certain programs to work, alongside being able to organise and use file structures. For any user used to the likes of Linux terminal, you could be familiar with the command:

  • $mkdir

Which is an abbreviation of "Make Directory". Within PowerShell there is an alias setup for "mkdir" to be used successfully; however, natively to PowerShell there is the New-Item cmdlet which has the capability to create files and folders. To create a file using New-Item, see below:

  • New-Item "<dir>/<file extension>"

See below for example usage:

What can be used to create a directory?

The New-Item cmdlet can also be used to create directory, but, the parameter of "-Type Directory" must be specified. See the below example:

  • New-item "dir" -Type Directory