Modifying an existing Move-Item script with Robocopy mirror section

Hi all

I am a newbie to Powershell, and with a lot of Googling I managed to get this script put together that does what I need for moving files.

I want to use this script to mirror folders and files, and I know that Powershell cannot do Mirror, so I want to replace the move part with a Robocopy job, but cannot get it to work

function Write-Log($string)
$outStr = "" + $Timestamp +" "+$string

Write-Output $outStr


Function Start-Moving




$Timestamp = Get-Date -Format "yyyy-MM-ddTHH-mm-ss"
$Log = "C:\support\scripts\logs\" + $JobLog + " " + $Timestamp + ".log"

Start-Transcript -path $Log -append -Force -NoClobber
try {

Write-Log "------------ Start of Log ------------"
#Write-Log ""

# get all file objects to use in moving
$files=Get-ChildItem -path $JobFolderFrom -Recurse -File

# Move the file and its folder.
$files |
Write-Log " Moving File --> $_. To $JobFolderTo"; Move-Item $_.Fullname -Destination $JobFolderTo 

# output statistics
Write-Output "**********************"
Write-Output "Number of old files moved: $($files.Count)"
Write-Log "------------- End of Log -------------"



Start-Moving -JobTime -5 -JobFolderFrom 'C:\Test1' -JobFolderTo 'C:\Test2' -JobLog 'Test1'

Without digging into your code … robocopy is able to move files as well and it’s able to log its actions. You actually don’t need a script.

Try looking at these to give you any additional edification to accomplish your use case.\FileSystem.ps1

Cheers guys

I will have a look at your suggestions

I had a look at both example scripts, but cannot find where to add my source and destination folders

I tried a few things, but running the scripts, nothing happens. No errors, no log

Probably there will not be some ready to use scripts fitting exactly your requirements. Of course you will have to adapt it to your needs.