I think WMI is the best way to go for this. I just wrote this but did not
test it. It could also use some more error checking. If I get the change
over the weekend I will test and improve it. If you make changes and
improve it, please post it for other to see and use.
$strSource = "c:\test"
$strTarget = "c:\ftp\test"
function CopyDir([string]$strSource, [string]$strTarget)
{
$strComputer = "."
$colFolder = Get-WmiObject -Class Win32_Directory -namespace
"root\CIMV2" -computername $strComputer | where{$_.name -eq $strSource}
foreach($objFolder in $colFolders)
{
[int]$errResults = $colFolders.CopyEx($strTarget)
switch($errResults)
{
0 {Write-Host "The request was successful."}
2 {Write-Host "Access was denied."}
8 {Write-Host "An unspecified failure occurred."}
9 {Write-Host "The name specified was invalid."}
10 {Write-Host "The object specified already exists."}
11 {Write-Host "The file system is not NTFS."}
12 {Write-Host "The platform is not Windows 2000 or Windows NT."}
13 {Write-Host "The drive is not the same."}
14 {Write-Host "The directory is not empty."}
15 {Write-Host "There has been a sharing violation."}
16 {Write-Host "The start file specified was invalid."}
17 {Write-Host "A privilege required for the operation is not held."}
21 {Write-Host "A parameter specified is invalid."}
}
}
}
"Flea#" <Flea@xxxxxx> wrote in message
news:7B82DEE2-26C3-46AB-9636-4F45655DE2F9@xxxxxx
> Hello all,
>
> I am wanting to have a powershell script run each morning that will
> perform
> back up of several directories, containing hundreds of files. The
> Copy-Item
> cmd-let works great for copying the directories, but, I didn't see an
> explicit option to set that will only back up the files that are different
> or
> don't exist, thus giving me an incremental backup? The files are to large
> to
> just do a force overwrite each time.
>
> Before I delve into writing custom functions to perform this task, I was
> wondering if there was an easy option or property I was missing that will
> do
> this?
>
> Thanks,
> Flea#
> --
> http://fleasharp.blogspot.com/