Sample script to transform SharePoint Migration Tool reports
Jason Giordano shares a script to help sort information collected by the SharePoint Migration Tool by website and folder.
The SharePoint Migration Tool is a helpful resource to migrate content from SharePoint on-premises to the cloud. The SharePoint Migration Tool generates log files, summary and task level reports to help you manage, audit and troubleshoot your migration process.
In some cases, reports generated by the SPMT can be difficult to work with because they are not sorted by website– especially if you need to spread out the work and ownership across teams. This is a simple script that transforms SPMT reports into folders, broken out by website so people working on specific pages can easily see which action items pertain to them.
Below is a simple VBScript (in most cases, you can save this as a .vbs file and execute it from Explorer).
Const sInputFolder = "C:\Input\" Const sOutputFolder = "C:\Output\" Const iForReading = 1 Const iForAppending = 8 MsgBox("Started") Set fso = CreateObject("Scripting.FileSystemObject") Set oSourceFolder = fso.GetFolder(sInputFolder) Set oSourceFiles = oSourceFolder.Files For Each oFile in oSourceFiles Set oInputFile = oFile.OpenAsTextStream(iForReading) sHeaders = oInputFile.ReadLine arrSplitHeaders = Split(sHeaders, ",") If arrSplitHeaders(1)="SiteUrl" Then Do While Not oInputFile.AtEndOfStream sCurrentLine = oInputFile.ReadLine arrSplitStrings = Split(sCurrentLine, ",") iTotal = UBound(arrSplitStrings, 1) If iTotal > 1 Then sSiteURL = Replace(arrSplitStrings(1),"/","-") sSiteURL = Replace(sSiteURL,"?","-") sSiteURL = Replace(sSiteURL,"=","-") sSiteURL = Replace(sSiteURL,":","") sSiteURL = Replace(sSiteURL," ","") sSiteURL = Replace(sSiteURL,"""","") If Len(sSiteURL) > 5 and Left(sSiteURL, 5) = "https" Then If NOT(fso.FolderExists (sOutputFolder & sSiteURL)) Then fso.CreateFolder(sOutputFolder & sSiteURL) If NOT(fso.FileExists (sOutputFolder & sSiteURL & "/" & oFile.Name)) Then Set oOutputFile = fso.CreateTextFile(sOutputFolder & sSiteURL & "/" & oFile.Name) oOutputFile.WriteLine sHeaders Else Set oOutputFile = fso.OpenTextFile(sOutputFolder & sSiteURL & "/" & oFile.Name, iForAppending) End If oOutputFile.WriteLine sCurrentLine End If End If oOutputFile.Close Loop End If oInputFile.Close Next MsgBox("Finished")