Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Copy-Item - behaviour changes on subsequent runs of the script

$
0
0

Good Afternoon all Smile

I have a script whereby I want to copy items in a folder from one directory to another.  The script works the first time but then behaves differently subsequent times by recreating the source folder again, how do I stop this behaviour please?

[string]$FolderName = Get-Date -f dd

$SourcePath = "\\server\folder1\folder2\"

$DestinationPath = "\\server\folder1\"

Copy-Item -Path $SourcePath -Destination $DestinationPath\$FolderName -Recurse -Force


Viewing all articles
Browse latest Browse all 6937

Trending Articles