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?


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")


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. 


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 & "'>")    


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

call GetSubSites(strResult)    




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)


for Each objWeb in objXml2.DocumentElement.ChildNodes    

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

Set objExec = objShell.Exec(strCmd)    

strResult = objExec.StdOut.ReadAll     


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


WScript.Echo strResult        

call GetSubSites(strResult)    

end if


end sub

sites and subsites with owners

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


special thanks to praveen

Hope this helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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