diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index dcbe786..6f83abf 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -221,14 +221,21 @@ if ($sql_result) { ## Generate Egnyte Data Inventory Sheet -$OutFile = $OutputFolder + "\MPE Data Inventory " + (Get-Date -Format FileDateTime).DateTime + ".xlsx" -Remove-Item -Path $OutFile -Force +$OutFile = $OutputFolder + "\MPE Data Inventory " + (Get-Date -Format FileDateTime) + ".xlsx" +try { + + Remove-Item -Path $OutFile -Force -ErrorAction SilentlyContinue +} +catch { + <#Do this if a terminating exception happens#> +} $SQLFile_to_Run = $PSScriptRoot + '\Generate Egnyte Export.sql' -$EgnyteExport = Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run +Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run +$EgnyteExport = Invoke-SqliteQuery -DataSource $PathToDB -Query "Select * from DataInventory" if ($EgnyteExport) { - $OutFile = Export-Excel -Path $OutputFile -AutoFilter + $EgnyteExport | Export-Excel -Path $OutFile -AutoFilter }