TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PowerShell New-Item

PowerShell New-Item with What is PowerShell, History of PowerShell, Features of PowerShell, PowerShell vs CMD, PowerShell Scripting, PowerShell Versions, PowerShell Commands, PowerShell Looping, PowerShell Conditions, PowerShell Array, PowerShell Brackets etc.

<< Back to POWERSHELL

PowerShell New-Item | Create folder

The New-Item Cmdlet in PowerShell creates the files and folders in the file system and also creates registry keys and entries in the registry. With the creation of a file, it also adds the initial content to the file.

Syntax

New-Item 
[-Path] <string[]> 
[-ItemType <string>] 
[-Value <Object>] 
[-Force] 
[-Credential <pscredential>] 
[-WhatIf] 
[-Confirm] 
[-UseTransaction]  
[<CommonParameters>]

New-Item 
[[-Path] <string[]>] 
-Name <string> 
[-ItemType <string>] 
[-Value <Object>] 
[-Force] 
[-Credential <pscredential>] 
[-WhatIf] 
[-Confirm] 
[-UseTransaction]  
[<CommonParameters>]

Parameters

Followings are the parameters used in this cmdlet:

-Path

The -Path parameter is used to specify the path of a location of the new file or folder. Wildcard characters are accepted.

-ItemType

The -ItemType parameter specify the type of specified provider of the new item.

If the location of a user is in the file system drive, these five values (File, SymbolicLink, Directory, Junction, HardLink) are allowed.

If your location is in a certification drive, you can specify these values: Certificate Provider, Certificate, Store, StoreLocation.

-Name

This parameter specifies the new file or folder name.

-Value

This parameter is used to denote the value of a new item.

-Force

This parameter forces this cmdlet to create the items which write over existing read-only items.

-WhatIf

This parameter describes what would happen if the cmdlet executes. The cmdlet does not execute.

-Confirm

This parameter prompts you a confirmation before executing the cmdlet.

Examples

Example 1: Creates a file in the present working directory

PowerShell New-Item

The command, in this example, creates a text file in the present working directory.

Example 2: Creates a file and add the content to that file

PowerShell New-Item

The command in this example creates a text file and also passes the string to the file, which is followed by a -Value parameter in the cmdlet.

Example 3: Create a directory

PowerShell New-Item

The command in this example creates the directory in the given drive. In this command, the -ItemType parameter represents the new item in a directory.

Example 4: Create multiple files

PowerShell New-Item

The command, in this example, creates the new file in the two different directories. If you want to create multiple items, the -Path parameter accepts multiple strings.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf