Adjust Output for new method.

This commit is contained in:
Erik Eckert 2023-10-04 14:56:27 -06:00
parent b56a41f5ec
commit 374c91715b

View File

@ -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" $PathToDB = "M:\IT\Egnyte\DuplicateFiles\WorkingRun\Dedupe.SQLite"
$OutputFolder = "M:\IT\Egnyte\DuplicateFiles\WorkingRun\Output" $OutputFolder = "M:\IT\Egnyte\DuplicateFiles\WorkingRun\Output"
$BaseDrive = 'X:\' $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 $OfficeList = Get-ChildItem -Path $BaseDrive -Directory -Depth 0
if ($Refresh) { if ($Refresh) {
@ -149,7 +149,7 @@ server,path,path2,etc,status,OriginalServer=RD,OriginalProject=ProjectNumber
#> #>
$DBConnect = New-SqliteConnection -DataSource $PathToDB
<# Get Migration Status <# Get Migration Status
CREATE TABLE "MigrationStatus" ( CREATE TABLE "MigrationStatus" (
"MigrationID" TEXT NOT NULL UNIQUE, "MigrationID" TEXT NOT NULL UNIQUE,
@ -208,7 +208,7 @@ Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
# $SQLFile_to_Run = $PSScriptRoot + '\DuplicatePairing.sql' # $SQLFile_to_Run = $PSScriptRoot + '\DuplicatePairing.sql'
# Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run # Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run
$DBConnect = New-SqliteConnection -DataSource $PathToDB
# foreach ($office in $OfficeList) { # foreach ($office in $OfficeList) {
# $OfficeServer = $office.Name # $OfficeServer = $office.Name
@ -278,6 +278,32 @@ if ($EgnyteExport) {
$EgnyteExport | Export-Excel -Path $OutFile -AutoFilter $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() $DBConnect.Close()