< Back
Copy-LongItem
Post
NAME Copy-LongItem
SYNOPSIS
Copies an item from one location to another.
SYNTAX
Copy-LongItem [-Path] <String> [-Destination] <String> [-Force <SwitchParameter>] [-NoBuffering <SwitchParameter>]
[-AllowDecryptedDestination <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Copy-LongItem cmdlet copies an item from one location to another location in the filesystem provider.
PARAMETERS
-Path <String>
Specifies the path to the items to copy.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? false
-Destination <String>
Specifies the path to the new location. To rename a copied item, include the new name in the value.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Allows the cmdlet to copy items that cannot otherwise be changed, such as copying over an existing file or
directory.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-NoBuffering [<SwitchParameter>]
The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for
very large file transfers.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-AllowDecryptedDestination [<SwitchParameter>]
An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DestinationType [<String>]
Specify whether the destination is a file or a folder. If this parameter is not specified the destination type
is inferred by checking whether the destination item has an extension or not.
If the destination has an extension then we assume it is a file and folder if not. As you can tell this is not
always correct because there can be folders with a period in them which can then be incorrectly inferred as a
file.
Hence it is important to specify this parameter to get accurate results.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
OUTPUTS
None
This cmdlet does not return any output.
NOTES
Copy-LongItem
Copy-LongItem is like the 'cp' or 'copy' commands in other shells.
By default the recurse flag is set so a folder copy operation is always recursive.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Copy-LongItem -Path C:\\temp\\drivers.txt -Destination C:\\temp\\folder1 -Verbose
This command copies the drivers.txt file to the C:\\temp\\folder1 directory. 'folder1' is created if it dosent exist.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Copy-LongItem C:\\temp\\logfiles\\ -Destination C:\\temp\\newlogs -Verbose
This command copies the contents of the folder C:\\Logfiles directory recursively to the C:\\temp\\newLogs directory.
It creates the "newLogs" subdirectory if it does not already exist.
Note: the "\\" at the end of the c:\\temp\\logfiles ensures that we copy the contents of the folder and not the
folder itself.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Copy-LongItem C:\\temp\\logfiles -Destination C:\\temp\\newlogs -Verbose
This command copies the entire folder C:\\Logfiles recursively to the C:\\temp\\newLogs. It creates the "newLogs"
subdirectory if it does not already exist.
EXAMPLE 4
PS C:\\>Copy-LongItem -Path C:\\temp\\win2012R2.iso -Destination C:\\temp\\2012R2.iso -Verbose -NoBuffering
attempts to copy the iso file using unbuffered I/O.(Recommended for very large file transfers.)
EXAMPLE 5
$params =
@{
Path = 'C:\\temp\\test-psalphafs\\source\\file-01.txt'
Destination = 'C:\\temp\\test-psalphafs\\destination.dir1'
Force = $false
verbose = $true
destinationtype = 'Directory'
}
Copy-LongItem @params
We use "splatting" to pass the parameters as a table to copy-longitem. file 'file-01.txt' is copied to
destination directory 'destination.dir1'. The destination directory 'destination.dir1' will be created if it
dosent already exist.
Note: The destination "destination.dir1" is a folder containing a period in its name and hence we also specify the
"destinationtype" parameter.
If destinationtype parameter is not specified the destination would be treated as a file.
RELATED LINKS
SYNOPSIS
Copies an item from one location to another.
SYNTAX
Copy-LongItem [-Path] <String> [-Destination] <String> [-Force <SwitchParameter>] [-NoBuffering <SwitchParameter>]
[-AllowDecryptedDestination <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Copy-LongItem cmdlet copies an item from one location to another location in the filesystem provider.
PARAMETERS
-Path <String>
Specifies the path to the items to copy.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? false
-Destination <String>
Specifies the path to the new location. To rename a copied item, include the new name in the value.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Allows the cmdlet to copy items that cannot otherwise be changed, such as copying over an existing file or
directory.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-NoBuffering [<SwitchParameter>]
The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for
very large file transfers.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-AllowDecryptedDestination [<SwitchParameter>]
An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DestinationType [<String>]
Specify whether the destination is a file or a folder. If this parameter is not specified the destination type
is inferred by checking whether the destination item has an extension or not.
If the destination has an extension then we assume it is a file and folder if not. As you can tell this is not
always correct because there can be folders with a period in them which can then be incorrectly inferred as a
file.
Hence it is important to specify this parameter to get accurate results.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
OUTPUTS
None
This cmdlet does not return any output.
NOTES
Copy-LongItem
Copy-LongItem is like the 'cp' or 'copy' commands in other shells.
By default the recurse flag is set so a folder copy operation is always recursive.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Copy-LongItem -Path C:\\temp\\drivers.txt -Destination C:\\temp\\folder1 -Verbose
This command copies the drivers.txt file to the C:\\temp\\folder1 directory. 'folder1' is created if it dosent exist.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Copy-LongItem C:\\temp\\logfiles\\ -Destination C:\\temp\\newlogs -Verbose
This command copies the contents of the folder C:\\Logfiles directory recursively to the C:\\temp\\newLogs directory.
It creates the "newLogs" subdirectory if it does not already exist.
Note: the "\\" at the end of the c:\\temp\\logfiles ensures that we copy the contents of the folder and not the
folder itself.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Copy-LongItem C:\\temp\\logfiles -Destination C:\\temp\\newlogs -Verbose
This command copies the entire folder C:\\Logfiles recursively to the C:\\temp\\newLogs. It creates the "newLogs"
subdirectory if it does not already exist.
EXAMPLE 4
PS C:\\>Copy-LongItem -Path C:\\temp\\win2012R2.iso -Destination C:\\temp\\2012R2.iso -Verbose -NoBuffering
attempts to copy the iso file using unbuffered I/O.(Recommended for very large file transfers.)
EXAMPLE 5
$params =
@{
Path = 'C:\\temp\\test-psalphafs\\source\\file-01.txt'
Destination = 'C:\\temp\\test-psalphafs\\destination.dir1'
Force = $false
verbose = $true
destinationtype = 'Directory'
}
Copy-LongItem @params
We use "splatting" to pass the parameters as a table to copy-longitem. file 'file-01.txt' is copied to
destination directory 'destination.dir1'. The destination directory 'destination.dir1' will be created if it
dosent already exist.
Note: The destination "destination.dir1" is a folder containing a period in its name and hence we also specify the
"destinationtype" parameter.
If destinationtype parameter is not specified the destination would be treated as a file.
RELATED LINKS