New-Item - Powershell 1.0 CmdLet
Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.
More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.
New-Item
Description Create a new item in a namespace Usage Options -path string The path(s) to the items. Wildcards are permitted. Use a dot (.) to specify the current location. -name string The name of the new item. -force Override restrictions that prevent the command from succeeding, apart from security settings. e.g. rename an existing file. Create a file when the directories in the path do not exist (PowerShell will create them) -itemType string The provider-specified type of the new item -value Object The value the new item, can be piped. -whatIf Describe what would happen if you executed the command without actually executing the command. -confirm Prompt you for confirmation before executing the command. -credential PSCredential Use a credential to validate access to the file. Credential represents a user-name, such as "User01" or "Domain01\User01", or a PSCredential object, such as the one retrieved by using the Get-Credential cmdlet. If you type a user name, you will be prompted for a password. This parameter is not supported by any PowerShell core cmdlets or providers. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable. Example(s) Create a text file: PS C:\>new-item -path C:\docs -name SS64.txt -type "file" -value "some text" Create a directory named 'Demo Folder' in the C: drive: PS C:\>new-item -path c:\ -name "Demo Folder" -type directory Create a PowerShell profile in the path specified by the $profile variable: PS C:\>new-item -path $profile -type file -force $profile is an automatic (built-in) variable that stores the path and file name of your PowerShell profile (a profile is a text file). To see the value of the $profile variable, type "$profile" By default, the profile does not exist, even though PowerShell stores a path and file name for it. After you use the command above to create a profile, you can enter aliases, functions, and scripts in the profile to customize your shell.