on
error
resume
next
CONST ForWriting = 2
Outputfile = " DNS记录列表 "
Set FSO = CreateObject ( " Scripting.FileSystemObject " )
Set fLog = fso.OpenTextFile(Outputfile & " .csv " , ForWriting, TRUE )
fLog.WriteLine " IP Address,OwnerName,DateTime "
servername = " . "
domainname = " Test.intra "
recordtype = " A "
set dnsserver = Getobject ( " winmgmts:{Authenticationlevel=pktPrivacy}!\\ " & servername & " \root\MicrosoftDNS " )
query = " Select * from MicrosoftDNS_ " & recordtype & " Type where containername="" " & domainname & " "" "
wscript.echo " Query= " & query
Set colItems = dnsserver.ExecQuery(query,, 48 )
if colitems.count <> 0 then
For Each objItem in colItems
Wscript.Echo " IP Address: " & objItem.IPAddress
' Wscript.Echo "ContainerName: " & objItem.ContainerName
' Wscript.Echo "DnsServerName: " & objItem.DnsServerName
Wscript.Echo " DomainName: " & objItem.DomainName
Wscript.Echo " OwnerName: " & objItem.OwnerName
Wscript.Echo " PrimaryName: " & objItem.PrimaryName
Wscript.Echo " RecordClass: " & objItem.RecordClass
Wscript.Echo " RecordData: " & objItem.RecordData
Wscript.Echo " TextRepresentation: " & objItem.TextRepresentation
If objItem.TimeStamp > 0 Then
Timestamp = DateAdd ( " h " , objItem.TimeStamp, " 1/1/1601 00:00:00 AM " )
WScript.Echo " Timestamp: " & Timestamp
Else
Timestamp = ""
WScript.Echo " Timestamp: Not Set "
End If
' Wscript.Echo "Timestamp: " & objItem.Timestamp
' Wscript.Echo "TTL: " & objItem.TTL
fLog.WriteLine objItem.IPAddress & " , " & objItem.OwnerName & " , " & Timestamp
Next
end if
CONST ForWriting = 2
Outputfile = " DNS记录列表 "
Set FSO = CreateObject ( " Scripting.FileSystemObject " )
Set fLog = fso.OpenTextFile(Outputfile & " .csv " , ForWriting, TRUE )
fLog.WriteLine " IP Address,OwnerName,DateTime "
servername = " . "
domainname = " Test.intra "
recordtype = " A "
set dnsserver = Getobject ( " winmgmts:{Authenticationlevel=pktPrivacy}!\\ " & servername & " \root\MicrosoftDNS " )
query = " Select * from MicrosoftDNS_ " & recordtype & " Type where containername="" " & domainname & " "" "
wscript.echo " Query= " & query
Set colItems = dnsserver.ExecQuery(query,, 48 )
if colitems.count <> 0 then
For Each objItem in colItems
Wscript.Echo " IP Address: " & objItem.IPAddress
' Wscript.Echo "ContainerName: " & objItem.ContainerName
' Wscript.Echo "DnsServerName: " & objItem.DnsServerName
Wscript.Echo " DomainName: " & objItem.DomainName
Wscript.Echo " OwnerName: " & objItem.OwnerName
Wscript.Echo " PrimaryName: " & objItem.PrimaryName
Wscript.Echo " RecordClass: " & objItem.RecordClass
Wscript.Echo " RecordData: " & objItem.RecordData
Wscript.Echo " TextRepresentation: " & objItem.TextRepresentation
If objItem.TimeStamp > 0 Then
Timestamp = DateAdd ( " h " , objItem.TimeStamp, " 1/1/1601 00:00:00 AM " )
WScript.Echo " Timestamp: " & Timestamp
Else
Timestamp = ""
WScript.Echo " Timestamp: Not Set "
End If
' Wscript.Echo "Timestamp: " & objItem.Timestamp
' Wscript.Echo "TTL: " & objItem.TTL
fLog.WriteLine objItem.IPAddress & " , " & objItem.OwnerName & " , " & Timestamp
Next
end if