Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

The current site collection analytics report shows the number of sites per day which allows the owner to track how many new sites are appearing per day. However, I need to be able to determine the actual sites themselves. In other words, how can I get a list of the subsites in a collection and their owners?

share|improve this question

1 Answer 1

Hi this is not mine and taken from the link below! it shows you sites and subsite with the owners!

It an amazing VBA script.

1) copy past code into notepad or word document

2) save and rename, add the extention vbs e.g testScript.vbs

3) change the constants at the top of the script so that it points to your stsadm path, URL for your root url and file name path to the place where you want to dump the file

4) from cmd run like this "cscript.exe testScript.vbs"

5) goto the dump file where you saved it and open the xml file in Excel

6) all done ;)

Option Explicit

Const STSADM_PATH ="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm"

Const ROOT_URL = "http://pravmoss/"

Const FILE_NAME = "D:\listofsites.xml" 

Dim objShell, objExec, objXml, objXml2,objXml3, objSc,objFso, objFile, objWeb

Dim strResult, strSubResult, strUrl, strCmd, strOwner, strXML

WScript.Echo "Creating shell object and calling root enumsites command"

Set objShell = CreateObject("WScript.Shell")

Set objExec = objShell.Exec(STSADM_PATH & " -o enumsites -url " & ROOT_URL)

strResult = objExec.StdOut.ReadAll  

'Load XML in DOM document so it can be processed.

WScript.Echo "Loading XML File"

Set objXml = CreateObject("MSXML2.DOMDocument")

Set objXml2 = CreateObject("MSXML2.DOMDocument")

Set objXml3 = CreateObject("MSXML2.DOMDocument")

objXml.LoadXML(strResult)

WScript.Echo "Creating File System Object"

'Create the FileSystemObject and write to file.

Set objFso = CreateObject("Scripting.FileSystemObject")

'Loop through each site collection and call enumsubwebs to get the child URL's. 

objFile.WriteLine("<ROOT>")

For Each objSc in objXml.DocumentElement.ChildNodes    

strUrl = objSc.Attributes.GetNamedItem("Url").Text    

strOwner = objSc.Attributes.GetNamedItem("Owner").Text    

strCmd = STSADM_PATH & " -o enumsubwebs -url """ + strUrl + """"

Set objExec = objShell.Exec(strCmd)    

strResult = objExec.StdOut.ReadAll 

objFile.WriteLine("<SITECOLLECTION SiteCollectionURL='" & strUrl & "' Owner = '" & strOwner & "'>")    

objFile.WriteLine(strResult)    

WScript.Echo "Traversing the sub Webs..."  

call GetSubSites(strResult)    

objFile.WriteLine("</SITECOLLECTION>")

Next

objFile.WriteLine("</ROOT>") 

set objFile = nothing

set objFso = nothing

set objXml = nothing

set objXml2 = nothing

set objXml3 = nothing

set objExec = nothing 

WScript.Echo "File created" 

sub GetSubSites(strResult)

objXml2.LoadXML(strResult)

for Each objWeb in objXml2.DocumentElement.ChildNodes    

strCmd = STSADM_PATH & " -o enumsubwebs -url """ + objWeb.text + """"    

Set objExec = objShell.Exec(strCmd)    

strResult = objExec.StdOut.ReadAll     

objXml3.LoadXML(strResult)    

if objXml3.DocumentElement.Attributes.GetNamedItem("Count").Text <> "0" Then 

objFile.WriteLine(strResult)        

WScript.Echo strResult        

call GetSubSites(strResult)    

end if

next

end sub

sites and subsites with owners

If you want to see the origional post to this then you can find it here:

http://www.dotnetscraps.com/dotnetscraps/post/Recursively-listing-all-MOSS-Site-Collections-and-Sub-Sites.aspx

special thanks to praveen

Hope this helps :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.