diff --git a/Generate Egnyte Export-old.sql b/Generate Egnyte Export-old.sql new file mode 100644 index 0000000..769ca20 --- /dev/null +++ b/Generate Egnyte Export-old.sql @@ -0,0 +1,24 @@ +-- Generate Non-Duplicated PARENT FOLDER List +DROP TABLE DataInventory; +CREATE TABLE DataInventory AS +Select * from ( + SELECT SERVER, + REPLACE( + Parent, + "X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(Parent,("\\mpe.ca\datadrive\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, + sum(FileCount) as FileCount, Sum(FileSize) as FileSize, 'Parent' as Source, Status from FolderData + Where Parent in ( + SELECT Parent FROM NonDupParent + ) + AND FolderData.fld_MigrationID IS NULL +GROUP by UNCPath +) +union +SELECT SERVER, + REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(PATH,("\\mpe.ca\datadrive\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, + FileCount, FileSize, 'Project' as Source, Status from FolderData +Where FolderData.Project in ( + SELECT Project FROM NonDupProject) +AND FolderData.fld_MigrationID IS NULL; \ No newline at end of file diff --git a/Generate Egnyte Export.sql b/Generate Egnyte Export.sql index 769ca20..c4a0f39 100644 --- a/Generate Egnyte Export.sql +++ b/Generate Egnyte Export.sql @@ -1,24 +1 @@ --- Generate Non-Duplicated PARENT FOLDER List -DROP TABLE DataInventory; -CREATE TABLE DataInventory AS -Select * from ( - SELECT SERVER, - REPLACE( - Parent, - "X:\","\\mpe.ca\datadrive\") AS UNCPath, - REPLACE(REPLACE(Parent,("\\mpe.ca\datadrive\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, - sum(FileCount) as FileCount, Sum(FileSize) as FileSize, 'Parent' as Source, Status from FolderData - Where Parent in ( - SELECT Parent FROM NonDupParent - ) - AND FolderData.fld_MigrationID IS NULL -GROUP by UNCPath -) -union -SELECT SERVER, - REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath, - REPLACE(REPLACE(PATH,("\\mpe.ca\datadrive\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, - FileCount, FileSize, 'Project' as Source, Status from FolderData -Where FolderData.Project in ( - SELECT Project FROM NonDupProject) -AND FolderData.fld_MigrationID IS NULL; \ No newline at end of file +DROP TABLE IF EXISTS DataInventory; \ No newline at end of file diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index ae91961..fdb5ea3 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -55,7 +55,7 @@ $OfficeList | ForEach-Object -parallel { $XDrivePath = $_.FullName # Write-Host "Processing " $_.FullName -ForegroundColor Green - $ProjectFolders = get-childitem $_.FullName -Directory -Depth 2 | Where-Object FullName -Match $USING:ProjectRegex + $ProjectFolders = get-childitem $_.FullName -Directory -Depth 1 | Where-Object FullName -Match $USING:ProjectRegex # $ProjectFolders now contains all folders down to the 3rd level of project number - for Example, 1234-567-001. We can now generate a project number for the output file. # We need to get a file count for each "last" folder - IE, 001 in the example 1234-567-001. @@ -108,7 +108,7 @@ $OfficeList | ForEach-Object -parallel { $Path = $Path.Replace("X:\", "\\mpe.ca\datadrive\") $projectnumber = $result.tostring() $DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy - $Query = "Select Project,fld_LastRefresh FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";" + $Query = "Select Project,fld_LastRefresh FROM FolderData where Server = '$Server' AND Path = `"$Path`";" $sql_result = Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query @@ -123,7 +123,7 @@ $OfficeList | ForEach-Object -parallel { 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`"" + $Query = "Delete from FolderData WHERE Server = '$Server' AND Path = `"$Path`"" Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $Query @@ -146,7 +146,6 @@ $OfficeList | ForEach-Object -parallel { $out = [PSCustomObject]@{ Server = $Server - Project = $ProjectNumber.ToString() Parent = $folder_Parent Path = $Path FileCount = $folder_FileCount