tag:blogger.com,1999:blog-85204448478491630412024-03-14T03:53:31.397-04:00The Frustrated GeekThe Rants of a Computer ProfessionalMark Melansonhttp://www.blogger.com/profile/17727927227700445803noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-8520444847849163041.post-77343610751262533402008-10-15T18:57:00.000-04:002008-10-15T19:21:33.430-04:00Migrating your users to a new server<span class="Apple-style-span" style="color: rgb(95, 117, 89); line-height: 20px;font-family:Verdana;font-size:12px;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); line-height: normal; font-size:14px;"><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "><span class="Apple-style-span" style="font-size: medium;">Recently I have been working on migrating Windows servers from Win2K to Win2K3. During our adventure we have across the usual issues that you would expect during a migration. So far these have been quickly addressed and fixes documented. Unfortunately migrating Offline Files in a seamless manner has not been as easy to to overcome.</span></p><p size="0.85em" style=" padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "><span class="Apple-style-span" style="font-size: medium;">After much hair pulling and googling I found enough information to put together a solution that is working for us. Since I have had the benefit of the knowledge of so many others on the </span><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><a href="http://en.wikipedia.org/wiki/Internets_%28colloquialism%29"><span class="Apple-style-span" style="font-size: medium;">Internets</span></a></span><span class="Apple-style-span" style="font-size: medium;"> I thought I'd post my findings for your perusal.</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "><span class="Apple-style-span" style="font-size: medium;">Before I begin let me start by saying if this does not work for you or it breaks something you are on your own.</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "><span class="Apple-style-span" style="font-size: medium;">If you are here you may not know that Microsoft actually provides a tool for this purpose. It is in the Win2K3 Resource Kit and is called CSCCMD.EXE. If you have it, good for you! It's crap. But there is a new and improved version that is mentioned in </span><a href="http://support.microsoft.com/kb/884739"><span class="Apple-style-span" style="font-size: medium;">this</span></a><span class="Apple-style-span" style="font-size: medium;"> 2 year old article. From a scripting standpoint it isn't much better but it will have to do. If you checked out the KB article you will also notice that you have to call them to get it. Apparently two years isn't long enough to test it sufficiently. If you search the Internet via </span><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><a href="http://www.google.com/search?q=%22I+am+looking+for+version+1.1+of+the+CSCCMD%22"><span class="Apple-style-span" style="font-size: medium;">Google</span></a></span><span class="Apple-style-span" style="font-size: medium;"> you will find it (or call them). You will need it for this to work. You will also need </span><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><a href="http://www.kixtart.org/"><span class="Apple-style-span" style="font-size: medium;">KIXTART</span></a></span><span class="Apple-style-span" style="font-size: medium;">. I wrote the script in KIXTART so I could add it to a login script. It should be easy to port to the scripting language of your choice. If you are running Vista then you don't need to do any of this since you can now manipulate it with WMI. You can find a VBScript to do that </span><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><a href="http://blogs.technet.com/filecab/pages/cscrenameitem-vbs.aspx"><span class="Apple-style-span" style="font-size: medium;">here</span></a></span><span class="Apple-style-span" style="font-size: medium;">.</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "><span class="Apple-style-span" style="font-size: medium;">The script expects CSCCMD.EXE to be in the path.</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "><span class="Apple-style-span" style="font-size: medium;">Below is the code. Good Luck!</span></p><p style=" padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(95, 117, 89); line-height: 1.75em; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size:0.85em;"><span id="body0"><pre style=" color: rgb(95, 117, 89); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family:'Courier New', Courier, monospace;font-size:1em;"><span id="body0"><pre style=" margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family:'Courier New', Courier, monospace;font-size:1em;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><span class="Apple-style-span" style="font-family: verdana;"><span class="Apple-style-span" style="font-size: medium;"><br /></span></span><span class="Apple-style-span" style="font-family: verdana;"><span class="Apple-style-span" style="font-size: medium;">;Function MigOfflineFiles()<br />;<br />;Author Mark Melanson<br />;<br />;Contributors <br />;<br />;Action Repoints the Offline Files cache to another server<br />;<br />;Assumptions Old share and new share are the same name<br />;<br />;Syntax MigOfflineFiles("ServerOld", "ServerNew")<br />;<br />;Version 2.3<br />;<br />;Date 03-07-2008<br />;<br />;Date Revised 03-13-2008<br />;<br />;Revision Reason Added error checking and return codes<br />; Added logging of FAILURES ONLY<br />; Removed dependency on Temp files by using the WSHPipe UDF<br />; Fixed error checking in log creation<br />; Changed some variable names<br />; Restructured code to move If statement into SELECT CASE<br />; Restructured return codes<br />;<br />;Remarks Tested on 2000/XP<br />;<br />;Returns 0 - Offline Files are DISABLED<br />; 1 - NOTHING TO DO (Targeted Server not found to be configured on the client)<br />; 2 - ALL Targeted Offline Files were repointed successfully<br />; 3 - SOME Targeted Offline Files were repointed successfully<br />; Check the log for what failed at: $Temp\@UserID_OfflineFail.log<br />; 4 - NONE of the Targeted Offline Files were repointed successfully<br />; Check the log for what failed at: $Temp\@UserID_OfflineFail.log<br />; 5 - SOME Targeted Offline Files were repointed successfully<br />; Log Creation FAILED<br />; 6 - NONE of the Targeted Offline Files were repointed successfully<br />; Log Creation FAILED<br />; 7 - UNKNOWN ERROR<br />;<br />;Dependencies KiXtart v4.53<br />; WSHPipe KIXTART UDF<br />; Microsoft CSCCMD.EXE v1.1 - http://support.microsoft.com/kb/884739<br />;<br />;License: Creative Commons Attribution 3.0 United States<br />; http://creativecommons.org/licenses/by/3.0/us/<br />;<br />;Source<br /><br /><br />Function MigOfflineFiles($OldSrv, $NewSrv)<br />Dim $Temp, $Index, $CSCSrvShr, $CSCSrv, $CSCShr, $NUL, $RetCode<br />Dim $MigFail, $MigSuccess, $MigStat, $LogStat, $WinDir, $x, $Result<br />DIM $KeyName[2] ; Note : declaration of an array of 3 elements.<br />$MigOfflineFiles = ""<br />$Temp = EXPANDENVIRONMENTVARS ("%TEMP%")<br /><br />; Is Offline Files enabled?<br />$RetCode = WSHPipe("csccmd /IsEnabled",1)<br />If UCase($RetCode[0]) = "DISABLED"<br /> ; Return 0 to indicate Offline Files is not enabled<br /> $MigOfflineFiles = 0<br /> ; Exit Function<br /> Exit 0<br />EndIf<br /><br />$LogStat = 0<br />$MigStat = ""<br />$Index = 0<br />Do<br /> ; enumerate the CSC Shares<br /> $KeyName = ENUMKEY("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache\Shares\", $Index)<br /> If @ERROR = 0<br /> ; parse the server and share<br /> $CSCSrvShr = Split(UCase($KeyName),"/",-1)<br /> $CSCSrv = $CSCSrvShr[2]<br /> $CSCShr = $CSCSrvShr[3]<br /> ; Are we pointing at the old server?<br /> If $CSCSrv = UCASE($OldSrv)<br /> $RetCode = ""<br /> $MigStat = 1<br /> $MigFail = "FALSE"<br /> $MigSuccess = "FALSE"<br /> ; Run CSCCMD and log failures<br /> $RetCode = WSHPipe("csccmd /MOVESHARE:\\" + $CSCSrv + "\" + $CSCShr + " \\" + $NewSrv + "\" + $CSCShr,1)<br /> $Result = Ucase($RetCode[0])<br /> If UCase($Result) = "THE COMMAND COMPLETED SUCCESSFULLY."<br /> $MigSuccess = 1<br /> ; CSCCMD does not cleanup the registry entries (I don't like loose ends)<br /> ; Switched to DELTREE as DELKEY did not always work even with no subkeys<br /> $NUL = DELTREE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache\Shares\" + $KeyName)<br /> Else<br /> $MigFail = 1<br /> IF Open( 3, $Temp + "\" + @UserID + "_OfflineFail.log", 5 ) = 0<br /> $x = WriteLine( 3 ,@Date + " " + @Time + " " + "\\" + $CSCSrv + "\" + $CSCShr + " \\" + $NewSrv + "\" + $CSCShr + " " + $Result + @CRLF)<br /> If $x <> 0<br /> $LogStat = $LogStat + 1<br /> ENDIF<br /> $NUL = Close(3)<br /> ENDIF<br /> EndIf<br /> EndIf<br /> $Index = $Index + 1<br /> EndIf<br />Until $KeyName = ""<br /><br />; Check our return codes<br />SELECT<br />; If there was NOTHING TO DO<br />CASE $Migstat <> 1<br /> ; Return 1 to indicate NOTHING TO DO<br /> $MigOfflineFiles = 1<br />; If the migration had no failures and good logs<br />CASE $MigFail = "FALSE" AND $MigSuccess = 1<br /> ; Return 2 to indicate SUCCESS<br /> ; You should reboot the computer for the changes to take effect<br /> $MigOfflineFiles = 2<br />; If the migration had success and failure and good logs<br />CASE $MigFail = 1 AND $MigSuccess = 1 AND $LogStat = 0<br /> ; Failure log is left at $Temp\@UserID_OfflineFail.log<br /> ; Return 3 to indicate SUCCESS and FAILURE<br /> ; You should reboot the computer for the changes to take effect<br /> $MigOfflineFiles = 3<br />; If the migration completely failed and had good logs<br />CASE $MigFail = 1 AND $MigSuccess = "FALSE" AND $LogStat = 0<br /> ; We had one or more failures<br /> ; Failure log is left at $Temp\@UserID_OfflineFail.log<br /> ; Return 4 to indicate one or more FAILURES<br /> $MigOfflineFiles = 4<br />; If the migration had success and failure and questionable logs<br />CASE $MigFail = 1 AND $MigSuccess = 1 AND $LogStat <> 0<br /> ; We had one or more failures<br /> ; FAILURE LOG WAS NOT CREATED OR IS INCOMPLETE<br /> ; Return 5 to indicate SUCCESS and FAILURE<br /> ; You should reboot the computer for the changes to take effect<br /> $MigOfflineFiles = 5<br />; If the migration completely failed and questionable logs<br />CASE $MigFail = 1 AND $MigSuccess = "FALSE" AND $LogStat <> 0<br /> ; We had one or more failures<br /> ; FAILURE LOG WAS NOT CREATED OR IS INCOMPLETE<br /> ; Return 6 to indicate one or more FAILURES<br /> $MigOfflineFiles = 6<br />CASE 1<br /> ; You should not be here<br /> ; UNKNOWN ERROR<br /> $MigOfflineFiles = 7<br />ENDSELECT<br />EndFunction<br /></span></span></span></pre><pre style="font-size: 1em; font-family: 'Courier New', Courier, monospace; color: rgb(95, 117, 89); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></pre></span></pre></span></p></span></span>Mark Melansonhttp://www.blogger.com/profile/17727927227700445803noreply@blogger.com0