PowerShell Genie

Move-Item

Use Move-Item to move a file or directory to a new location, and rename it if you change the leaf name.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Move-Item

Syntax

1PS> Move-Item [-Path] <String[]> [[-Destination] <string>] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<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.

Move-Item [-Path] <String[]> [[-Destination] <string>] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
  1. Stage 1Move-Item-Path -Destination -Force -PassThru -WhatIf -Confirm

    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

    Move-Item -Path 'C:\Scripts\Backup-Files.ps1'

    1PS> Move-Item -Path 'C:\Scripts\Backup-Files.ps1' -Destination 'C:\Scripts\Archive'
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\Scripts\Archive
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a----         9/28/2026   9:04 AM           1985 Cleanup-Old.ps1
    -a----        10/12/2025  11:47 AM           2418 Backup-Files.ps1

    Move-Item -Path 'C:\Temp\old.txt'

    1PS> Move-Item -Path 'C:\Temp\old.txt' -Destination 'C:\Temp\new.txt'
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\Temp
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a----         10/9/2026   1:58 PM            312 new.txt

    Move-Item -Path 'C:\Scripts\*.log'

    1PS> Move-Item -Path 'C:\Scripts\*.log' -Destination 'C:\Temp'
    Show reference output

    Sample output · fictional data, shaped like the real thing

        Directory: C:\Temp
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a----         10/9/2026   8:02 AM           4120 app.log
    -a----         10/8/2026   5:47 PM           1874 debug.log

    Parameters

    Parameter definitions:

    • -Path
    • -Destination
    • -Force
    • -PassThru
    • -WhatIf
    • -Confirm

    Move-Item on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Move-Item when you need to move a file or directory to a new location, and rename it if you change the leaf name. 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: Access denied may mean the source file is open or the destination ACL rejects writes. Close the owning application when appropriate and verify both source and destination permissions. 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: Rename-Item. Move-Item can relocate an item; Rename-Item changes its name without selecting another destination directory. Check the destination before moving a group of files. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Move-Item reference on Microsoft Learn

    Recap

    Move-Item Use Move-Item to move a file or directory to a new location, and rename it if you change the leaf name.

    Next: New-Item
    Genie guideMove-Item

    Use Move-Item to move a file or directory to a new location, and rename it if you change the leaf name. The console below is pre-loaded — run it, then change a value and run it again.