logic update...

This commit is contained in:
Erik Eckert 2023-09-15 13:04:44 -06:00
parent aec05f5f69
commit 8280190842
2 changed files with 31 additions and 20 deletions

View File

@ -1,24 +1,35 @@
-- Generate Non-Duplicated PARENT FOLDER List
DROP TABLE DataInventory;
CREATE TABLE DataInventory AS
SELECT SERVER,
Select * from (
SELECT SERVER,Parent,
REPLACE(
Parent,
"X:\"," \ \ mpe.ca \ datadrive \ ") AS UNCPath,
REPLACE(REPLACE(Parent,(" X: \ " || Server)," / Shared / N - Data ")," \ "," / ") AS EgnytePath,
"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 (
Where Parent != (
SELECT Parent FROM DuplicateList
)
GROUP by UNCPath
)
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
SELECT SERVER, Parent,
REPLACE(PATH," X:\","\\mpe.ca\datadrive\") AS UNCPath,
REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath,
FileCount, FileSize, 'Project' as Source from FolderData
Where FolderData.Project NOT in (
SELECT A.Project FROM DuplicateList as A)
AND FolderData.Parent in (
Select B.Parent FROM DuplicateList as B
);
delete FROM DataInventory
where Parent in (
select Parent from DataInventory
group by Parent
HAVING count(*) > 1
)
group by Server
ORDER BY Server;
and Source = 'Project';

View File

@ -221,7 +221,7 @@ if ($sql_result) {
## Generate Egnyte Data Inventory Sheet
$OutFile = $OutputFolder + "\MPE Data Inventory " + (Get-Date -Format FileDateTime) + ".xlsx"
$OutFile = $OutputFolder + "\MPE Data Inventory " + (Get-Date -Format FileDate) + ".xlsx"
try {
Remove-Item -Path $OutFile -Force -ErrorAction SilentlyContinue