diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index e10a440..ee2c8da 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -27,7 +27,7 @@ $PAth_To_Migration_Status = "M:\00 - Egnyte PS Data Inventory\Migration_status\M $PathToDB = "M:\IT\Egnyte\DuplicateFiles\WorkingRun\Dedupe.SQLite" $OutputFolder = "M:\IT\Egnyte\DuplicateFiles\WorkingRun\Output" $BaseDrive = 'X:\' -$ProjectRegex = '^X:\\[A-Z]{2}\W\d+' +$ProjectRegex = '^X:\\[A-Z]{2}\W[a-zA-Z0-9 ]*\\' $OfficeList = Get-ChildItem -Path $BaseDrive -Directory -Depth 0 if ($Refresh) { @@ -149,7 +149,7 @@ server,path,path2,etc,status,OriginalServer=RD,OriginalProject=ProjectNumber #> - +$DBConnect = New-SqliteConnection -DataSource $PathToDB <# Get Migration Status CREATE TABLE "MigrationStatus" ( "MigrationID" TEXT NOT NULL UNIQUE, @@ -208,7 +208,7 @@ Invoke-SqliteQuery -DataSource $PathToDB -Query $Query # $SQLFile_to_Run = $PSScriptRoot + '\DuplicatePairing.sql' # Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run -$DBConnect = New-SqliteConnection -DataSource $PathToDB + # foreach ($office in $OfficeList) { # $OfficeServer = $office.Name @@ -278,6 +278,32 @@ if ($EgnyteExport) { $EgnyteExport | Export-Excel -Path $OutFile -AutoFilter } +$OutFile = $OutputFolder + "\FULL MPE Data Inventory " + (Get-Date -Format FileDate) + ".xlsx" +try { + + Remove-Item -Path $OutFile -Force -ErrorAction SilentlyContinue +} +catch { + <#Do this if a terminating exception happens#> +} +$Query = 'Select * from ( + SELECT SERVER, + REPLACE( + Parent, + "X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(REPLACE(Parent,("\\mpe.ca\datadrive\" || Server),REPLACE("/Shared/N-Data/" || Server || "_/","_/","_")),"\","/"),"_/","_") AS EgnytePath, + sum(FileCount) as FileCount, Sum(FileSize) as FileSize, Status, fld_MigrationID,MigrationName from FolderData + LEFT JOIN MigrationStatus on FolderData.fld_MigrationID = MigrationID +-- WHERE FolderData.fld_MigrationID IS NULL +GROUP by UNCPath +ORDER by UNCPath +);' +$FullEgnyteExport = Invoke-SqliteQuery -DataSource $PathToDB -Query $Query +if ($FullEgnyteExport) { + + $FullEgnyteExport | Export-Excel -Path $OutFile -AutoFilter +} + $DBConnect.Close()