So I have done alot of searching without luck.
I'm doing a one way sync Local to Remote(FTP) via Powershell
It's working great and I worked in some reporting and email.
Problem
One thing I can't figure out how to do....
I want to capture a list of any files that are removed on the FTP site (because they no longer exist locally).
However I can't find an event or example to do that.
I found an example using
Get-ChildItem -Recurse But that was designed to capture the local directory before and after.
I need to either list the FTP site before and after to compare or discover an event I haven't found that will let me append to my log file what was removed.
Seems like a worthy Feature Request for SynchronizeDirectories :D
And this isn't a must but if anyone has any ideas on how I can tell the difference between a new file uploaded vs an existing file I just updated from local that would be nice
function FileTransferred
{
param ($e)
if ($e.Error -eq $Null)
{
Write-Host ("Upload of {0} succeeded" -f $e.FileName)
Add-Content -Path $LogFile -Value ( "`nUpload of file succeeded"+" "+$e.FileName )
}
else
{
Write-Host ("Upload of {0} failed: {1}" -f $e.FileName, $e.Error)
Add-Content -Path $LogFile -Value ( "`nUpload of file failed: "+" "+$e.FileName+" Error: "+$e.Error )
}
<# if ($e.Chmod -ne $Null)
{
if ($e.Chmod.Error -eq $Null)
{
Write-Host ("Permisions of {0} set to {1}" -f $e.Chmod.FileName, $e.Chmod.FilePermissions)
}
else
{
Write-Host ("Setting permissions of {0} failed: {1}" -f $e.Chmod.FileName, $e.Chmod.Error)
}
}
else
{
Write-Host ("Permissions of {0} kept with their defaults" -f $e.Destination)
}
if ($e.Touch -ne $Null)
{
if ($e.Touch.Error -eq $Null)
{
Write-Host ("Timestamp of {0} set to {1}" -f $e.Touch.FileName, $e.Touch.LastWriteTime)
}
else
{
Write-Host ("Setting timestamp of {0} failed: {1}" -f $e.Touch.FileName, $e.Touch.Error)
}
}
else
{
# This should never happen during "local to remote" synchronization
Write-Host ("Timestamp of {0} kept with its default (current time)" -f $e.Destination)
}#>
}
Thanks,
Kenny :)