Ever had the problem where you have multiple content databases for a given web application in WSS and need to find which one has the site you’re after?
Probably not, I’d only had the odd one until recently, so I wrote the following script to help out…
This works only where you have single SQL server with content databases, if you have content databases across multiple SQL servers you’ll need to modify this script slightly…
Font is quite small to fit it all on one screen!! - Simply copy-paste into your favourite script editor (I like PrimalScript)...
** Start Script **
'declareDim debugmode' read CommandLine args into vars' no validation here so they must all be completeFor Each oArg In WScript.ArgumentssSwitch = LCase(Left(oArg,3))sValue = Right(oArg,Len(oArg)-3)Select Case sSwitchCase "-x:"Debugoption = sValueCase "-y:"SQLServer = sValueCase "-z:"ConfigDB = sValueCase "-s:"SiteSearch = SValueEnd SelectNext'Debug Option'error and bomb out if not setIf Debugoption = "debugon" Thendebugmode = 1MsgBox "Debugging activated!", vbOKOnly Or vbExclamationMsgBox "SQLServer = " & SQLServer, vbOKOnly Or vbExclamationMsgBox "ConfigDB = " & ConfigDB, vbOKOnly Or vbExclamationMsgBox "SiteSearch = " & SiteSearch, vbOKOnly Or vbExclamationElseif Debugoption = "debugoff" Thendebugmode = 0ElseMsgBox "Debugoption not specified, please set using:" & (Chr(13)) & "'sitebackup.vbs -x:debugon' for ON" & (Chr(13)) & "'sitebackup.vbs -x:debugoff' for OFF" & (Chr(13)) & "this utility will do nothing without the correct command line arguments!" & (Chr(13)) & (Chr(13)) & "Matt is a lazy coder!", vbOKOnly Or vbCritical, "BIG FAT ERROR"WScript.QuitEnd ifIf SQLServer = "" Then'error outMsgBox "SQL Server not specified, please set using:" & (Chr(13)) & "'sitebackup.vbs -y:SERVERNAME'" & (Chr(13)) & "This utility will do nothing without the correct command line arguments!" & (Chr(13)) & (Chr(13)) & "Matt is a lazy coder!", vbOKOnly Or vbCritical, "BIG FAT ERROR"WScript.QuitEnd IfIf ConfigDB = "" Then'errorMsgBox "ConfigDB not specified, please set using:" & (Chr(13)) & "'sitebackup.vbs -z:DATABASENAME'" & (Chr(13)) & "This utility will do nothing without the correct command line arguments!" & (Chr(13)) & (Chr(13)) & "Matt is a lazy coder!", vbOKOnly Or vbCritical, "BIG FAT ERROR"WScript.QuitEnd IfIf SiteSearch = "" Then'errorMsgBox "Site URL not specified, please set using:" & (Chr(13)) & "'sitebackup.vbs -s:http://server/sites/site'" & (Chr(13)) & "This utility will do nothing without the correct command line arguments!" & (Chr(13)) & (Chr(13)) & "Matt is a lazy coder!", vbOKOnly Or vbCritical, "BIG FAT ERROR"WScript.QuitEnd Iffiledatestamp = "Y" & year(now()) & "-M" & month(now()) & "-D" & day(now()) & "-HH" & hour(now()) & "-MM" & minute(now())' SET CONSTSbaseDir = BakDrive & BakDirSQLConString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" & ConfigDB & ";Data Source=" & SQLServerIf Debugmode = 1 Then'MsgBox "baseDir = " & baseDir & (Chr(13)), vbOKOnly Or vbExclamationMsgBox "sql con string = " & SQLConString & (Chr(13)), vbOKOnly Or vbExclamationEnd If' CONNECT TO DBDim WSSConSet WSSCon = CreateObject("ADODB.Connection")WSSCon.Open SQLConString'create record setset rsWSSDB = CreateObject("ADODB.recordset")WSSDBsql="select Name from DATABASES order by Name"rsWSSDB.open WSSDBsql, SQLConString'loop through each contant DBDim NOvalDim YESvalNOval = 0YESval = 0while NOT rsWSSDB.EOFset WSSSiteRS = CreateObject("ADODB.recordset")WSSSiteCon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" & rsWSSDB("Name") & ";Data Source=" & SQLSERVER'WSSSitessql="select fullUrl from SITES WHERE FullURL = '" & SiteSearch & "' order by fullUrl"'WSSSiteRS.Open WSSSitessql, WSSSiteCon'count recordsIf Debugmode = 1 ThenMsgBox "WSSSiteCon = " & WSSSiteCon & (Chr(13)), vbOKOnly Or vbExclamationEnd Ifset cNumWSS = CreateObject("ADODB.recordset")NumWSSsql="select count(*) as TotTeamSites from SITES WHERE FullURL = '" & SiteSearch & "'"If Debugmode = 1 ThenMsgBox "Couting Query= " & NumWSSsql & (Chr(13)), vbOKOnly Or vbExclamationEnd IfcNumWSS.open NumWSSsql, WSSSiteConIf Debugmode = 1 ThenMsgBox "number of sites found = " & cNumWSS("TotTeamSites") & (Chr(13)), vbOKOnly Or vbExclamationEnd IfIf cNumWSS("TotTeamSites") = 0 ThenNOval = (NOval + 1)End IfIf cNumWSS("TotTeamSites") >0 ThenYESval = (YESval + 1)MsgBox "I found it!!" & (Chr(13)) & "It's in: " & rsWSSDB("Name") & (Chr(13)), vbOKOnly Or vbExclamationEnd IfrsWSSDB.MoveNextwendIf YESVal = 0 ThenMsgBox "I didn't find it!!" & (Chr(13)) & "I checked " & NOVal & " content databases" & (Chr(13)) & "You searched for: " & SiteSearch & (Chr(13)) & "Did you remember the trailing backslash?", vbOKOnly Or vbExclamationEnd IfWSSCon.ClosecNumWSS.close
** End Script **
Call the script from a shortcut or command line, like:
C:\path\script.vbs -x:debugon -y:MYSERVER -z:MyConfigDB -s:http://server/sites/sitename/
You must include the trailing backslash!
ưu điêm ghế văn phòng làm việc nên chú ý như thế nào để chọn mua sản phẩm phù hợp vàNhững ưu điểm ghế văn phòng làm việc
ReplyDeleteĐể chọn mua bàn làm việc nào cho phù hợp với văn phòng làm việc nên bạn nên quan tâm tớiChọn mua mẫu ghế văn phòng làm việc như thế nào
Các tiêu chí chọn mua mãu nội thất văn phòng cho công ty doanh nghiệp bạn nên quan tâm tớitiêu chí chọn ghế văn phòng
Ghế văn phòng làm việc nào phù hợp cho công tyvăn phong làm việc của bạn nên quan tâm toi cácCần nên chọn mua mẫu ghế văn phòng làm việc nào
Mẫu ghês văn phong fnào phù hợp với nhu cầu làm việc tại văn phòng của bạn cho nên việcNên chọn mua mẫu ghế văn phòng nào
Nội thát văn phòng phải phù hợp với cac tiêu chi nào cho văn phòng làm việc nên việcLựa chọn ghế văn phòng hợp với bạn