|
####User Params Here ################################## |
|
# Path to the Create-Dashboard.ps1 file |
|
$PathToCreateDashboard = "C:\Users\Stephen\Dropbox\My Code\Powershell\Dashboard\Create-BlogDashboard.ps1" |
|
|
|
# \/ This should be the path to your Dropbox camera Uploads folder |
|
$cameraFolder = "C:\Users\Stephen\Dropbox\Camera Uploads" |
|
|
|
# \/ Files are MOVED from your Dropbox folder to this path |
|
$BackupFolder = "g:\Photos\LG g4" |
|
|
|
# \/ Place to create status reports |
|
$StatusReportPath = "g:\backups" |
|
|
|
# \/ Specify the maximum age of files in days here. Anything older than this is moved out of the $cameraFolder path |
|
$MoveFilesOlderThanAge = "-18" |
|
|
|
####End user params ##################################### |
|
|
|
$cutoverDate = ((get-date).AddDays($MoveFilesOlderThanAge)) |
|
|
|
$backupFiles = new-object System.Collections.ArrayList |
|
|
|
$filesToMove = Get-ChildItem $cameraFolder | Where-Object LastWriteTime -le $cutoverDate |
|
$itemCount = $filesToMove | Measure-Object | select -ExpandProperty Count |
|
$FileSize = $filesToMove | Measure-Object -Sum Length |
|
|
|
if ($itemCount -eq 0){return} |
|
|
|
write-host "Moving files older than $cutoverDate, of which there are `n`t`t`t`t" -nonewline |
|
write-host -fore yellow $itemcount |
|
|
|
|
|
[int](gc c:\temp\picSpace.txt) + [int]$FileSize.Sum | Set-content c:\temp\picSpace.txt |
|
[int](gc c:\temp\totalmoved.txt) + [int]$itemCount | set-content c:\temp\totalmoved.txt |
|
|
|
$movelog = import-csv c:\temp\movelog.csv |
|
"$([int]$movelog[-1].Day+1),$itemCount,$(($filesToMove | ? Extension -ne .mp4).Count),$(($filesToMove | ? Extension -eq .mp4).Count)" | Add-Content C:\temp\movelog.csv |
|
|
|
$filesToMove | ForEach-Object { |
|
[void]$backupFiles.Add((Move-Item -Destination $BackupFolder -Path $_.FullName -PassThru -Force| select BaseName,Extension,@{Name=‘FileSize‘;Expression={"$([math]::Round($_.Length / 1MB)) MB"}},Length,Directory)) |
|
Start-Sleep -Milliseconds 25 |
|
} |
|
|
|
$companyLogo = '<div align=left><img src="http://127.0.0.1/Style/logo.png"></div>' |
|
$header = @" |
|
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/Style/style.css" /> |
|
|
|
$companyLogo |
|
<h1>File export from Dropbox Report</h1> |
|
<p>The following automated report was generated at $(Get-Date) and contains the $itemcount files which were older than |
|
$([math]::Abs($MoveFilesOlderThanAge)) days. <Br><Br>This backup job was executed on System: $($Env:Computername)</p> |
|
|
|
|
|
<hr> |
|
"@ |
|
|
|
$post = @" |
|
<h3>These items were moved to <b>$BackupFolder</b> for archiving to Azure</h3> |
|
"@ |
|
|
|
$backupFiles | select BaseName,Extension,@{Name=‘FileSize‘;Expression={"$([math]::Round($_.Length / 1MB)) MB"}},Length,Directory | export-csv -NoTypeInformation "G:\Backups\FileList__$((Get-Date -UFormat "%Y-%m-%d"))_Log.csv" |
|
|
|
$HTMLbase = $backupFiles | ConvertTo-Html -Head $header ` |
|
-Title ("Dropbox Backup Report for $((Get-Date -UFormat "%Y-%m-%d"))") ` |
|
-PostContent $post |
|
|
|
$HTMLbase | out-file $StatusReportPath\DropboxBackup_$((Get-Date -UFormat "%Y-%m-%d"))_Log.html |
|
|
|
& $PathToCreateDashboard -i (get-random -min 8230 -Maximum 8450) |
|
|
|
read-host "Press any button to exit (will close the window)" |
|
timeout 30 |