PowerShell Logo Small


This is the built-in help made by Microsoft for the command 'mkdir', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.


Creates a new item.


New-Item [-Path] <String[]> [-Credential [<PSCredential>]] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String>]] [-ItemType [<String>]] [-Value [<Object>]] [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
New-Item [[-Path] <String[]>] [-Credential [<PSCredential>]] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String>]] [-ItemType [<String>]] [-Value [<Object>]] -Name <String> [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]]

Search powershellhelp.space


The New-Item cmdlet creates a new item and sets its value. The types of items that can be created depend upon the location of the item. For example, in the file system,
New-Item is used to create files and folders. In the registry, New-Item creates registry keys and entries.

New-Item can also set the value of the items that it creates. For example, when creating a new file, New-Item can add initial content to the file.



Online Version: http://go.microsoft.com/fwlink/p/?linkid=293886




-------------------------- EXAMPLE 1 --------------------------

PS C:\>new-item -path . -name testfile1.txt -itemtype "file" -value "This is a text string."

This command creates a text file named testfile1.txt in the current directory. The dot (.) in the value of the Path parameter indicates the current directory. The quoted
text that follows the Value parameter is added to the file as content.

-------------------------- EXAMPLE 2 --------------------------

PS C:\>new-item -path c:\ -name logfiles -itemtype directory

This command creates a directory named Logfiles in the C: drive. The ItemType parameter specifies that the new item is a directory, not a file or other file system object.

-------------------------- EXAMPLE 3 --------------------------

PS C:\>new-item -path $profile -itemtype file -force

This command creates a Windows PowerShell profile in the path that is specified by the $profile variable.

You can use profiles to customize Windows PowerShell. $Profile is an automatic (built-in) variable that stores the path and file name of the CurrentUser/CurrentHost profile.
By default, the profile does not exist, even though Windows PowerShell stores a path and file name for it.

In this command, the $profile variable represents the path to the file. The ItemType parameter specifies that the command creates a file. The Force parameter lets you create
a file in the profile path, even when the directories in the path do not exist (Windows PowerShell creates them).

After you use this command to create a profile, you can enter aliases, functions, and scripts in the profile to customize your shell.

For more information, see about_Automatic_Variables and about_Profiles.

-------------------------- EXAMPLE 4 --------------------------

PS C:\>new-item -itemtype directory -path c:\ps-test\scripts

This command creates a new Scripts directory in the C:\PS-Test directory.

The name of the new directory item, Scripts, is included in the value of the Path parameter, instead of being specified in the value of the Name parameter. As indicated by
the syntax, either command form is valid.

-------------------------- EXAMPLE 5 --------------------------

PS C:\>new-item -itemtype file -path "c:\ps-test\test.txt", "c:\ps-test\Logs\test.log"

This command uses the New-Item cmdlet to create files in two different directories. Because the Path parameter takes multiple strings, you can use it to create multiple