Write-Host "Copying the $SrcFile2" -ForegroundColor YellowĬopy-Item -Path "$SrcFolder\$SrcFile2" -Recurse -Destination "$DstFolder\$Date - $SrcFile2" -ErrorAction Silentl圜ontinue Log File is in $Logs" -ForegroundColor RedĪdd-Content "$Logs\Log - $Date.txt" -Value "$SrcFile1 not copied because $($Error)" Write-Host "Completed" -ForegroundColor Green Write-Host "Copying the $SrcFile1" -ForegroundColor YellowĬopy-Item -Path "$SrcFolder\$SrcFile1" -Recurse -Destination "$DstFolder\$Date - $SrcFile1" -ErrorAction Silentl圜ontinue $Date = Get-Date -Format "dd-MM-yyyy-dddd HH-mm" A fail safe, if the transfer does not work alert the user and stop the process, plus if feasible log the failed outcome as per step 3. Is it possible to have a window or progress indicator which has information for the user to see how the operation is progressing.ĥ. Save the txt file to a local folder, so over time I will build up a record when files are transferred.Ĥ. Also, create a simple log or txt to record each file being transferred, log the new filename, outcome fail or saved, date, time and file size when it was transferred. Save each file to a new location(could be two separate location for each) with a new filename using the following naming convention "dd-mm-yyyy - hhmmss - ". Script to copy the two files regardless if they are open at source.Ģ. I am wanting to automate the process of copying 2 MS Excel files each has a separate defined name, the source name never changes but the files are used constantly so someone may have these files open.ġ. Not sure if PowerShell is design for this, I was thinking back to the days when you would create a BAT file.
0 Comments
Leave a Reply. |