{"id":32,"date":"2007-06-25T11:13:23","date_gmt":"2007-06-25T11:13:23","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?page_id=32"},"modified":"2008-07-01T08:04:01","modified_gmt":"2008-07-01T08:04:01","slug":"sub-archivelog","status":"publish","type":"page","link":"https:\/\/www.wapshere.com\/missmiis\/code-snippets\/sub-archivelog","title":{"rendered":"vbscript: ArchiveLog"},"content":{"rendered":"<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">Archive the export\/import.xml file, and modify so it works with the <span style=\"text-decoration: underline;\">stylesheet<\/span>. <\/span><\/span><\/p>\n<p><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">The log.xsl stylesheet should be copied into the root of the MaData folder.<\/span><\/span><\/p>\n<p>\u00c2\u00a0<\/p>\n<pre>' This script copies the MIIS export and import logs to datestamped versions\r\n' and modifies them to work with a stylesheet called ..\/log.xsl.\r\n'\r\n' The logs should be called 'import.xml' or 'export.xml'\r\n' Enter the MA name and just 'import' or 'export' when calling the script.\r\n'\u00c2\u00a0\u00c2\u00a0 Usage: cscript archivelog.vbs MaName import|export\r\n'\r\n' Written by Carol Wapshere <a href=\"https:\/\/www.wapshere.com\/missmiis\">https:\/\/www.wapshere.com\/missmiis<\/a><\/pre>\n<pre>\r\nOption Explicit<\/pre>\n<pre>Const XML_STYLESHEET = \"..\\log.xsl\"\r\nConst MIIS_FOLDER = \"C:\\Program Files\\Microsoft Identity Integration Server\"\r\nConst ForReading = 1\r\nConst ForWriting = 2\r\nConst ForAppending = 8\r\nConst Unicode = -1<\/pre>\n<pre>Dim objFS, MaName, LogName<\/pre>\n<pre>Set objFS = CreateObject(\"Scripting.FileSystemObject\")<\/pre>\n<pre>If WScript.Arguments.Count &lt;&gt; 2 Then\r\n\u00c2\u00a0 Usage\r\nEnd If<\/pre>\n<pre>MaName = WScript.Arguments.Item(0)\r\nLogName = WScript.Arguments.Item(1)<\/pre>\n<pre>ArchiveLog MaName, LogName<\/pre>\n<pre>\r\nSub ArchiveLog(MA, Profile)<\/pre>\n<pre>\u00c2\u00a0 Dim objLogFile, objArchiveFile\r\n\u00c2\u00a0 Dim strLogName, strArchiveName, logTime, dateStamp, strLine<\/pre>\n<pre>\u00c2\u00a0 strLogName = MIIS_FOLDER &amp; \"\\MaData\\\" &amp; MA &amp; \"\\\" &amp; Profile &amp; \".xml\"\r\n\u00c2\u00a0 If objFS.FileExists(strLogName) Then\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 logTime = Now()\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 dateStamp = DatePart(\"yyyy\", logTime) &amp; TwoChars(\"m\", logTime) &amp;_\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 TwoChars(\"d\", logTime) &amp; TwoChars(\"h\", logTime) &amp;_\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 TwoChars(\"n\", logTime) &amp; TwoChars(\"s\", logTime) \r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 strArchiveName = MIIS_FOLDER &amp; \"\\MaData\\\" &amp; MA &amp; \"\\\" &amp; Profile &amp; dateStamp &amp; \".xml\"\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 set objLogFile = objFS.OpenTextFile(strLogName, ForReading, false, Unicode)\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 set objArchiveFile = objFS.OpenTextFile(strArchiveName, ForWriting, true, Unicode)\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objLogFile.ReadLine()\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(\"&lt;?xml version=\"\"1.0\"\" encoding=\"\"UTF-16\"\"?&gt;\")\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(\"&lt;?xml-stylesheet type=\"\"text\/xsl\"\" href=\"\" mce_href=\"\"\" &amp; XML_STYLESHEET &amp; \"\"\"?&gt;\")\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(\"&lt;top&gt;\")\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(\"&lt;xmlfile-time&gt;\")\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(logTime)\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(\"&lt;\/xmlfile-time&gt;\")\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objLogFile.ReadLine() 'skip mmsml\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objLogFile.ReadLine() 'skip directory-entries\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 strLine = objLogFile.ReadLine()\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Do Until InStr(strLine, \"&lt;\/directory-entries&gt;\") &gt; 0\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(strLine)\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 strLine = objLogFile.ReadLine()\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Loop\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.WriteLine(\"&lt;\/top&gt;\")\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objLogFile.Close()\r\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objArchiveFile.Close()\r\n\u00c2\u00a0 End If\r\nEnd Sub<\/pre>\n<pre>\r\nFunction TwoChars(dtvar, time)\r\n\u00c2\u00a0 Dim i<\/pre>\n<pre>\u00c2\u00a0 i = DatePart(dtvar, time)\r\n\u00c2\u00a0 If i &lt; 10 Then\r\n\u00c2\u00a0\u00c2\u00a0 TwoChars = \"0\" &amp; CStr(i)\r\n\u00c2\u00a0 Else\r\n\u00c2\u00a0\u00c2\u00a0 TwoChars = CStr(i)\r\n\u00c2\u00a0 End If\r\nEnd Function<\/pre>\n<pre>\r\nSub Usage\r\n\u00c2\u00a0 Wscript.echo \"Usage: cscript archivelog.vbs MaName import|export\"\r\n\u00c2\u00a0 Wscript.Quit\r\nEnd Sub<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Archive the export\/import.xml file, and modify so it works with the stylesheet. The log.xsl stylesheet should be copied into the root of the MaData folder. \u00c2\u00a0 &#8216; This script copies the MIIS export and import logs to datestamped versions &#8216; and modifies them to work with a stylesheet called ..\/log.xsl. &#8216; &#8216; The logs should&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":30,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-32","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/Pkp1o-w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":0,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages\/32\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/pages\/30"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}