Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

bgordon151

Attempting To Syncronize To SharePoint Writes The Log File But Won't Write The Sync Data

I have a powershell script that works perfectly if I use a UNC path to a location on my network however when I try to sync the files from the source on my LAN to a local path representing a OneDrive folder, I am only successful it getting it to write the log file in the remote location. The actual data I want to sync never seems to write to the remote location and the logs seem to have it ignoring the path to the local (really OneDrive remote) location and instead showing that it is looking to c:\windows\syswow64..

I have attached a sample redacted log to show the behavior. What is odd is that it will write the log to the sharepoint/onedrive location using the same path but seems to ignore that path for the actual synchronize command and default to c:\windows\syswow64...

Here is the script (edited to make it ambiguous)
$targets = @{}
$targets.Add("10.10.10.10","source1")
$targets.Add("10.10.10.11","source2")
$logsource = "/path/to/source/data/"
 
foreach ($target in $targets.keys) {
    $targetpath = "C:\Users\myusername\MY SHAREPOINT\Shared Resource - Documents\Logs"
    $targetname = $targets[$target].ToUpper()
    $targetpath = $targetpath + "\" + $targetname
 
    & "C:\Program Files (x86)\WinSCP\WinSCP.com" `
    /log="$targetpath\logs\$targetname-!S-!Y-!M-!D.log" /ini=nul `
    /command `
    "open ftp://sourceIP:password@$target/ -passive=0" `
    "synchronize local "$target" "$logsource"" `
    "exit"
 
    $winscpResult = $LastExitCode
    Write-Host Result $winscpResult
}