From f42a5cd0795ae2282d3d21d6a0d008954d560988 Mon Sep 17 00:00:00 2001 From: eeckert Date: Thu, 14 Sep 2023 15:29:46 -0600 Subject: [PATCH] autmate egnte inventory sheet --- Generate Egnyte Export.sql | 22 ++++++++++++++++++++++ Get-ProjectFolders.ps1 | 13 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Generate Egnyte Export.sql diff --git a/Generate Egnyte Export.sql b/Generate Egnyte Export.sql new file mode 100644 index 0000000..6826a8c --- /dev/null +++ b/Generate Egnyte Export.sql @@ -0,0 +1,22 @@ +-- Generate Non-Duplicated PARENT FOLDER List +DROP TABLE DataInventory; +CREATE TABLE DataInventory AS +SELECT SERVER, + REPLACE(Parent,"X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(Parent,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, + sum(FileCount), Sum(FileSize), 'Parent' as Source from FolderData +Where Parent not in ( + SELECT Parent FROM DuplicateList +) +UNION +SELECT SERVER, + REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, + sum(FileCount), Sum(FileSize), 'Project' as Source from FolderData +Where Project not in ( + SELECT A.Project FROM NonDupProject as A) +AND Parent not in ( + Select B.Parent FROM NonDupParent as B + ) +group by Server +ORDER BY Server; diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index c7e1982..6339df1 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -215,6 +215,19 @@ if ($sql_result) { } +## Generate Egnyte Data Inventory Sheet + +$OutFile = $OutputFolder + "\MPE Data Inventory " + (Get-Date -Format FileDateTime).DateTime + ".xlsx" +$SQLFile_to_Run = $PSScriptRoot + '\Generate Egnyte Export.sql' +$EgnyteExport = Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run + +if ($EgnyteExport) { + $OutFile = Export-Excel -Path $OutputFile -AutoFilter +} + + + + $DBConnect.Close()