Convert to UNC PAth everywhere
This commit is contained in:
parent
0dcfba2fec
commit
f7f05aa454
@ -103,6 +103,7 @@ $OfficeList | ForEach-Object -parallel {
|
|||||||
elseif ($result.Length -ge 5) {
|
elseif ($result.Length -ge 5) {
|
||||||
$Server = $_.FullName.Substring(1, 4) -replace (':|\\', '')
|
$Server = $_.FullName.Substring(1, 4) -replace (':|\\', '')
|
||||||
$Path = $_.FullName.Replace("'", "`'") #SQL Formatted Path
|
$Path = $_.FullName.Replace("'", "`'") #SQL Formatted Path
|
||||||
|
$Path = $Path.Replace("X:\", "\\mpe.ca\datadrive\")
|
||||||
$projectnumber = $result.tostring()
|
$projectnumber = $result.tostring()
|
||||||
$DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy
|
$DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy
|
||||||
$Query = "Select Project FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";"
|
$Query = "Select Project FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = `"$Path`";"
|
||||||
@ -121,6 +122,7 @@ $OfficeList | ForEach-Object -parallel {
|
|||||||
$result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
|
$result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
|
||||||
$FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse
|
$FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse
|
||||||
$folder_Parent = $result3.value.replace("'", "`'") #SQL Formatting
|
$folder_Parent = $result3.value.replace("'", "`'") #SQL Formatting
|
||||||
|
$folder_Parent = $folder_Parent.Replace("X:\", "\\mpe.ca\datadrive\")
|
||||||
$folder_FileSize = ($FolderPath_Data | Measure -sum Length).sum / 1024 / 1024 / 1024
|
$folder_FileSize = ($FolderPath_Data | Measure -sum Length).sum / 1024 / 1024 / 1024
|
||||||
$folder_FileCount = ($FolderPath_Data | measure).Count
|
$folder_FileCount = ($FolderPath_Data | measure).Count
|
||||||
$folder_LastWrite = ($FolderPath_Data | measure LastWriteTime -Maximum).Maximum
|
$folder_LastWrite = ($FolderPath_Data | measure LastWriteTime -Maximum).Maximum
|
||||||
@ -172,8 +174,44 @@ server,path,path2,etc,status,OriginalServer=RD,OriginalProject=ProjectNumber
|
|||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$MigrationStatus_import = Import-Excel -Path $PAth_To_Migration_Status -WorksheetName "MPE Migration Tracker" -StartRow 2 | Out-DataTable
|
<# Get Migration Status
|
||||||
Invoke-SQLiteBulkCopy -DataSource $PathToDB -Table "MigrationStatus" -DataTable $MigrationStatus_import -Force -ConflictClause Replace
|
CREATE TABLE "MigrationStatus" (
|
||||||
|
"MigrationID" TEXT NOT NULL UNIQUE,
|
||||||
|
"MigrationName" TEXT,
|
||||||
|
"MigrationFolderSource" TEXT,
|
||||||
|
"MigrationFolderDestination" TEXT,
|
||||||
|
"MigrationStatus" INTEGER,
|
||||||
|
PRIMARY KEY("MigrationID")
|
||||||
|
);
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
$MigrationStatus_import = Import-Excel -Path $PAth_To_Migration_Status -WorksheetName "MPE Migration Tracker" -StartRow 2
|
||||||
|
foreach ($status in $MigrationStatus_import) {
|
||||||
|
$SQLSourcePath = $status.'Source Path'.replace("'", "`'") #SQL Formatting
|
||||||
|
$SQLDestPath = $status.'Destination Path'.replace("'", "`'") #SQL Formatting
|
||||||
|
$SQLMigrationID = $status.'Migration ID'
|
||||||
|
$SQLMigrationName = $status.'Migration Name'
|
||||||
|
$SQLMigrationStatus = $status.'Current State'
|
||||||
|
|
||||||
|
# TODO Add code to ensure there's a trailing slash on Source and Dest paths (consistency)
|
||||||
|
|
||||||
|
$Query = "Select * from MigrationStatus WHERE MigrationID = `'$SQLMigrationID`'"
|
||||||
|
$Test = Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||||
|
|
||||||
|
if ($test) {
|
||||||
|
$Query = "UPDATE MigrationStatus SET MigrationStatus = '$SQLMigrationStatus' WHERE MigrationID = '$SQLMigrationID'"
|
||||||
|
Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Query = "INSERT INTO MigrationStatus VALUES ('$SQLMigrationID','$SQLMigrationName',`'$SQLSourcePath`',`'$SQLDestPath`','$SQLMigrationStatus')"
|
||||||
|
Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user