%20%E4%B8%AD%E7%9A%84%E7%B8%BD%E8%A8%98%E9%8C%84.png)
如何取得 DNS 伺服器中的總記錄(Windows Server 2003 - Active Directory 環境)
是否可以透過 Powershell/wmi 取得此資訊?
更新:
到目前為止,我將其與 Powershell 一起使用:
& "d:\AdminTools\SupportTools\Windows2003\dnscmd.exe" SERVERDNS /enumrecords domain.local . > output.txt
gc output.txt | measure-object | select count
有什麼建議 ?
答案1
一個簡單的批次檔怎麼樣?
@Echo Off
rem Enter the location of the Windows Support Tools below
set @SupportToolsLoc=c:\Program Files\Support Tools
rem Enter the domain name you want to count below
set @DomainName=foo.com
rem Enter DNS Server Name below, or a period for the local server
Set @DNSServer=.
setlocal ENABLEDELAYEDEXPANSION
set /a @RecordCount=0
"%@SupportToolsLoc%\dnscmd" %@DNSServer% /enumrecords %@DomainName% . >DNSRecords.txt
for /f "skip=1 tokens=*" %%f in ('type DNSRecords.txt') do set /a @RecordCount=!@RecordCount! + 1
set /a @RecordCount=!@RecordCount! - 1
If "%@DNSServer%"=="." echo There are !@RecordCount! records in the domain %@DomainName% on the local server
If not "%@DNSServer%"=="." echo There are !@RecordCount! records in the domain %@DomainName% on the DNS Server %@DNSServer%
pause
del /q DNSRecords.txt
endlocal
希望這可以幫助,
格倫