copy-item

What is the meaning of Powershell's Copy-Item's -container argument?

I am writing a script for MS PowerShell. This script uses the Copy-Item command. One of the optional arguments to this command is "-container". The documentation for the argument states that specifying this argument "Preserves container objects during the copy operation." This is all well and good, for I would be the last person to wa...

Powershell Copy-Item but only copy changed files...

I am trying to recurse through a directory and copy it from A to B. That can be done with the following: Copy-Item C:\MyTest C:\MyTest2 –recurse I want to be able though to only copy new files (ones that exist in src but not dest) and also only copy files that may have changed based off a CRC check and not a datetime stamp. $file = "...

How Do I copy the files and the Folder Tree to Remote Machine?

I have two machines Server A and Server B I want to copy all the files and folder tree from Server A to Server B and create the same file and folder tree using powershell scripting I have tried the command given below but it copies only the files in the folder but do not create the folder tree Copy-Item E:\TestSource\* //TestDestinati...

PowerShell: Copy-Item Cannot find path

I'm trying to get PowerShell to copy files from a remote computer (on which I have admin rights through AD) to the local computer. It fails in the strangest place. Here's a snippet of the script: $configs = Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter "*.config" $serverUNCPath foreach($config in $configs){ $config_...

PowerShell Copy-Item what I'm doing wrong?

Given the dir structure: x\Code x\Script\Backup.ps1 Backup.ps1 contains: $BackupDirectoy = "..\Backup" $CodeDirectory = "..\Code" function BackupCurrentVersion() { New-Item $BackupDirectoy -type directory -force Copy-Item $CodeDirectory -destination $BackupDirectory -recurse } BackupCurrentVersion I'm doing somet...

Powershell filter files by SQL Server result set and copy

I am executing a query in SQL Server and returning a single column result set. I need to loop through the result set and find file names matching the record from the result set. Part of the file name is a sequence number. I need to sort the files in ascending order, select the first file, and then copy only that file to a subdirectory. T...

Progress during large file copy (Copy-Item & Write-Progress?)

Is there any way to copy a really large file (from one server to another) in Powershell AND display it's progress? There are solutions out there to use Write-Progress in conjunction with looping to copy many files and display progress. However I can't seem to find anything that would show progress of a single file. Any thoughts? ...

PowerShell copy fails without warning

Howdy, am trying to copy a file from IE cache to somewhere else. This works on w7, but not Vista Ultimate. In short: copy-item $f -Destination "$targetDir" -force (I also tried $f.fullname) The full script: $targetDir = "C:\temp" $ieCache=(get-itemproperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"...

powershell error checking during file copy with recursion

I have a program that copies folders and files recursively. example: Copy-Item -path "$folderA" -destination "$folderB" -recurse Sometimes the files do not copy. Is there a way to "step inside the recursion" or a better way to do it, so I can enable some kind of error checking during the process rather than after wards. Possibly even...