我会将此添加到我的其他帖子,但我无法找到它。我一直在试图从一个UNC(源)复制图像(JPG和JPEG)到三天内的两个UNC(目的地)。我只需要复制图像,而不是它们包含的文件夹。图像不从一个UNC移动到另一个UNC
我没有收到任何错误,从脚本收到的电子邮件告诉我没有图像被复制。目的地没有任何图像复制到它们,并且源图像中的图像比今天的日期早三天。我完全失去了。我一直在谷歌上试图找出这个目前无济于事。任何建议,将不胜感激。
$ImageLocation = "\\vdifiles\Print-Room\FileSrv\Barcode-Order"
$TestSite = "\\10.0.100.3\www2.varietydistributors.com\catalog\newpictures"
$LiveSite = "\\10.0.100.3\Variety Distributors.com\catalog\newpictures"
$WhenFileWritten = (get-date).AddDays(-3)
$IncludeFileTypes = "*.jpeg,*.jpg"
$LogFile = "C:\Temp\FilesCopied.log"
$EmailServer = "emailserver.me.com"
$EmailFrom = "[email protected]"
$AuthUser = "user"
$AuthPass = "pass"
$XHeaderInfo = "X-Header: This email was sent from Laservault."
$EmailTo = "[email protected]"
$EmailSubject = "Barcode Images Summary."
$EmailBodySent = "Attached to this email is a log file of what images were copied from $ImageLocation to $TestSite and $LiveSite as well as sent to AS2 to send over to Order Stream."
$EmailBodyNotSent = "There were no files in $ImageLocation that matched $WhenFileWritten days old. So, nothing was sent to $TestSite, $LiveSite or AS2."
$TheImages = get-childitem "Microsoft.PowerShell.Core\FileSystem::$ImageLocation" -recurse | where-object {$_.Extension -eq $IncludeFileTypes -and $_.LastWriteTime -gt $WhenFileWritten -and $_.PsIsContainer -eq $false}
foreach ($Images in $TheImages) {
$FileCount = $Images.count
if ($FileCount -gt 0) {
copy-item -path $Images.FullName -destination "Microsoft.PowerShell.Core\FileSystem::$TestSite" -force
copy-item -path $Images.FullName -destination "Microsoft.PowerShell.Core\FileSystem::$LiveSite" -force
write-host "$FileCount files were copied."
write-output $Images >> $LogFile
\\vdifiles\blat$\blat.exe -attach $LogFile -to $EmailTo -s $EmailSubject -i $EmailFrom -body $EmailBodySent -server $EmailServer -u $AuthUser -pw $AuthPass -f $EmailFrom -x $XHeaderInfo
remove-item $LogFile
} else {
\\vdifiles\blat$\blat.exe -to $EmailTo -s $EmailSubject -i $EmailFrom -body $EmailBodyNotSent -server $EmailServer -u $AuthUser -pw $AuthPass -f $EmailFrom -x $XHeaderInfo
}
}
现在,我没有收到电子邮件,也没有将文件从源UNC复制到目标UNC。这是我的: – user3013729
$ TheImages = get-childitem“Microsoft.PowerShell.Core \ FileSystem :: $ ImageLocation”-include $ IncludeFileTypes -exclude $ ExcludeFileTypes -recurse |对象{$ _。LastWriteTime -gt $ WhenFileWritten和$ _。PsIsContainer -eq $ false} – user3013729
$ IncludeFileTypes =“* .jpeg”,“*。jpg” $ ExcludeFileTypes =“* .psd”,“* .tif“,”*。pdf“ – user3013729