Hello all. I'm trying to create a script that will run on an AWS instance with local drives that will copy each drive to a corresponding AWS FSX drive that is also mapped to the local machine. If I create the script in PS ISE and run, things seem to process as expected, but when I create a Scheduled job it never runs.
Any idea's?
$directories = @(
@{"Source"="H:\";"Destination"="W:\D$";"Log"="C:\devops\logs\robocopy\$((Get-Date -Format MMddyy_hhmmss))_coursesdev.log"}
@{"Source"="I:\";"Destination"="X:\D$";"Log"="C:\devops\logs\robocopy\$((Get-Date -Format MMddyy_hhmmss))_courseslive.log"}
@{"Source"="J:\";"Destination"="Y:\D$";"Log"="C:\devops\logs\robocopy\$((Get-Date -Format MMddyy_hhmmss))_companyfiles.log"}
@{"Source"="K:\";"Destination"="Z:\D$";"Log"="C:\devops\logs\robocopy\$((Get-Date -Format MMddyy_hhmmss))_othercontent.log"}
)
foreach($directory in $directories){
$scriptBlock = {
Param($SourceDir, $DestDir, $LogLocation)
robocopy $SourceDir $DestDir /xd RECYCLE.BIN "System Volume Information" /mir /W:1 /R:1 /MT:24 /log:$LogLocation
}
Start-Job -ScriptBlock $scriptBlock -ArgumentList $directory.Source, $directory.Destination, $directory.Log
}