add folder refesh after 15 days as well
This commit is contained in:
parent
fb1225060e
commit
f8bc020aa7
@ -101,23 +101,33 @@ $OfficeList | ForEach-Object -parallel {
|
|||||||
# Write-Progress @CurentLoopProgress
|
# Write-Progress @CurentLoopProgress
|
||||||
}
|
}
|
||||||
elseif ($result.Length -ge 5) {
|
elseif ($result.Length -ge 5) {
|
||||||
|
$RefreshDays = -15
|
||||||
|
|
||||||
$Server = $_.FullName.Substring(1, 4) -replace (':|\\', '')
|
$Server = $_.FullName.Substring(1, 4) -replace (':|\\', '')
|
||||||
$Path = $_.FullName.Replace("'", "`'") #SQL Formatted Path
|
$Path = $_.FullName.Replace("'", "`'") #SQL Formatted Path
|
||||||
$Path = $Path.Replace("X:\", "\\mpe.ca\datadrive\")
|
$Path = $Path.Replace("X:\", "\\mpe.ca\datadrive\")
|
||||||
$projectnumber = $result.tostring()
|
$projectnumber = $result.tostring()
|
||||||
$DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy
|
$DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy
|
||||||
$Query = "Select Project FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";"
|
$Query = "Select Project,fld_LastRefresh FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";"
|
||||||
$sql_result = Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query
|
$sql_result = Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query
|
||||||
|
|
||||||
if (($sql_result.project -eq $null)) {
|
|
||||||
|
if (($sql_result.project -eq $null) -or ($sql_result.fld_LastRefresh -le (Get-Date).AddDays($RefreshDays).ToShortDateString())) {
|
||||||
$CurentLoopProgress = @{
|
$CurentLoopProgress = @{
|
||||||
ID = $JobID
|
ID = $JobID
|
||||||
Activity = "Loading Telemetry for " + $_.FullName
|
Activity = "Loading Telemetry for " + $_.FullName
|
||||||
PercentComplete = 75
|
PercentComplete = 75
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Progress @CurentLoopProgress
|
Write-Progress @CurentLoopProgress
|
||||||
|
|
||||||
|
if ($sql_result.project -ne $null) {
|
||||||
|
# found a record, but needs updating - delete old record from DB
|
||||||
|
$Query = "Delete from FolderData WHERE '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`""
|
||||||
|
Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
|
$result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
|
||||||
$FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse
|
$FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse
|
||||||
@ -145,6 +155,7 @@ $OfficeList | ForEach-Object -parallel {
|
|||||||
FileLastAccess = $folder_LastAccess
|
FileLastAccess = $folder_LastAccess
|
||||||
Status = $null # added to support Migration Status
|
Status = $null # added to support Migration Status
|
||||||
fld_MigrationID = $null
|
fld_MigrationID = $null
|
||||||
|
fld_LastRefresh = (Get-Date).ToShortDateString()
|
||||||
} | Out-DataTable
|
} | Out-DataTable
|
||||||
|
|
||||||
Invoke-SQLiteBulkCopy -DataSource $PathToDB_Copy -Table "FolderData" -DataTable $out -Force
|
Invoke-SQLiteBulkCopy -DataSource $PathToDB_Copy -Table "FolderData" -DataTable $out -Force
|
||||||
|
Loading…
Reference in New Issue
Block a user