PowerShell Logo Small

Copy-Item



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

Copies an item from one location to another.

SYNTAX


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



Search powershellhelp.space

DESCRIPTION


The Copy-Item cmdlet copies an item from one location to another location in the same namespace. For example, it can copy a file to a folder, but it cannot copy a file to a
certificate drive.


Copy-Item does not cut or delete the items being copied. The particular items that the cmdlet can copy depend on the Windows PowerShell provider that exposes the item. For
example, it can copy files and directories in a file system drive and registry keys and entries in the registry drive.


Copy-Item can copy and rename items in the same command. To rename an item, enter the new name in the value of the Destination parameter. To rename an item without copying
it, use the Rename-Item cmdlet.



<

RELATED LINKS

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

REMARKS

<

Examples


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

PS C:\>Copy-Item C:\Wabash\Logfiles\mar1604.log.txt -Destination C:\Presentation



This command copies the mar1604.log.txt file to the C:\Presentation directory. The command does not delete the original file.










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

PS C:\>Copy-Item C:\Logfiles -Destination C:\Drawings -Recurse



This command copies the entire contents of the Logfiles directory into the Drawings directory. If the LogFiles directory contains files in subdirectories, those
subdirectories will be copied with their file trees intact. The Container parameter is set to true by default. This preserves the directory structure.










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

PS C:\>Copy-Item C:\Logfiles -Destination C:\Drawings\Logs -Recurse



This command copies the contents of the C:\Logfiles directory to the C:\Drawings\Logs directory. It creates the \Logs subdirectory if it does not already exist.










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

PS C:\>Copy-Item \\Server01\Share\Get-Widget.ps1 -Destination \\Server12\ScriptArchive\Get-Widget.ps1.txt



This command uses the Copy-Item cmdlet to copy the Get-Widget.ps1 script from the \\Server01\Share directory to the \\Server12\ScriptArchive directory. As part of the copy
operation, the command also changes the item name from Get-Widget.ps1 to Get-Widget.ps1.txt, so it can be attached to email messages.