I have run this script about 5 times. The first 2 - 3 it worked to perfection, but the last 2 it is not copying over all files, and I can not figure out why...Can someone examine this code and let me know why it won't copy all files from my local folder to my Z: drive?
clear-host
#1st manually assign drive letter
$USBDriveLetter="Z"
$USBDriveBackupPath="Z:\"
$erroractionpreference = "Continue"
try
{
if(Test-Path $USBDriveBackupPath)
{
invoke-expression "Robocopy C:\Users\Owner\Videos\ $USBDriveBackupPath\ /s /MIR /R:5 /COPY:DAT /NP"
Start-Sleep -Seconds 60
Invoke-Expression "c:\DevCon\USB_Disk_Eject /removeletter $USBDriveLetter"
}
}
catch
{
Start-Sleep -Seconds 60
Invoke-Expression "c:\DevCon\USB_Disk_Eject /removeletter $USBDriveLetter"
}