$WarningPreference = "SilentlyContinue" if ((Test-Path "${env:ProgramFiles}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1") -eq $true){ $module = "${env:ProgramFiles}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1" } elseif ((Test-Path "${env:ProgramFiles(x86)}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1") -eq $true){ $module = "${env:ProgramFiles(x86)}\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI.psd1" } else { if ($debug -eq $true){ Write-Host "Can't find BackupExec API Script. Aborting..." } else { Write "255" exit 255 } } Import-Module $module # 1 is ok, so no sunday found $sunday = "1" $tapelib = Get-BEStorage | where { $_.StorageType -eq "RoboticLibraryDevice" } $medias = Get-BEMedia | where { $_.LocationName -eq $tapelib.Name -and $_.MediaSet -ne "Cleaning Media" } foreach ($media in $medias) { if ($media.AllocatedDate.DayOfWeek -eq "Sunday") { $curr_date = get-date # check if tape is from last backup or reinserted tape from rotation if ($media.AllocatedDate -gt $curr_date.adddays(-20)) { # change sunday to 0, because 0 is problem = sunday found $sunday = 0 } } } write $sunday