PowerShell Genie

New-Item

Use New-Item to create a new item, such as a file, directory, registry key, or provider-specific object.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — New-Item

Syntax

1PS> New-Item [-Path] <String[]> [-ItemType <String>] [-Value <Object>] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

New-Item [-Path] <String[]> [-ItemType <String>] [-Value <Object>] [<CommonParameters>]
  1. Stage 1New-Item-Path -ItemType -Value

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    New-Item -Path C:\Ops

    1PS> New-Item -Path C:\Ops -ItemType Directory
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    d----          10/14/2026   11:30 AM                Ops

    New-Item -Path C:\Ops\report.txt

    1PS> New-Item -Path C:\Ops\report.txt -ItemType File
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\Ops
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a---          10/14/2026   11:30 AM              0 report.txt

    New-Item -Path HKCU:\Software\Contoso

    1PS> New-Item -Path HKCU:\Software\Contoso -ItemType Key
    Show reference output

    Sample output · fictional data, shaped like the real thing

       Hive: HKEY_CURRENT_USER\Software
    
    
    SKC  VC Name                           Property
    ---  -- ----                           --------
      0   0 Contoso                         {}

    Parameters

    Parameter definitions:

    • -Path
    • -ItemType
    • -Value

    New-Item on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use New-Item when you need to create a new item, such as a file, directory, registry key, or provider-specific object. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: An item-already-exists error can mean the script was run twice. Check Test-Path, decide whether reuse is appropriate, and do not overwrite an existing file merely to silence the error. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Copy-Item. New-Item creates an item at the requested path; Copy-Item copies an existing item. Creating a directory does not automatically copy a folder tree into it. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    New-Item reference on Microsoft Learn

    Put this command to work

    Create a report directory

    Create C:\Lab\Reports as a directory.

    Review the lesson

    Recap

    New-Item Use New-Item to create a new item, such as a file, directory, registry key, or provider-specific object.

    Next: Get-Item
    Genie guideNew-Item

    Use New-Item to create a new item, such as a file, directory, registry key, or provider-specific object. The console below is pre-loaded — run it, then change a value and run it again.