我會將此添加到我的其他帖子,但我無法找到它。我一直在試圖從一個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