Here is a script that reads the Domain name and then gathers information about all the Domain DFS namespaces into one file.
Dave
'***************************************************************************************************************** ** *****
'Written by David
'7 FEB 2008
'
' Reads domain name and gets information about DFS Namespaces
' Uses dfsutil to gather the information from domain
'
'
Option Explicit
Dim netObj, objSysInfo
Dim LocalComputerName, Username, domaindnsname, domainname
Dim testmode, PopMessage
Dim strFolder,strCommand,strProgramName
Dim objshell, objFSO
Dim StartPos, EndPos 'where in the array do the dfs name spaces start and end
Dim loopcounter, strOutput, strOutputFile
'************************************************************************************************************************
'set memory varibles used by the script
'
Set netobj=wscript.createobject("wscript.network") 'create network object
localcomputername=netobj.computername 'get local computer name
domainname=netobj.userdomain 'get local domain
username=netobj.username 'get username
Set objSysInfo = CreateObject("ADSystemInfo") 'create adsi object
domaindnsname = objSysInfo.DomainDNSName 'Domain DNS Name
'************************************************************************************************************************
'Main program loop
'
'open output file
strOutput = inputbox("Please enter Output file name", "Output File", strfolder & strProgramName & ".txt")
If strOutput = "" Then
wscript.quit
End If
If objFSO.FileExists(strOutput) Then
objFSO.DeleteFile(strOutput)
End If
Set strOutputFile = objfso.opentextfile(strOutput, ForWriting, True)
'write header
strOutputFile.writeline ("Calling Program : " & strProgramName)
strOutputFile.writeline ("Called from folder : " & strfolder)
strOutputFile.writeline ("Date of Run : " & date)
strOutputFile.writeline ("Time of Run : " & time)
strOutputFile.writeline ("Local Computer Name : " & localcomputername)
strOutputFile.writeline ("Domain Name : " & domainname)
strOutputFile.writeline ("User Name : " & username)
strOutputFile.writeline ("Domain DNS Name : " & domaindnsname)
strOutputFile.writeline()
strOutputFile.close
Set strOutputFile = objfso.opentextfile(strOutput, ForAppending, True)
getDomainDFSNameSpaces(domainname)
For loopcounter = startpos To EndPos
strOutputFile.write (getNameSpaces(arrReadinput(loopcounter)))
Next
strOutputFile.close
'close object
Set objfso = Nothing
Set objshell = Nothing
'************************************************************************************************************************
'end of program Functions and procedures below
'********************************************************************************************
''********************************************************************************************
' Function returns true if lstrcomputer is online, does ping test for reply in console message
Function IsOnline(lstrComputer)
Dim objExecObject, strText
Set objShell = CreateObject("WScript.Shell"):
Set objExecObject = objShell.Exec ("%comspec% /c ping -n 1 -w 25 " & lstrComputer)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "Reply") > 0 Then
IsOnline=True
Else
IsOnline=False
End If
Loop
End Function
'********************************************************************************************
'********************************************************************************************
'This function returns the path from which the script was called
'Call ScriptPath(strFolder,strCommand,strProgramName)
'wscript.echo "Called from folder : -> " & strFolder & vbCrlf & "Calling Program Line : -> " & strCommand & vbCrlf _
'& "Calling Program Name : -> " & strProgramName & vbCrlf
'wscript.quit
Function ScriptPath(callingfolder, callingcommandline, callingprogramname)
ScriptPath=Left(Wscript.scriptfullname,Instr(1,WScript.ScriptFullName,wscript.scriptname,1)-1)
callingfolder=scriptpath
callingcommandline=wscript.scriptfullname
callingprogramname=left(wscript.scriptname,len(wscript.scriptname)-4)
End Function
'*******************************************************************************************
'********************************************************************************************
' Function returns DFS Namespaces in domain
Function getDomainDFSNameSpaces(strDomain)
Dim objExecObject, strText, counter
Set objShell = CreateObject("WScript.Shell")
Do While Not objExecObject.StdOut.AtEndOfStream
' strText = objExecObject.StdOut.ReadAll()
Redim Preserve arrReadinput(counter)
'remove tab from line item
arrReadinput(counter)=replace(objExecObject.StdOut.Readline(),vbTab,"")
counter=counter+1
' wscript.echo strText
Loop
counter=0
'remove program header lines
StartPos = lbound(arrReadinput)+7
'remove program trail lines
EndPos = ubound(arrReadinput)-4
'Write output header
strOutputFile.writeline("********************************************************************************************")
strOutputFile.writeline("Domain Namespaces For " & strDomain & " as of " & date & vbCrlf)
'write output string
For counter = StartPos To EndPos
strOutputFile.writeline(arrReadinput(counter))
' counter=counter+1
Next
End Function
'********************************************************************************************
'********************************************************************************************
' Function returns DFS Namespaces folder targets in domain
Function getNameSpaces(StrNameSpace)
Dim objExecObject, strText, counter
Set objShell = CreateObject("WScript.Shell")
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
counter=counter+1
Loop
strOutputFile.writeline("********************************************************************************************")
strOutputFile.writeline("Namespace For " & StrNameSpace & " as of " & date & vbCrlf)
strOutputFile.writeline(strText)
End Function
'********************************************************************************************
'EOF
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.