{"id":39955,"date":"2020-11-13T00:12:56","date_gmt":"2020-11-13T07:12:56","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/premier-developer\/?p=39955"},"modified":"2020-11-09T11:50:34","modified_gmt":"2020-11-09T18:50:34","slug":"sample-script-to-transform-sharepoint-migration-tool-reports","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/sample-script-to-transform-sharepoint-migration-tool-reports\/","title":{"rendered":"Sample script to transform SharePoint Migration Tool reports"},"content":{"rendered":"<p><a href=\"https:\/\/www.linkedin.com\/in\/jasonpgiordano\/\">Jason Giordano<\/a> shares a script to help sort information collected by the SharePoint Migration Tool by website and folder.<\/p>\n<hr \/>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/en-us\/sharepointmigration\/introducing-the-sharepoint-migration-tool\">SharePoint Migration Tool<\/a> 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.<\/p>\n<p>In some cases, reports generated by the SPMT can be difficult to work with because they are not sorted by website&#8211; 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.<\/p>\n<p>Below is a simple VBScript (in most cases, you can save this as a .vbs file and execute it from Explorer).<\/p>\n<pre class=\"prettyprint\">Const sInputFolder = \"C:\\Input\\\" \r\n\r\nConst sOutputFolder = \"C:\\Output\\\" \r\n\r\nConst iForReading = 1 \r\n\r\nConst iForAppending = 8 \r\n\r\n\u202f \r\n\r\nMsgBox(\"Started\") \r\n\r\nSet fso = CreateObject(\"Scripting.FileSystemObject\") \r\n\r\nSet oSourceFolder = fso.GetFolder(sInputFolder) \r\n\r\nSet oSourceFiles = oSourceFolder.Files \r\n\r\nFor Each oFile in oSourceFiles\u202f\u202f\u202f\u202f \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f Set oInputFile = oFile.OpenAsTextStream(iForReading) \r\n\r\n\u202f\u202f\u202f\u202f \u202f\u202f\u202fsHeaders = oInputFile.ReadLine \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f arrSplitHeaders = Split(sHeaders, \",\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f If arrSplitHeaders(1)=\"SiteUrl\" Then \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f Do While Not oInputFile.AtEndOfStream \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f sCurrentLine = oInputFile.ReadLine \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f \u202f\u202f\u202f\u202f\u202farrSplitStrings = Split(sCurrentLine, \",\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f iTotal = UBound(arrSplitStrings, 1) \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f If iTotal &gt; 1 Then \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f sSiteURL = Replace(arrSplitStrings(1),\"\/\",\"-\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f sSiteURL = Replace(sSiteURL,\"?\",\"-\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f sSiteURL = Replace(sSiteURL,\"=\",\"-\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f sSiteURL = Replace(sSiteURL,\":\",\"\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f sSiteURL = Replace(sSiteURL,\" \",\"\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f \u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fsSiteURL = Replace(sSiteURL,\"\"\"\",\"\") \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f If Len(sSiteURL) &gt; 5 and Left(sSiteURL, 5) = \"https\" Then \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f If NOT(fso.FolderExists (sOutputFolder &amp; sSiteURL)) Then fso.CreateFolder(sOutputFolder &amp; sSiteURL) \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f If NOT(fso.FileExists (sOutputFolder &amp; sSiteURL &amp; \"\/\" &amp;\u202foFile.Name)) Then \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f Set oOutputFile = fso.CreateTextFile(sOutputFolder &amp; sSiteURL &amp; \"\/\" &amp;\u202foFile.Name) \r\n\r\n\u202f\u202f \u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202foOutputFile.WriteLine sHeaders \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f Else \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f Set oOutputFile = fso.OpenTextFile(sOutputFolder &amp; sSiteURL &amp; \"\/\" &amp;\u202foFile.Name, iForAppending) \r\n\r\n\u202f\u202f \u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fEnd If \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f oOutputFile.WriteLine sCurrentLine \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f End If \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f End If \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202foOutputFile.Close \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f Loop \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f End If \r\n\r\n\u202f\u202f\u202f\u202f\u202f\u202f\u202f oInputFile.Close \r\n\r\nNext \r\n\r\nMsgBox(\"Finished\") \r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":582,"featured_media":38586,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8745],"tags":[335,10601],"class_list":["post-39955","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sharepoint","tag-sharepoint","tag-spmt"],"acf":[],"blog_post_summary":"<p>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.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/39955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=39955"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/39955\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/38586"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=39955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=39955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=39955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}