<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indented! &#187; reporting</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/reporting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Mon, 17 Oct 2011 19:03:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Microsoft DNS &amp; stale records</title>
		<link>http://www.indented.co.uk/index.php/2008/10/10/microsoft-dns-stale-records/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/10/microsoft-dns-stale-records/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 11:18:56 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Microsoft DNS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VbScript]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[reporting]]></category>
		<category><![CDATA[Stale Records]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[Windows 2003]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=199</guid>
		<description><![CDATA[This post explains how to identify and report on stale records in a dynamically updated Microsoft DNS zone. The time stamp taken from a DNS record represents the numbers of hours since 01/01/1601 00:00. The value can be converted into a useful date within a script. By default, all times are reported and tested in [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This post explains how to identify and report on stale records in a dynamically updated Microsoft DNS zone.<br />
<span id="more-199"></span><br />
The time stamp taken from a DNS record represents the numbers of hours since 01/01/1601 00:00. The value can be converted into a useful date within a script. By default, all times are reported and tested in UTC.</p>
<p>A stale record is a record where both the No-Refresh Interval and Refresh Interval have passed without the time stamp updating. Ordinarily stale records would be removed by a Scavenging process. These scripts may be useful if trying to asses the impact of enabling Scavenging or reducing Aging intervals.</p>
<h3>Listing stale records with VbScript</h3>
<p>This script uses a WMI query to return all A records for a domain, then it sorts through each record, echoing when the time stamp is older than our pre-defined maximum age. The script will work best when run with cscript.</p>
<pre class="brush: vb; title: ; notranslate">
' No-Refresh + Refresh (in Days)
Const MAXIMUM_AGE = 4

' Connect to the MicrosoftDNS Namespace
Set objWMIService = _
  GetObject(&quot;winmgmts:\\dc01.internal.highorbit.co.uk\root\MicrosoftDNS&quot;)

' Query A records with MicrosoftDNS_AType class where the record is not static
Set colItems = objWMIService.ExecQuery(&quot;SELECT * FROM MicrosoftDNS_AType &quot; &amp;_
  &quot; WHERE ContainerName='internal.highorbit.co.uk' AND TimeStamp&lt;&gt;0&quot;)

For Each objItem In colItems
  ' Convert the timestamp into a date and time
  dtmTimeStamp = DateAdd(&quot;h&quot;, objItem.TimeStamp, &quot;01/01/1601 00:00:00&quot;)
  ' Compare the date and time with MAXIMUM_AGE
  If dtmTimeStamp &lt;= (Date() - MAXIMUM_AGE) Then
    ' Echo the record details if it is older than the MAXIMUM_AGE
    WScript.Echo objItem.OwnerName &amp; VbTab &amp; objItem.IPAddress &amp;_
      VbTab &amp; dtmTimeStamp
  End If
Next
</pre>
<h3>Listing stale records with PowerShell</h3>
<p>This snippet uses Get-WMIObject and a improved query to return only stale records rather than sorting after returning all dynamic records.</p>
<p>A timespan value is generated to represent the minimum value of TimeStamp for valid records.</p>
<pre class="brush: powershell; title: ; notranslate">
# No-Refresh + Refresh (in Days)
$TotalAgingInterval = 4

$ServerName = &quot;dc01.internal.highorbit.co.uk&quot;
$ContainerName = &quot;internal.highorbit.co.uk&quot;

$MinTimeStamp = [Int](New-TimeSpan `
  -Start $(Get-Date(&quot;01/01/1601 00:00&quot;)) `
  -End $((Get-Date).AddDays(-$TotalAgingInterval))).TotalHours

Get-WMIObject -Computer $ServerName `
  -Namespace &quot;root\MicrosoftDNS&quot; -Class &quot;MicrosoftDNS_AType&quot; `
  -Filter `
  &quot;ContainerName='$ContainerName' AND TimeStamp&lt;$MinTimeStamp AND TimeStamp&lt;&gt;0&quot; `
 | Select-Object OwnerName, `
  @{n=&quot;TimeStamp&quot;;e={(Get-Date(&quot;01/01/1601&quot;)).AddHours($_.TimeStamp)}}
</pre>
<h3>Reading Aging intervals with PowerShell</h3>
<p>The Aging intervals and the date the zone can be scavenged set on a zone can be read using WMI using the MicrosoftDNS_Zone class. As with the TimeStamp the .AddHours method must be used to return a date.</p>
<pre class="brush: powershell; title: ; notranslate">
$ServerName = &quot;dc01.internal.highorbit.co.uk&quot;
$ContainerName = &quot;internal.highorbit.co.uk&quot;

Get-WMIObject -Computer $ServerName `
  -Namespace &quot;root\MicrosoftDNS&quot; -Class &quot;MicrosoftDNS_Zone&quot; `
  -Filter &quot;ContainerName='$ContainerName'&quot; `
 | Select-Object NoRefreshInterval, RefreshInterval, `
  @{n=&quot;AvailForScavengeTime&quot;;e={
    (Get-Date(&quot;01/01/1601&quot;)).AddHours($_.AvailForScavengeTime)}}
</pre>
<h3>Localisation</h3>
<p>As mentioned at the beginning of this post, all times are reported in UTC by default. By calling a the ToLocalTime method the date returned can be converted to local time, using the time zone configured on the system executing the query.</p>
<pre class="brush: powershell; title: ; notranslate">
$ServerName = &quot;dc01.internal.highorbit.co.uk&quot;
$ContainerName = &quot;internal.highorbit.co.uk&quot;

$MinTimeStamp = [Int](New-TimeSpan `
  -Start $(Get-Date(&quot;01/01/1601 00:00&quot;)) `
  -End $((Get-Date).AddDays(-$TotalAgingInterval))).TotalHours

Get-WMIObject -Computer $ServerName `
  -Namespace &quot;root\MicrosoftDNS&quot; -Class &quot;MicrosoftDNS_AType&quot; `
  -Filter `
  &quot;ContainerName='$ContainerName' AND TimeStamp&lt;$MinTimeStamp AND TimeStamp&lt;&gt;0&quot; `
 | Select-Object OwnerName, `
  @{n=&quot;TimeStamp&quot;;e={
    ((Get-Date(&quot;01/01/1601&quot;)).AddHours($_.TimeStamp)).ToLocalTime()}}
</pre>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/10/microsoft-dns-stale-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft DNS &amp; static records</title>
		<link>http://www.indented.co.uk/index.php/2008/10/02/microsoft-dns-static-records/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/02/microsoft-dns-static-records/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 11:59:32 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Microsoft DNS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VbScript]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[reporting]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[Windows 2003]]></category>
		<category><![CDATA[wmi]]></category>
		<category><![CDATA[wmic]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=28</guid>
		<description><![CDATA[Windows 2008 has an improved user interface for DNS. The main console includes details of a records time stamp and whether or not the record is Static. Life isn&#8217;t quite so easy with Windows 2003. However, as each static record has a time stamp set to 0 they can be found with a little work. [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Windows 2008 has an improved user interface for DNS. The main console includes details of a records time stamp and whether or not the record is Static. Life isn&#8217;t quite so easy with Windows 2003. However, as each static record has a time stamp set to 0 they can be found with a little work.<br />
<span id="more-28"></span><br />
When using an Active Directory Integrated zone records are stored within Active Directory as dnsNode objects. The Time Stamp value is encoded along with the rest of the record properties (TTL, etc) in the dnsRecord attribute on the dnsNode. The attribute is a Binary Large Object (BLOB), Microsoft do not currently publish references or maps for these attributes. WMI queries can be used as an alternative.</p>
<h3>The DNS management console</h3>
<p>To see the current time stamp, and whether a record is dynamic or not first enable View / Advanced in the DNS console. For each record that makes an additional tick box and text box visible.</p>
<p>The record below is dynamic, if the box is not ticked, and the time stamp field is blank the record is static. That means that unticking the box stating the record can be scavenged changes the record to static.</p>
<p><a href="http://www.indented.co.uk/wp-content/uploads/2008/10/dynamicrecord.jpg"><img class="aligncenter size-medium wp-image-52" title="Dynamic Record" src="http://www.indented.co.uk/wp-content/uploads/2008/10/dynamicrecord-270x300.jpg" alt="" width="270" height="300" /></a></p>
<h3>DNSCMD</h3>
<p>DNSCMD installs along with the Windows Support Tools. It can be used to identify static records, although it can be very difficult pulling the results out of a list like this.</p>
<p><em>For example:</em></p>
<pre class="brush: plain; title: ; notranslate">
dnscmd /ZonePrint somedomain.example
</pre>
<h3>WMIC</h3>
<p>WMIC, Windows Management Instrumentation Command-Line, will install the first time it is run. As the name suggests, it allows execution of WMI queries on the command line.</p>
<pre class="brush: plain; title: ; notranslate">
WMIC /NAMESPACE:&quot;\\root\MicrosoftDNS&quot; PATH &quot;MicrosoftDNS_AType&quot; WHERE &quot;ContainerName='somedomain.example’ AND TimeStamp=0&quot; GET &quot;OwnerName,TTL,TimeStamp&quot;
</pre>
<p>Or</p>
<pre class="brush: plain; title: ; notranslate">
WMIC /NAMESPACE:&quot;\\root\MicrosoftDNS&quot; PATH &quot;MicrosoftDNS_AType&quot; WHERE &quot;TimeStamp=0&quot; GET &quot;OwnerName,TTL,TimeStamp&quot;
</pre>
<h3>VbScript</h3>
<p>This VbScript snippet echoes each static record, it is works best when run with cscript.</p>
<pre class="brush: vb; title: ; notranslate">
strServerName = &quot;dc01.somedomain.example&quot;
strContainerName = &quot;somedomain.example&quot;

Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strServerName &amp; _
  &quot;\root\MicrosoftDNS&quot;)
Set colItems = objWMIService.ExecQuery(&quot;SELECT * FROM MicrosoftDNS_AType &quot; &amp;_
  &quot; WHERE ContainerName='&quot; &amp; strContainerName &amp; &quot;' AND TimeStamp=0&quot;)

For Each objItem In colItems
  WScript.Echo objItem.OwnerName &amp; VbTab &amp; objItem.IPAddress &amp; VbTab &amp; &quot;Static&quot;
Next

Set colItems = Nothing
Set objWMIService = Nothing
</pre>
<h3>PowerShell</h3>
<pre class="brush: powershell; title: ; notranslate">
$ServerName = &quot;dc01.somedomain.example&quot;
$ContainerName = &quot;somedomain.example&quot;

Get-WMIObject -Computer $ServerName `
    -Namespace &quot;root\MicrosoftDNS&quot; -Class &quot;MicrosoftDNS_AType&quot; `
    -Filter &quot;ContainerName='$ContainerName' AND TimeStamp=0&quot; `
  | Select-Object OwnerName,TTL, @{n=&quot;TimeStamp&quot;;e={&quot;Static&quot;}}
</pre>
<p>The same search can be used for any record type, by changing the WMI class. The options most likely to be useful are:</p>
<ul>
<li>MicrosoftDNS_AType &#8211; Address or Host records</li>
<li>MicrosoftDNS_CNAMEType &#8211; Alias records</li>
<li>MicrosoftDNS_MXType &#8211; Mail Exchanger records</li>
<li>MicrosoftDNS_NSType &#8211; Name Server records</li>
<li>MicrosoftDNS_SRVType &#8211; Service records</li>
<li>MicrosoftDNS_PTRType &#8211; Pointer records (Reverse Lookup zone)</li>
</ul>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/02/microsoft-dns-static-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

