PowerShell Logo Small

Move-Item



This is the built-in help made by Microsoft for the command 'Move-Item', 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.

SYNOPSIS

Moves an item from one location to another.

SYNTAX


Move-Item [-Path] <String[]> [[-Destination] [<String>]] [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]] [-Force] [-Include [<String[]>]]
[-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PassThru] [-Confirm] [-WhatIf]
[-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
Move-Item [[-Destination] [<String>]] [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]] [-Force] [-Include [<String[]>]] [-InformationAction
{SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PassThru] -LiteralPath <String[]> [-Confirm] [-WhatIf]
[-UseTransaction [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Move-Item cmdlet moves an item, including its properties, contents, and child items, from one location to another location. The locations must be supported by the same
provider. For example, it can move a file or subdirectory from one directory to another or move a registry subkey from one key to another. When you move an item, it is added
to the new location and deleted from its original location.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293883
Clear-Item
Copy-Item
Get-Item
Invoke-Item
New-Item
Remove-Item
Rename-Item
Set-Item
about_Providers

REMARKS

<

Examples


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

PS C:\>move-item -path C:\test.txt -destination E:\Temp\tst.txt



This command moves the Test.txt file from the C: drive to the E:\Temp directory and renames it from "test.txt" to "tst.txt".










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

PS C:\>move-item -path C:\Temp -destination C:\Logs



This command moves the C:\Temp directory and its contents to the C:\Logs directory. The Temp directory, and all of its subdirectories and files, then appear in the Logs
directory.










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

PS C:\>move-item -path .\*.txt -destination C:\Logs



This command moves all of the text files (*.txt) in the current directory (represented by a dot (.)) to the C:\Logs directory.










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

PS C:\>Get-ChildItem -Path .\*.txt -Recurse | Move-Item -Destination C:\TextFiles



This command moves all of the text files from the current directory and all subdirectories, recursively, to the C:\TextFiles directory.

The command uses the Get-ChildItem cmdlet to get all of the child items in the current directory (represented by the dot [.]) and its subdirectories that have a *.txt file
name extension. It uses the Recurse parameter to make the retrieval recursive and the Include parameter to limit the retrieval to *.txt files.

The pipeline operator (|) sends the results of this command to Move-Item, which moves the text files to the TextFiles directory.

If files being moved to C:\Textfiles have the same name, Move-Item displays an error and continues, but it moves only one file with each name to C:\Textfiles. The other
files remain in their original directories.

If the Textfiles directory (or any other element of the destination path) does not exist, the command fails. The missing directory is not created for you, even if you use
the Force parameter. Move-Item moves the first item to a file called "Textfiles" and then displays an error explaining that the file already exists.

Also, by default, Get-ChildItem does not move hidden files. To move hidden files, use the Force parameter with Get-ChildItem.

Note: In Windows PowerShell 2.0, when using the Recurse parameter of the Get-ChildItem cmdlet, the value of the Path parameter must be a container. Use the Include
parameter to specify the .txt file name extension filter (Get-ChildItem –Path .\* -Include *.txt –Recurse | Move-Item -Destination C:\TextFiles).










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

PS C:\>move-item hklm:\software\mycompany\* hklm:\software\mynewcompany



This command moves the registry keys and values within the MyCompany registry key in HKLM\Software to the MyNewCompany key. The wildcard character (*) indicates that the
contents of the MyCompany key should be moved, not the key itself. In this command, the optional Path and Destination parameter names are omitted.










-------------------------- EXAMPLE 6 --------------------------

PS C:\>move-item -literalpath 'Logs[Sept`06]' -destination 'Logs[2006]'



This command moves the Logs[Sept`06] directory (and its contents) into the Logs[2006] directory.

The LiteralPath parameter is used instead of Path, because the original directory name includes left bracket and right bracket characters ("[" and "]"). The path is also
enclosed in single quotation marks (' '), so that the backtick symbol (`) is not misinterpreted.

The Destination parameter does not require a literal path, because the Destination variable also must be enclosed in single quotation marks, because it includes brackets
that can be misinterpreted.