It is currently Mon Feb 13, 2012 9:29 pm




 Page 1 of 1 [ 1 post ] 
Author Message
 Post subject: Script to synchronise all sites with Web Deployment Tool
PostPosted: Fri Jun 19, 2009 8:49 am 
Site Admin
Site Admin
User avatar

Joined: Mon Feb 09, 2009 1:31 pm
Posts: 193
Location: Newport, South Wales
I have written this simple VB Script to synchronise all the sites in IIS between two servers. Feel free to use and share this script. If anybody can improve on it just post back in this thread with your version of it :)

' ================== '
' Sort out variables '
' ================== '

DIM srcServer
DIM dstServer
DIM objWebService

srcServer = "SERVER1"
dstServer = "SERVER2"
SET objWebService = GetObject( "IIS://" & srcServer & "/W3SVC" )

EnumWebsites objWebService



' =========================================================== '
' Enumerate web sites in IIS and call synchronisation command '
' =========================================================== '

SUB EnumWebsites( objWebService )
    DIM objWebServer

    FOR EACH objWebServer IN objWebService
        IF objWebserver.Class = "IIsWebServer" THEN
   Set objShell = WScript.CreateObject("WScript.Shell")
   Dim sCmd
   sCmd = "%comspec% /c msdeploy.exe -verb:sync -source:apphostconfig=""" &_
objWebServer.ServerComment & """ -dest:apphostconfig=""" & objWebServer.ServerComment_
& """,computername=""" & dstServer & """ > C:\msdeploy.log"
   return = objShell.Run(sCmd,0,true)
        END IF
    NEXT

END SUB



_________________
Dave Webb
Windows 2008 Forums
Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

cron