From 111f4dbb916a421e3fa2e44527f5bc02b57a5747 Mon Sep 17 00:00:00 2001 From: eeckert Date: Fri, 15 Sep 2023 11:03:39 -0600 Subject: [PATCH] clean up output folder if needed. --- Get-ProjectFolders.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index b506e6a..dcbe786 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -178,6 +178,7 @@ foreach ($office in $OfficeList) { if ($sql_result) { $OutFile = $OutputFolder + "\$OfficeServer Duplicates.xlsx" + Remove-Item -Path $OutFile -Force $sql_result | Export-Excel -Path $OutFile -AutoFilter } @@ -188,6 +189,7 @@ $sql_result = Invoke-SqliteQuery -DataSource $PathToDB -Query $Query if ($sql_result) { $OutFile = $OutputFolder + "\MPE All Duplicates.xlsx" + Remove-Item -Path $OutFile -Force $sql_result | Export-Excel -Path $OutFile -AutoFilter } @@ -199,6 +201,7 @@ $sql_result = Invoke-SqliteQuery -DataSource $PathToDB -Query $Query if ($sql_result) { $OutFile = $OutputFolder + "\MPE Non-Duplicates - Parent Folders.xlsx" + Remove-Item -Path $OutFile -Force $sql_result | Export-Excel -Path $OutFile -AutoFilter } @@ -211,6 +214,7 @@ $sql_result = Invoke-SqliteQuery -DataSource $PathToDB -Query $Query if ($sql_result) { $OutFile = $OutputFolder + "\MPE Non-Duplicates - Project Folders.xlsx" + Remove-Item -Path $OutFile -Force $sql_result | Export-Excel -Path $OutFile -AutoFilter } @@ -218,10 +222,12 @@ if ($sql_result) { ## Generate Egnyte Data Inventory Sheet $OutFile = $OutputFolder + "\MPE Data Inventory " + (Get-Date -Format FileDateTime).DateTime + ".xlsx" +Remove-Item -Path $OutFile -Force $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 }