<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Obscurum per Obscurius</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/muaddib/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/muaddib/feed.xml</link>
    <description>Explaining the obscure by means of the more obscure</description>
    <lastBuildDate>Tue, 17 May 2016 15:40:33 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How to Configure and Use a PowerShell Profile</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/how-to-configure-and-use-a-powershell-profile</link>
      <pubDate>Wed, 19 Nov 2014 12:08:00 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2014/11/19/how-to-configure-and-use-a-powershell-profile/</guid>
      <description><![CDATA[When you open a PowerShell window to perform some work all the aliases, functions and variables you...]]></description>
      <content:encoded><![CDATA[<p>When you open a PowerShell window to perform some work all the aliases, functions and variables you create are only available in your current session.&nbsp; If you exit the session all these changes are lost.&nbsp; To retain these changes from session to session you can create a Windows PowerShell profile and customize it.&nbsp; The profile is essentially a PowerShell script that runs when you start a PowerShell session.&nbsp; You can copy your profile to other computers so you have a consistent environment on any computer you are working on.</p>
<p>Since the PowerShell profile is a script the Execution policy of your computer must allow scripts to run.&nbsp; Open an elevated PowerShell window and run the following command to check your execution policy:</p>
<blockquote>
<p>Get-ExecutionPolicy</p>
</blockquote>
<p>If it says restricted then scripts are prevented from running.&nbsp; To enable scripts run the following:</p>
<blockquote>
<p>Set-ExecutionPolicy Remotesigned or Set-ExecutionPolicy Remotesigned Unrestricted</p>
</blockquote>
<p>Now you are ready to configure a PowerShell profile.&nbsp; At the PowerShell prompt type:</p>
<blockquote>
<p>$Profile and press ENTER.</p>
</blockquote>
<p>You should see something similar to the following:</p>
<blockquote>
<p>C:\Users\muaddib\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1</p>
</blockquote>
<p>Open the Documents folder and confirm there is a &ldquo;WindowsPowerShel&rdquo; folder.&nbsp; If not create it.</p>
<p>Next open Notepad and create the &ldquo;Microsoft.PowerShell_profile.ps1&rdquo; profile file.</p>
<p>Now let&rsquo;s add some content to the profile.&nbsp; I have a variable that contains my DEV directory where I perform all my PowerShell work.&nbsp; I also have a couple of aliases such as GH for &ldquo;GET-HELP and C for CLS.&nbsp;&nbsp; I also have a few functions I use frequently.&nbsp; Here is an excerpt from my PowerShell profile.&nbsp; When I was first learning PowerShell I used the banner shown below to remind me of some of the common commands every time I opened a PowerShell window.&nbsp; Go ahead and add the content shown below to your profile (&ldquo;Microsoft.PowerShell_profile.ps1&rdquo;) for now to demonstrate the use of the profile and save the file,</p>
<p><span style="font-family: Courier New;"># ALIAS Definitions <br />&nbsp; set-alias -name gh -value get-help <br />&nbsp; set-alias -name c -value cls </span></p>
<p><span style="font-family: Courier New;"># FUNCTIONS <br />&nbsp; #get detailed help <br />&nbsp; Function GHD <br />&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp; CLS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; Get-help $args[0] -detailed | more <br />&nbsp;&nbsp; } #END GHD Function</span></p>
<p><span style="font-family: Courier New;">#Variables <br /> $DEV = &ldquo;C:\dev"</span></p>
<p><span style="font-family: Courier New;">#change working folder to DEV folder <br /> CD $DEV</span></p>
<p><span style="font-family: Courier New;"> ################################################################################# <br />&nbsp; # BANNER <br />&nbsp; #################################################################################</span></p>
<p><span style="font-family: Courier New;">Write-host -foregroundcolor green "USEFUL COMMANDS" <br />&nbsp; Write-host -foregroundcolor yellow "&nbsp; GET-HELP (Get-HELP ABOUT_*)" <br />&nbsp; Write-host -foregroundcolor yellow "&nbsp; GET-HELP GET-SERVICE &ndash;Detailed" <br />&nbsp; Write-host -foregroundcolor yellow "&nbsp; GET-COMMAND" <br />&nbsp; Write-host -foregroundcolor yellow "&nbsp; GET-MODULE &ndash;ListAvailable" <br />&nbsp; write-host ""</span></p>
<p>&nbsp;</p>
<p>Now open a new PowerShell windows and you should see something similar to the figure below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/5707.image_238BD304.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/5707.image_5F00_238BD304.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/5635.image_thumb_2151DAF9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/5635.image_5F00_thumb_5F00_2151DAF9.png" alt="image" width="474" height="233" border="0" /></a></p>
<p>Now type GH GET-SERVICE and you should see the help for the GET-SERVICE cmdlets.&nbsp;</p>
<p>Now type GHD GET-SERVICE to run the GHD function that will display detailed help for the GET-SERVICE cmdlet.&nbsp; I find this easier than typing GET-HELP &lt;cmdlets name &gt; &ndash;detailed when I want detailed help.</p>
<p>So there you have it.&nbsp; Once you have your profile customized its just a matter of moving the file to another computer so you have access to your common work environment.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to Start and Save Virtual Machines with PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/how-to-start-and-save-virtual-machines-with-powershell</link>
      <pubDate>Tue, 01 Apr 2014 14:47:55 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2014/04/01/how-to-start-and-save-virtual-machines-with-powershell/</guid>
      <description><![CDATA[I have a Hyper-V lab I run on my laptop (Windows 8.1, dual quad processor, 32G RAM, 2 HDs) that has...]]></description>
      <content:encoded><![CDATA[<p>I have a Hyper-V lab I run on my laptop (Windows 8.1, dual quad processor, 32G RAM, 2 HDs) that has 7-9 virtual machines (VMs) running.&#160; When I’m done working on my lab I typically SAVE all the running VMs instead of shutting them down.&#160; The next time I need to run the lab I start all the saved VMs.&#160; This is much quicker than waiting for all the operating systems to boot.&#160; </p>  <p>Windows 8 will do this for me automatically but I since I’m a control freak I like to control these actions myself.&#160; One important note.&#160; These are LAB MACHINES.&#160; You should never perform a SAVE action on a production VM especially Active Directory domain controllers.</p>  <p>In the past I would open the Hyper-V console, select all the SAVED systems and click “start” and then reverse the process to shut down the lab.&#160; It occurred to last week I could control these actions faster and easier with PowerShell.&#160; I created two functions named START-LAB and STOP-LAB and added them to my PowerShell profile so they are available in every PowerShell session.&#160; Now I just open an elevated PowerShell window and type the name of the appropriate function.&#160; The code for the functions is shown below:</p>  <p>#START-LAB   <br /> Function Start-Lab {    <br /> if ((get-vm).count -eq 0)     <br />&#160;&#160;&#160; {Write-host    <br />&#160;&#160;&#160;&#160; Write-host -foregroundcolor RED &quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Cannot Start VMs&quot;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160; Write-host -foregroundcolor RED &quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PowerShell is not Running with Elevated Credentials&quot;    <br />&#160;&#160;&#160;&#160; Write-Host    <br />&#160;&#160;&#160;&#160; Exit}    <br />&#160; Else    <br />&#160;&#160;&#160; {Write-Host    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-host &quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Starting all SAVED VMs....&quot;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Host    <br />&#160;&#160;&#160; get-vm |where {$_.state -eq &quot;saved&quot;} | Start-VM    <br />&#160;&#160;&#160; }    <br /> } #END Start-Lab</p>    <p>#STOP-LAB   <br /> Function Stop-Lab {    <br /> if ((get-vm).count -eq 0)     <br />&#160;&#160;&#160; {Write-host    <br />&#160;&#160;&#160;&#160;&#160; Write-host -foregroundcolor RED &quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Cannot Stop VMs&quot;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160; Write-host -foregroundcolor RED &quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PowerShell is not Running with Elevated Credentials&quot;    <br />&#160;&#160;&#160;&#160; Write-Host    <br />&#160;&#160;&#160;&#160; Exit}    <br />&#160; Else    <br />&#160;&#160;&#160; {Write-Host    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-host &quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Saving all running VMs....&quot;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Host    <br />&#160;&#160;&#160; get-vm |where {$_.state -eq &quot;running&quot;} | Save-VM    <br />&#160;&#160;&#160; }    <br /> } #END Stop-Lab</p>]]></content:encoded>
    </item>
    <item>
      <title>PowerShell Script to Query UserAccountControl Flags</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/powershell-script-to-query-useraccountcontrol-flags</link>
      <pubDate>Sun, 30 Mar 2014 13:04:00 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2014/03/30/powershell-script-to-query-useraccountcontrol-flags/</guid>
      <description><![CDATA[One of the services I provide as a Premier Field Engineer is performing health and security...]]></description>
      <content:encoded><![CDATA[<p>One of the services I provide as a Premier Field Engineer is performing health and security assessments in a customer&rsquo;s environment and providing them a detailed report.&nbsp; Recently I was performing an <strong>Offline Assessment for Active Directory Security</strong> for a customer and several accounts were flagged that had some non-standard userAccountControl flags set.</p>
<p>The user userAccountControl flags set various account settings for user/computer accounts in Active Directory.&nbsp; One flag sets the account to &ldquo;Password Never Expires&rdquo; while another flag indicates the &ldquo;Account is Disabled&rdquo;.&nbsp; Multiple flags can be set for an account.&nbsp; The full list and additional information can be found <a href="http://support.microsoft.com/kb/305144" target="_blank">here</a>.</p>
<p>While many of these settings can searched using the PowerShell Get-ADUser cmdlets others are not readily exposed.&nbsp; Most of our security tools reference the individual UserAccountControl flag represented as a decimal number (e.g. 65536 indicates password never expires).&nbsp; When I&rsquo;m onsite I will usually help them find these accounts by performing a quick PowerShell query.&nbsp;</p>
<p>This weekend I decided I would build quick easy to use script to help customers find these accounts and dump them to a file.</p>
<p>When you run the script you are presented with a menu asking which flag you want to query for as shown below.&nbsp; You can query for standard values using the menu or select option 23 and enter a customer decimal value to query for.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0830.image_0AE1C63A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0830.image_5F00_0AE1C63A.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/6574.image_thumb_708FB3FA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/6574.image_5F00_thumb_5F00_708FB3FA.png" alt="image" width="383" height="241" border="0" /></a></p>
<p>Once you make a selection the query is performed and the results are displayed to the screen.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/8664.image_5EBE7054.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/8664.image_5F00_5EBE7054.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/2335.image_thumb_7B46B25B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/2335.image_5F00_thumb_5F00_7B46B25B.png" alt="image" width="244" height="86" border="0" /></a></p>
<p>You are then prompted to save your results to a file by selecting Y or N.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/5758.image_30CAC4A8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/5758.image_5F00_30CAC4A8.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/7848.image_thumb_3457366A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/7848.image_5F00_thumb_5F00_3457366A.png" alt="image" width="244" height="91" border="0" /></a></p>
<p>So there it is pretty simple script for people who don&rsquo;t do a lot of scripting.&nbsp; More experienced scripters can dissect this script and build one more advanced.&nbsp; As always let me know if you have any comments or found this post useful.</p>
<p><strong>The script code is shown below and there is a download link at the bottom of the page.</strong></p>
<p>##############&nbsp;&nbsp; BEGIN SCRIPT #########################################</p>
<p>###################################################################### <br /> # SCRIPT: GET-UAC.ps1 <br /> #PURPOSE: Dump accounts that match UserAccountControl value selected <br /> #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or you can enter customer value <br />#&nbsp;&nbsp;&nbsp; DATE: March 29, 2014 <br /> # <br /> #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> # REVISON: 1.1 <br /> ######################################################################</p>
<p>cls</p>
<p>#Import ActiveDirectory Module if not loaded <br /> $Module = Get-Module ActiveDIrectory <br /> If ($Module -eq $Null) {Import-Module ActiveDirectory}</p>
<p># NOTE - RUN FROM SHELL NOT EDITOR <br /> # Requires -modules ActiveDirectory</p>
<p><br /> #display Options Menu <br /> Write-Host "" <br /> Write-Host -foregroundcolor green "Select the UserAccountControl setting you want to query for:" <br /> Write-Host "1&nbsp;&nbsp;&nbsp; SCRIPT&nbsp;&nbsp;&nbsp;&nbsp; (1, 0x0001)" <br /> Write-Host "2&nbsp;&nbsp;&nbsp; ACCOUNTDISABLE&nbsp;&nbsp;&nbsp;&nbsp; (2, 0x0002)" <br /> Write-Host "3&nbsp;&nbsp;&nbsp; HOMEDIR_REQUIRED&nbsp;&nbsp;&nbsp;&nbsp; (8, 0x0008)" <br /> Write-Host "4&nbsp;&nbsp;&nbsp; LOCKOUT&nbsp;&nbsp;&nbsp;&nbsp; (16, 0x0010)" <br /> Write-Host "5&nbsp;&nbsp;&nbsp; PASSWD_NOTREQD&nbsp;&nbsp;&nbsp;&nbsp; (32, 0x0020)" <br /> Write-Host "6&nbsp;&nbsp;&nbsp; PASSWD_CANT_CHANGE&nbsp;&nbsp;&nbsp;&nbsp; (64, 0x0040)" <br /> Write-Host "7&nbsp;&nbsp;&nbsp; ENCRYPTED_TEXT_PWD_ALLOWED&nbsp;&nbsp;&nbsp;&nbsp; (128, 0x0080)" <br /> Write-Host "8&nbsp;&nbsp;&nbsp; TEMP_DUPLICATE_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (256, 0x0100)" <br /> Write-Host "9&nbsp;&nbsp;&nbsp; NORMAL_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (512, 0x0200)" <br /> Write-Host "10&nbsp;&nbsp; INTERDOMAIN_TRUST_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (2048, 0x0800)" <br /> Write-Host "11&nbsp;&nbsp; WORKSTATION_TRUST_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (4096, 0x1000)" <br /> Write-Host "12&nbsp;&nbsp; SERVER_TRUST_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (8192, 0x2000)" <br /> Write-Host "13&nbsp;&nbsp; DONT_EXPIRE_PASSWORD&nbsp;&nbsp;&nbsp;&nbsp; (65536, 0x10000)" <br /> Write-Host "14&nbsp;&nbsp; MNS_LOGON_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (131072, 0x20000)" <br /> Write-Host "15&nbsp;&nbsp; SMARTCARD_REQUIRED&nbsp;&nbsp;&nbsp;&nbsp; (262144, 0x40000)" <br /> Write-Host "16&nbsp;&nbsp; TRUSTED_FOR_DELEGATION&nbsp;&nbsp;&nbsp;&nbsp; (524288, 0x80000)" <br /> Write-Host "17&nbsp;&nbsp; NOT_DELEGATED&nbsp;&nbsp;&nbsp;&nbsp; (1048576, 0x100000)" <br /> Write-Host "18&nbsp;&nbsp; USE_DES_KEY_ONLY&nbsp;&nbsp;&nbsp;&nbsp; (2097152, 0x200000)" <br /> Write-Host "19&nbsp;&nbsp; DONT_REQ_PREAUTH&nbsp;&nbsp;&nbsp;&nbsp; (4194304, 0x400000)" <br /> Write-Host "20&nbsp;&nbsp; PASSWORD_EXPIRED&nbsp;&nbsp;&nbsp;&nbsp; (8388608, 0x800000)" <br /> Write-Host "21&nbsp;&nbsp; TRUSTED_TO_AUTH_FOR_DELEGATION&nbsp;&nbsp;&nbsp;&nbsp; (16777216, 0x1000000)" <br /> Write-Host "22&nbsp;&nbsp; PARTIAL_SECRETS_ACCOUNT&nbsp;&nbsp;&nbsp;&nbsp; (67108864, 0x04000000 )" <br /> Write-Host "23&nbsp;&nbsp; Custom USerAccountControl value" <br /> Write-host "" <br /> Write-host ""</p>
<p>#PROMPT user for input <br /> [int]$a = Read-Host -prompt "Please Select an Option 1-23"</p>
<p>&nbsp; <br /> # Make sure number entered is not greater than 23 -Show error message <br /> If ($a -gt 23)&nbsp; {Write-host -foregroundcolor red "Number must be between 1-23"}</p>
<p>Write-host "" <br /> Write-host ""</p>
<p>[int]$uacValue = 0</p>
<p>switch ($a) <br /> { <br /> 1&nbsp; {[int]$uacvalue = 1} <br /> 2&nbsp; {[int]$uacvalue = 2} <br /> 3&nbsp; {[int]$uacvalue = 8} <br /> 4&nbsp; {[int]$uacvalue = 16} <br /> 5&nbsp; {[int]$uacvalue = 32} <br /> 6&nbsp; {[int]$uacvalue = 64} <br /> 7&nbsp; {[int]$uacvalue = 128} <br /> 8&nbsp; {[int]$uacvalue = 256} <br /> 9&nbsp; {[int]$uacvalue = 512} <br /> 10&nbsp; {[int]$uacvalue = 2048} <br /> 11&nbsp; {[int]$uacvalue = 4096} <br /> 12&nbsp; {[int]$uacvalue = 8192} <br /> 13&nbsp; {[int]$uacvalue = 65536} <br /> 14&nbsp; {[int]$uacvalue = 131072} <br /> 15&nbsp; {[int]$uacvalue = 262144} <br /> 16&nbsp; {[int]$uacvalue = 524288} <br /> 17&nbsp; {[int]$uacvalue = 1048576} <br /> 18&nbsp; {[int]$uacvalue = 2097152} <br /> 19&nbsp; {[int]$uacvalue = 4194304} <br /> 20&nbsp; {[int]$uacvalue = 8388608} <br /> 21&nbsp; {[int]$uacvalue = 16777216} <br /> 22&nbsp; {[int]$uacvalue = 67108864} <br /> 23&nbsp; {$b = Read-Host -prompt "Enter custom UserAccountControl value (e.g. 514) "; [int]$uacvalue = $b} <br /> }&nbsp;</p>
<p>#WRITE OUTPUT TO SCREEN <br /> # you can customize the properties displayed for each user by adding properties <br /> # to Format-Table command (e.g. name,distinguishedname <br /> $results = Get-ADUser -Filter 'useraccountcontrol -band $uacvalue' -Properties useraccountcontrol | Format-Table name <br /> IF ($results -eq $Null) {Write-Host "No accounts match this criteria";EXIT} <br />&nbsp; Else <br /> {$results}</p>
<p><br /> $fileSave = Read-Host -prompt "Do you want to save results to a file? Press Y or N" <br /> IF ($filesave -eq "y") {out-file -filepath .\UAC_VALUE_$uacvalue.TXT -inputobject $results -encoding ASCII;Write-host"";Write-host"";Write-Host -foregroundcolor green "Output Saved to UAC_VALUE_$uacvalue.TXT" }</p>
<p>##############&nbsp;&nbsp; END SCRIPT #########################################</p>
<h2>Reference</h2>
<p><strong>How to use the UserAccountControl flags to manipulate user account properties</strong></p>
<p><a href="http://support.microsoft.com/kb/305144">http://support.microsoft.com/kb/305144</a></p>
<p><br /><strong>How to Query Individual Properties of the "userAccountControl" Active Directory User property using LDAP</strong></p>
<p><a href="http://blogs.msdn.com/b/muaddib/archive/2008/10/08/query-individual-properties-of-the-useraccountcontrol-active-directory-user-property.aspx">http://blogs.msdn.com/b/muaddib/archive/2008/10/08/query-individual-properties-of-the-useraccountcontrol-active-directory-user-property.aspx</a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/51/22/10/GET-UAC.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-51-22-10/GET_2D00_UAC.zip">GET-UAC.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>List of Rollup Updates for Windows 8/8.1 &amp; Windows Server 2012 / 2012 R2</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/list-of-rollup-updates-for-windows-88-1-windows-server-2012-2012-r2</link>
      <pubDate>Mon, 03 Feb 2014 09:29:52 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2014/02/03/list-of-rollup-updates-for-windows-88-1-windows-server-2012-2012-r2/</guid>
      <description><![CDATA[I put this list together for a couple of customers who were asking for the latest Service Pack for...]]></description>
      <content:encoded><![CDATA[<p>I put this list together for a couple of customers who were asking for the latest Service Pack for these operating systems.&nbsp; It turns out we don&rsquo;t have &ldquo;Service Packs&rdquo; available but we do have &ldquo;Update Rollups&rdquo; available.&nbsp; As you can see from our official terminology below they are very similar in there purpose.<p><strong>Service pack      <br></strong>Definition: A tested, cumulative set of all hotfixes, security updates, critical updates, and updates. Additionally, service packs may contain additional fixes for problems that are found internally since the release of the product. Service packs my also contain a limited number of customer-requested design changes or features.</p><p><strong>Update rollup      <br></strong>Definition: A tested, cumulative set of hotfixes, security updates, critical updates, and updates that are packaged together for easy deployment. A rollup generally targets a specific area, such as security, or a component of a product, such as Internet Information Services (IIS).</p><p>Please keep in mind the lists below may not be exhaustive but were complete as of the time of this writing.&nbsp; I&rsquo;ll try to keep this list updated going forward.&nbsp; You should search TechNet for &ldquo;&lt;operating system&gt; update rollup&rdquo; to find the latest update rollup packages.&nbsp; Another option is to use Microsoft Baseline Security Analyzer (MBSA) or Windows Update to scan for missing updates.</p><p><strong>General Availability - Windows 8 September 2012 / Windows Server 2012 October 2012</strong></p><p>Windows 8 Client and Windows Server 2012 General Availability Update Rollup&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2756872">http://support.microsoft.com/kb/2756872</a></p><p>Windows 8 and Windows Server 2012 update rollup: January 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2785094">http://support.microsoft.com/kb/2785094</a></p><p>Windows 8 and Windows Server 2012 update rollup: April 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2822241">http://support.microsoft.com/kb/2822241</a></p><p>Windows 8 and Windows Server 2012 update rollup: May 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2836988">http://support.microsoft.com/kb/2836988</a></p><p>Windows RT, Windows 8, and Windows Server 2012 update rollup: June 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2845533">http://support.microsoft.com/kb/2845533</a></p><p>Windows RT, Windows 8, and Windows Server 2012 update rollup: July 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2855336">http://support.microsoft.com/kb/2855336</a></p><p>Windows RT, Windows 8, and Windows Server 2012 update rollup: September 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2876415/en-gb">http://support.microsoft.com/kb/2876415/en-gb</a></p><p>Windows RT, Windows 8, and Windows Server 2012 update rollup: October 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2883201">http://support.microsoft.com/kb/2883201</a></p><p>Windows RT, Windows 8, and Windows Server 2012 update rollup: January 2014&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2911101">http://support.microsoft.com/kb/2911101</a>     <br></p><p><strong>General Availability - Windows 8.1 October 2013 / Windows Server 2012 R2 October 2013</strong></p><p>Windows 8.1 and Windows Server 2012 R2 General Availability Update Rollup&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2883200">http://support.microsoft.com/kb/2883200</a> </p><p>Windows 8.1 and Windows Server 2012 R2 update rollup: October 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2884846">http://support.microsoft.com/kb/2884846</a> </p><p>Windows RT 8.1, Windows 8.1, and Windows Server 2012 R2 update rollup: November 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2887595">http://support.microsoft.com/kb/2887595</a></p><p>Windows RT 8.1, Windows 8.1, and Windows Server 2012 R2 update rollup: December 2013&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2903939">http://support.microsoft.com/kb/2903939</a></p><p>Windows RT 8.1, Windows 8.1, and Windows Server 2012 R2 update rollup: January 2014&nbsp;&nbsp;&nbsp; <br><a href="http://support.microsoft.com/kb/2911106">http://support.microsoft.com/kb/2911106</a></p></p>
]]></content:encoded>
    </item>
    <item>
      <title>The Best MMC Keyboard shortcut ever!</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/the-best-mmc-keyboard-shortcut-ever</link>
      <pubDate>Fri, 03 Jan 2014 14:01:38 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2014/01/03/the-best-mmc-keyboard-shortcut-ever/</guid>
      <description><![CDATA[I was reading an internal email thread today and one of my peers mentioned he used to use a keyboard...]]></description>
      <content:encoded><![CDATA[<p>I was reading an internal email thread today and one of my peers mentioned he used to use a keyboard shortcut that would expand an entire tree in a management console but could not remember what the key combination was.&#160; When I read this I too remembered there used to be a “magic” key but I had also forgotten how to do it.&#160; Fortunately another peer knew the answer to the question.</p>  <p>The “magic key” is the asterisk (“ * ”) character on the numeric keypad.&#160; If you are working in Active Directory Sites and Services and want to expand ALL the sites just click on the Sites node at the top of MMC and press “ * “ on the numeric keypad and all the sites will expand to the NTDS Settings object.&#160; To collapse the tree just hit the minus key ( “ – “) on numeric keypad.&#160; This also works in Active Directory Users &amp; Computers DNS etc.</p>  <p>The link below contains additional MMC shortcuts.</p>  <p><strong>MMC Navigation Keyboard Shortcuts</strong>    <br /><a href="http://technet.microsoft.com/en-us/library/cc181576.aspx">http://technet.microsoft.com/en-us/library/cc181576.aspx</a> </p>  <p>For me this is a life-changing improvement in productivity.&#160; How about you?   </p>]]></content:encoded>
    </item>
    <item>
      <title>How to Modify Security Inheritance on Active Directory Objects using PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/how-to-modify-security-inheritance-on-active-directory-objects-using-powershell</link>
      <pubDate>Mon, 30 Dec 2013 08:28:00 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2013/12/30/how-to-modify-security-inheritance-on-active-directory-objects-using-powershell/</guid>
      <description><![CDATA[A couple of weeks ago I was working with a customer analyzing a number of user accounts affected by...]]></description>
      <content:encoded><![CDATA[<p>A couple of weeks ago I was working with a customer analyzing a number of user accounts affected by AdminSDHolder protection.&nbsp; User accounts that are members of privileged groups such as Domain Admins end up being modified so they are protected by AdminSDHolder.&nbsp; There is a property named AdminCount that usually has no value that is set to &ldquo;1&rdquo; once an account is added to a privileged group.&nbsp; In addition the inheritance flag is unchecked so the account no longer inherits permissions from a parent object (I.E. an OU).&nbsp; The AdminCount value has no effect on the account and is used as a flag to indicate the account is, or was, protected.&nbsp; More information can be found in the Reference section below.</p>
<p>When the account is removed from a privileged group these two changes are not automatically reversed and must be changed manually.&nbsp; The inability to inherit permissions will prevent your delegation model from working as expected so we decided to create script to set the AdminCount back to it&rsquo;s default state and enable inheritance on the user objects.</p>
<p>Finding accounts that were or are members of privileged groups is easy enough.&nbsp; You can use the Get-ADUser cmdlet to find them as shown below:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">Get-ADUser -Filter {AdminCount -eq 1} -properties AdminCount</span></p>
</blockquote>
<p>Changing the AdminCount property on an object back to the default state is easy enough as well:</p>
<blockquote><span style="font-family: Consolas; font-size: x-small;">Set-ADUser &lt;user identity&gt; -Clear AdminCount</span></blockquote>
<p>Modifying the inheritance flag was a bit more challenging.&nbsp; First lets describe the behavior of the inheritance flag and where it is located in the GUI.&nbsp; The Inheritance Flag can be set using Active Directory Users &amp; Computers (ADUCs).&nbsp; You can see checkbox by viewing the properties for a user, selecting the &ldquo;Security&rdquo; tab and then clicking the &ldquo;Advanced&rdquo; button and you will see the screen shown below.</p>
<blockquote>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/2117.image_3DAF2EC4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/2117.image_5F00_3DAF2EC4.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/5658.image_thumb_14A72079.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/5658.image_5F00_thumb_5F00_14A72079.png" alt="image" width="244" height="185" border="0" /></a></p>
</blockquote>
<blockquote>
<p><span style="font-size: xx-small;">Figure 1 &ndash; Inheritance flag check box</span></p>
</blockquote>
<p>If you uncheck the box you will receive the following prompt asking you if you want to copy the existing permissions to the object.</p>
<blockquote>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0407.image_0FC46CBD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0407.image_5F00_0FC46CBD.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0312.image_thumb_042EAF7E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0312.image_5F00_thumb_5F00_042EAF7E.png" alt="image" width="244" height="113" border="0" /></a></p>
</blockquote>
<blockquote>
<p><span style="font-size: xx-small;">Figure 2 &ndash; Copy permissions dialog,</span></p>
</blockquote>
<p>Clicking &ldquo;Add&rdquo; will add the inherited permissions form the parent object.&nbsp; Clicking &ldquo;Remove&rdquo; will leave the object with the permissions applied explicitly to the object.</p>
<p>We spent a good deal of time trying to find a way to &ldquo;check&rdquo; the inheritance box programmatically in PowerShell.&nbsp; After a few hours we realized we had other work to do and settled on a tried and true method that uses DSACLS command to enable inheritance.&nbsp; The command is shown below.</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">DSACLS &lt;User DN&gt;&nbsp; /P:N</span></p>
</blockquote>
<p>We were now able to script these changes on the desired accounts but I still wanted to find out how to do this using native PowerShell commands&hellip;</p>
<h1>The Quest&hellip;</h1>
<p>Before you read any further you need to understand I am NOT a programmer.&nbsp; I&rsquo;m a support engineer who likes to automate tasks with scripting languages.&nbsp; The great thing about PowerShell is it exposes the underlying .NET code and makes it easy for mortals like me&nbsp;to write scripts quickly and easily.&nbsp; For more&nbsp;advanced scripts I am forced to &ldquo;look under the hood&rdquo; understand what is happening at the programming level.&nbsp; This is where the challenge, and the learning happens for me.&nbsp; The remainder of the article will explain how I found the solution to my problem.</p>
<p>Most of my research for enabling inheritance on an object with PowerShell showed examples of modifying files and folders instead of users.&nbsp; The interesting thing is the same PowerShell cmdlets works for files, folders and Active Directory objects.</p>
<p>The good news is Get-Acl and Set-Acl cmdlets can be used to read and set security on Active Directory objects.&nbsp; The bad news is the process to enable/disable inheritance is not very intuitive at all.&nbsp;</p>
<p>To get started I created a test account named &ldquo;ACL Test&rdquo; and unchecked the inheritance flag.&nbsp; I then started looking at all properties on the object by running the following command:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">Get-ADUSer acltest &ndash;properties * |fl *</span></p>
</blockquote>
<p>I noticed there was something called nTSecurityDescriptor that displayed&nbsp; &ldquo;System.DirectoryServices.ActiveDirectorySecurity&rdquo; instead of a normal property value which indicated I was dealing with an object.&nbsp;&nbsp;I used the following commands to expose more information:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">$user = Get-ADUSer acltest &ndash;properties * |fl *</span></p>
<p><span style="font-family: Consolas; font-size: x-small;">$user.nTSecurityDescriptor&nbsp; |Get-Member</span></p>
</blockquote>
<p>This command showed promise.</p>
<blockquote>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/6574.image_17B8DDC1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/6574.image_5F00_17B8DDC1.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/4442.image_thumb_1B59894F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/4442.image_5F00_thumb_5F00_1B59894F.png" alt="image" width="244" height="189" border="0" /></a></p>
<p><span style="font-size: xx-small;">Figure 3 &ndash; Get-Member output for nTSecurityDescriptor&nbsp; </span></p>
</blockquote>
<p>At some point during several hours of &ldquo;Bing-ing&rdquo; I became aware that the inheritance flag was also referred to an Access Rule.&nbsp; The first thing I noticed was this:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">AreAccessRulesProtected&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp; bool AreAccessRulesProtected {get;}</span></p>
</blockquote>
<p>This property shows the state of the inheritance check flag on the object.&nbsp; So the command below made it easy to check the status of the flag:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">$user.nTSecurityDescriptor.AreAccessRulesProtected&nbsp; </span></p>
</blockquote>
<p>If the box was checked the command would return FALSE.&nbsp; If the box was unchecked it would return TRUE.&nbsp; I was able to verify this by checking and unchecking the box manually and running the code above.</p>
<p>As I started researching the process and testing code it became apparent to me I needed an easier way to determine if my code was making the change&nbsp;successfully.&nbsp;&nbsp;Frankly refreshing the object in ADUCs, viewing the properties selecting the &ldquo;Security&rdquo; tab and then &ldquo;Advanced&rdquo; button to view the checkbox for each test cycle was getting old.&nbsp; To solve this problem I used a&nbsp;PowerShell loop running in a separate&nbsp;window&nbsp;to monitor the change on the&nbsp;test account.&nbsp; The PowerShell code shown below checks the status of the flag every five seconds and repeats the check&nbsp;!000 times which meant I could work for over 80 minutes before restarting my monitor loop.&nbsp;</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">FOR($i=1;$i -le 1000; $i++){(get-aduser acltest -properties nTSecurityDescriptor).nTSecurityDescriptor.AreAccessRulesProtected ;Write-host "Count = $i";start-sleep 5}</span></p>
</blockquote>
<p>The output is shown below.&nbsp; I displayed the &ldquo;count&rdquo; so I could tell the display was updating.&nbsp; You can see where the state change occurred during my testing.</p>
<blockquote>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0172.image_3D44EBD3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0172.image_5F00_3D44EBD3.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0675.image_thumb_18B35E4F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0675.image_5F00_thumb_5F00_18B35E4F.png" alt="image" width="244" height="238" border="0" /></a></p>
<p><span style="font-size: xx-small;">Figure 4 &ndash; Monitoring my progress</span></p>
</blockquote>
<p>Keep in mind when you make a change in Active Directory it does not appear immediately but can take several seconds before the change can be detected.&nbsp; During my testing a change was usually detected within one or two 5 second cycles.</p>
<p>During my research&nbsp;I kept seeing examples of using Get-Acl and Set-Acl to set&nbsp;inheritance on OUs, files and folders but no examples of performing this task on users.&nbsp; I&rsquo;ll spare you the details but I was unable to change the state of the inheritance flags using the methods associated with $user.nTSecurityDescriptor&nbsp;object initially because I did not understand how to "write" the updated security information back to Active Directory.&nbsp; At this point in my testing and research I switched my focus to using Get-Acl and Set-Acl to solve my problem.</p>
<p>The first thing I did was run Get-Acl on the &ldquo;ACL Test&rdquo; user object and store that in a variable.</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">$ACL = Get-ACL -path 'AD:\CN=ACL Test,OU=Managed Users,DC=Contoso,DC=com'</span></p>
</blockquote>
<p>The $ACL variable is an object that represents the security of the &ldquo;CN=ACL Test,OU=Managed Users,DC=Contoso,DC=com&rdquo; user object.&nbsp; I then ran Get-Member on $ACL to expose the same properties and methods I had seen on the nTSecurityDescriptor object in earlier testing.</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">$ACL | Get-Member</span></p>
</blockquote>
<blockquote>
<p><strong>NOTE</strong>- See the ACL_GET_MEMBER.TXT file attached below to see all the properties and methods exposed.</p>
</blockquote>
<p>Several properties and methods were exposed but I was focused on two.&nbsp; The first was the &ldquo;AreAccessRulesProtected&rdquo; property which tells me the status of the inheritance checkbox.&nbsp; The second one is the &ldquo;SetAccessRuleProtection&rdquo; method shown below:</p>
<blockquote>
<p><span style="font-size: x-small;"><span style="font-family: Consolas;">SetAccessRuleProtection Method void SetAccessRuleProtection(bool&nbsp; </span><span style="font-family: Consolas;">IsProtected, bool preserveInheritance)</span></span></p>
</blockquote>
<p>Lets look at this a little closer.&nbsp; We see that &ldquo;SetAccessRuleProtection&rdquo; is a method which means we can take some type of action on the object.&nbsp; Then we see the word &ldquo;bool&rdquo; which is short for Boolean which means the two parameters we are passing; IsProtected and PreserveInheritance will be TRUE or FALSE when passed to the method.&nbsp; If we call the &ldquo;SetAccessRuleProtection&rdquo; method and set the value of the IsProtected parameter to TRUE, the inheritance checkbox will be cleared.&nbsp; If we set it to FALSE, the checkbox will become checked.&nbsp; The &ldquo;preserveInheritance&rdquo; parameter only has an effect when we uncheck the inheritance checkbox&nbsp; (IsProtected = TRUE).&nbsp; If we set preserveInheritance to TRUE then the permissions from the parent object are copied to the object.&nbsp; It has the same effect as clicking &ldquo;Add&rdquo; in figure 2 above.&nbsp; If &ldquo;preserverInheritance&rdquo; is set to FALSE, it has the same effect as clicking &ldquo;Remove&rdquo; in Figure 2 above.&nbsp; Let&rsquo;s take a look at the code in action.</p>
<p>First we create an object that represents the current security configuration of our user (ACL Test) using Get-Acl and store it in the variable $ACL.&nbsp; Notice the &ldquo;AD:\&rdquo; in front of the distinguished name for the user object.&nbsp; This let&rsquo;s Get-Acl command know the object is located on the Active Directory PSDrive (PowerShell Drive).</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">$ACL = Get-ACL -path 'AD:\CN=ACL Test,OU=Managed Users,DC=Contoso,DC=com'</span></p>
</blockquote>
<p>Next we call the SetAccessRuleProtection method of the $ACL security object and pass $False for the &ldquo;IsProtected&rdquo; parameter which will &ldquo;check&rdquo; the inheritance checkbox for the user account. We also pass $True for the &ldquo;preserveInheritance&rdquo; parameter but it has no effect since we are enabling inheritance.&nbsp; At this point in time we have modified the security on the $ACL object but we have not modified the object in Active Directory.</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">$ACL.SetAccessRuleProtection($False,$True)</span></p>
</blockquote>
<p>Finally we use Set-Acl to overwrite the security of the &ldquo;ACL Test&rdquo; user account in Active Directory with the value stored in $ACL variable.</p>
<blockquote>
<p><span style="font-family: Consolas;"><span style="font-size: xx-small;"><span style="font-size: x-small;"> Set-ACL -AclObject $ACL -path 'AD:\CN=ACL Test,OU=Managed Users,DC=Contoso,DC=com'</span> </span></span></p>
</blockquote>
<p>Now that I understood how to write the security changes back to Active Directory using Set-Acl I realized I would be able to perform the same task using the $user.nTSecurityDescriptor&nbsp;path I had started down originally.&nbsp; Here is the solution using that method:</p>
<p style="padding-left: 30px;">&nbsp;$user = get-aduser acltest -properties ntsecuritydescriptor<br />&nbsp;$user.ntsecuritydescriptor.SetAccessRuleProtection($false, $true)<br />&nbsp;Set-Acl -AclObject $user.ntsecurityDescriptor&nbsp; -Path "AD:\CN=ACL Test,OU=PS_USERS,DC=AD,DC=CONTOSO,DC=COM"<br />&nbsp;</p>
<h1>Putting it All Together</h1>
<p>Now that we know how to use Get-Acl and Set-Acl to modify the inheritance flag let&rsquo;s put it in a PowerShell function to make it easier to use in a script:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">Function Set-Inheritance { <br />&nbsp;&nbsp;&nbsp; param($ObjectPath) <br />&nbsp;&nbsp;&nbsp; $ACL = Get-ACL -path "AD:\$ObjectPath" <br />&nbsp;&nbsp;&nbsp; If ($acl.AreAccessRulesProtected){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ACL.SetAccessRuleProtection($False, $True) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set-ACL -AclObject $ACL -path "AD:\$ObjectPath" <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Host "MODIFIED "$ObjectPath <br />&nbsp;&nbsp;&nbsp; } #End IF <br /> } #End Function Set-Inheritance</span></p>
</blockquote>
<p>To use the function we call the function and pass the distinguished name of the object we want to enable inheritance on.&nbsp; Here is a sample script that uses the function:</p>
<blockquote>
<p><span style="font-family: Consolas; font-size: x-small;">Import-Module ActiveDirectory</span></p>
<p><span style="font-family: Consolas; font-size: x-small;"> Function Set-Inheritance { <br />&nbsp;&nbsp;&nbsp; param($ObjectPath) <br />&nbsp;&nbsp;&nbsp; $ACL = Get-ACL -path "AD:\$ObjectPath" <br />&nbsp;&nbsp;&nbsp; If ($acl.AreAccessRulesProtected){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ACL.SetAccessRuleProtection($False, $True) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set-ACL -AclObject $ACL -path "AD:\$ObjectPath" <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Host "MODIFIED "$ObjectPath <br />&nbsp;&nbsp;&nbsp; } #End IF <br /> } #End Function Set-Inheritance</span></p>
<p><span style="font-size: x-small;"><span style="font-family: Consolas;">#Find user with AdminCount set to 1 <br /></span><span style="font-family: Consolas;">$users = get-aduser -SearchBase "OU=Managed Users,DC=Contoso,DC=com" -Filter {AdminCount -eq 1} <br />#Enable inheritance flag for each user <br /> $users | foreach {Set-Inheritance $_.distinguishedname}</span></span></p>
</blockquote>
<p>We place the PowerShell function Set-Inheritance at the top of the script so it is loaded into memory before we call the function later in the script.&nbsp; We search for users with their AdminCount property set to &ldquo;1&rdquo; and store them in the $users variable.&nbsp; Then we loop through each user in the variable $users and pass the distinguished name of each user to the Set-Inheritance function to set the inheritance flag so the object will inherit permissions.</p>
<p>So there you have it.&nbsp; A long discussion on how I arrived at what amounts to three lines of PowerShell code to perform the same task as &ldquo;DSACLS &lt;User DN&gt; /P:N&rdquo;.&nbsp; As always if you have feedback or questions use the comments section below.</p>
<h1>Reference</h1>
<p><strong>Regarding AdminSDHolder</strong> <br /><a href="http://blogs.technet.com/b/asiasupp/archive/2006/11/16/adminsdholder1.aspx">http://blogs.technet.com/b/asiasupp/archive/2006/11/16/adminsdholder1.aspx</a></p>
<p><strong>AdminSDHolder, Protected Groups and SDPROP</strong> <br /><a href="http://technet.microsoft.com/en-us/magazine/2009.09.sdadminholder.aspx">http://technet.microsoft.com/en-us/magazine/2009.09.sdadminholder.aspx</a></p>
<p><strong>Delegated permissions are not available and inheritance is automatically disabled</strong> <br /><a href="http://support.microsoft.com/kb/817433">http://support.microsoft.com/kb/817433</a></p>
<p><strong>AdminSDHolder Object Affects Delegation of Control for Past Administrator Accounts</strong> <br /><a href="http://support.microsoft.com/kb/306398">http://support.microsoft.com/kb/306398</a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/48/60/35/ACL_GET_MEMBER.txt" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-48-60-35/ACL_5F00_GET_5F00_MEMBER.txt">ACL_GET_MEMBER.txt</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How to update the list of Name Servers on a DNS Zone with a Script</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/how-to-update-the-list-of-name-servers-on-a-dns-zone-with-a-script</link>
      <pubDate>Mon, 16 Dec 2013 16:02:00 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2013/12/16/how-to-update-the-list-of-name-servers-on-a-dns-zone-with-a-script/</guid>
      <description><![CDATA[I was working with a customer this week doing some Active Directory cleanup tasks.&nbsp; We were...]]></description>
      <content:encoded><![CDATA[<p>I was working with a customer this week doing some Active Directory cleanup tasks.&nbsp; We were decommissioning the last of their Windows Server 2003 domain controllers so we could upgrade the domain and forest functional level to Windows Server 2008 R2 to take advantage of some new features.</p>
<p>After removing the last Windows Server 2003 domain controller we opened up the DNS console to cleanup all the references to the decommissioned server including SRV records and DNS zone name server entries.&nbsp; Removing the name server entries from the forward lookup zones was easy to do manually since there were only a couple.&nbsp; When we got to the reverse lookup zones we realized we needed some automation since there were over 20 reverse lookup zones to remove the obsolete name server entries from.</p>
<p>The following commands can be used to Add or Delete Name Server (NS) records from a zone:</p>
<p><strong>Add Record</strong></p>
<blockquote>
<p><span style="font-family: Consolas;">DNSCMD &lt;DNS server&gt; /RECORDADD &lt;zone name&gt; @ NS &lt;name server FQDN&gt;</span></p>
</blockquote>
<p><strong>Delete Record</strong></p>
<blockquote>
<p><span style="font-family: Consolas;">DNSCMD &lt;DNS server&gt; /RECORDDELETE &lt;zone name&gt; @ NS &lt;name server FQDN&gt; /F</span></p>
</blockquote>
<p>Notice the &ldquo;/F&rdquo; at the end of the delete command.&nbsp; This suppresses the &ldquo;Y/N?&rdquo; prompt</p>
<p>To automate the task we created a script that uses a DOS FOR loop to iterate through the zones in a text file and remove the obsolete name server records.&nbsp; I added the DNSCMD commands above to my standard FOR loop script template that includes logging.</p>
<p>The first thing we did was create a ZONES.TXT file containing all the reverse lookup zones we needed to modify.&nbsp; We placed the ZONES.TXT file in the same directory as the script.&nbsp;</p>
<p>The contents are shown below:</p>
<p><span style="font-family: Consolas;">11.10.10.in-addr.arpa <br /> 12.10.10.in-addr.arpa <br /> 13.10.10.in-addr.arpa <br /> 14.10.10.in-addr.arpa <br /> 15.10.10.in-addr.arpa <br />16.10.10.in-addr.arpa <br /></span></p>
<p>The contents of the UPDATE_NAME_SERVERS.CMD script is shown below:</p>
<p><span style="font-family: Consolas;">:::::::::::::::::::::::::: BEGIN SCRIPT ::::::::::::::::::::::::::::::::</span></p>
<p><span style="font-family: Consolas;">@ECHO OFF <br />&nbsp; :: NAME:UPDATE_NAME_SERVERS <br />&nbsp; :: DATE: 4:56 PM 12/16/2013 <br />&nbsp; :: PURPOSE:&nbsp; <br />&nbsp; :: <br />&nbsp; :: The ZONES.TXT contains a list of zones (one server per line) <br />&nbsp; :: to be modified <br />&nbsp;&nbsp; <br />&nbsp; SET LOGFILENAME=.\UPDATE_NAME_SERVER_OUTPUT.LOG</span></p>
<p><span style="font-family: Consolas;">ECHO&nbsp;&nbsp;&nbsp;&nbsp; DATE: %DATE% &gt; %LOGFILENAME% <br /> ECHO&nbsp;&nbsp;&nbsp;&nbsp; TIME: %TIME% &gt;&gt; %LOGFILENAME% <br /> ECHO&nbsp;&nbsp;&nbsp;&nbsp; USER: %USERNAME% &gt;&gt; %LOGFILENAME% <br /> ECHO COMPUTER: %COMPUTERNAME% &gt;&gt; %LOGFILENAME% <br /> ECHO. &gt;&gt; %LOGFILENAME% <br /> ECHO. &gt;&gt; %LOGFILENAME% <br /> ECHO. &gt;&gt; %LOGFILENAME%</span></p>
<p><span style="font-family: Consolas;">FOR /F "tokens=1" %%i in (zones.txt) DO ( <br />&nbsp;&nbsp; ECHO Running command on... %%i <br />&nbsp;&nbsp; ECHO. &gt;&gt; %LOGFILENAME% <br />&nbsp;&nbsp; REM Delete Name Server (NS) records from a zone <br />&nbsp;&nbsp; <span style="background-color: #ffff00;"> dnscmd vdc02.contoso.com /recorddelete %%i @ NS admin1.contoso.com /f&nbsp; &gt;&gt; %LOGFILENAME%</span> </span></p>
<p><span style="font-family: Consolas;">&nbsp; REM USe this section to ADD Name Server (NS) Records <br />&nbsp;&nbsp; REM Uncomment the DNSCMD line below to add NS records <br />&nbsp;&nbsp; REM ============================================ <br />&nbsp;&nbsp; REM&nbsp; dnscmd vdc02.contoso.com /recordadd %%i @ NS admin1.contoso.com &gt;&gt; %LOGFILENAME% <br />&nbsp; )</span></p>
<p><span style="font-family: Consolas;">GOTO EOF</span></p>
<p><span style="font-family: Consolas;">:EOF <br />&nbsp; ECHO. <br />&nbsp; ECHO. <br />&nbsp; ECHO&nbsp; %0 COMPLETED! <br />&nbsp; ECHO. <br />&nbsp; ECHO. <br />&nbsp; ECHO. <br />&nbsp; :::::::::::::::::::::::::: END SCRIPT :::::::::::::::::::::::::::::::::::</span></p>
<p>Remember when using sample scripts always test them in a lab environment first before using them in production.&nbsp; If you found this useful or have feedback feel free to leave me a comment below.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to find user accounts with Kerberos preauthentication disabled.</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/how-to-find-user-accounts-with-kerberos-preauthentication-disabled</link>
      <pubDate>Mon, 28 Oct 2013 16:42:26 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2013/10/28/how-to-find-user-accounts-with-kerberos-preauthentication-disabled/</guid>
      <description><![CDATA[One of my duties as a Premier Field Engineer is to perform Active Directory Risk Assessments (aka...]]></description>
      <content:encoded><![CDATA[<p>One of my duties as a Premier Field Engineer is to perform Active Directory Risk Assessments (aka <a href="http://download.microsoft.com/download/1/C/1/1C15BA51-840E-498D-86C6-4BD35D33C79E/Datasheet_ADRAP.pdf">ADRAP</a>).&#160; During these risk assessments we review the configuration of key components of Active Directory to determine if there are any settings that vary from our recommended practices.</p>  <p>During almost every ADRAP I perform we get a message from our assessment tool indicating that one or more user accounts have Kerberos preauthentication disabled.&#160; Unfortunately the tool does not tells us which accounts.&#160; Before we discuss finding the accounts lets talk about the impact of disabling Kerberos pre-authentication.</p>  <p>During Kerberos authentication the Authentication Service (AS) request identifies the client to the KDC in plain text. If preauthentication is enabled, a time stamp will be encrypted using the user's password hash as an encryption key. If the KDC reads a valid time when using the user's password hash (stored in the Active Directory) to decrypt the time stamp, the KDC knows that request isn't a replay of a previous request. </p>  <p>The preauthentication feature may be disabled for specific users in order to support some applications that don't support the security feature. Access the user account from the Active Directory users and the computers will snap-in and select the account tab. From the account options: slide window, check mark the &quot;Do not require Kerberos&quot; preauthentication option (see below).</p>  <p><a href="http://technet.microsoft.com/en-us/library/Bb742516.kerb02_big(l=en-us).gif"><img title="Bb742516.kerb02(en-us,TechNet.10).gif" alt="Bb742516.kerb02(en-us,TechNet.10).gif" src="http://i.technet.microsoft.com/dynimg/IC86356.gif" /></a></p>  <p>More information on Kerberos can be found in the Reference section below.</p>  <p>So the Kerberos preauthentication setting is part of the UserAccountControl settings for accounts in Active Directory.&#160; We can read the value of this setting from Active Directory to find these accounts.&#160; When you view the UserAccountControl setting in ADSIEDIT (decimal) or LDP (hex) you will see a number representing the different flags (e.g disabled, password never expires etc.) configured on the account.&#160; More information on UserAccountControl can be found in the Reference section below.</p>  <h1>Searching Active Directory</h1>  <p>There are two simple ways you can find these accounts in Active Directory.&#160; The first method involves creating a custom LDAP query in Active Directory Users &amp; Computers (see Reference below) and using the LDAP query string below:</p>  <p>(&amp;(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=4194304))</p>  <p>The second method is to use PowerShell to query Active Directory.&#160; Two examples are shown below:</p>  <p> get-aduser&#160; -LDAP &quot;(&amp;(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=4194304))&quot; -properties DoesNotRequirePreAuth</p>  <p> get-aduser -filter * -properties DoesNotRequirePreAuth |where {$_.DoesNotRequirePreAuth -eq &quot;TRUE&quot;}    <br /></p>  <h1>Reference </h1>  <p><strong>Kerberos Explained      <br /></strong><a href="http://technet.microsoft.com/en-us/library/bb742516.aspx">http://technet.microsoft.com/en-us/library/bb742516.aspx</a> </p>  <p><strong>How to Create Custom Active Directory LDAP Searches      <br /></strong><a href="http://blogs.msdn.com/b/muaddib/archive/2011/10/24/active-directory-ldap-searches.aspx">http://blogs.msdn.com/b/muaddib/archive/2011/10/24/active-directory-ldap-searches.aspx</a> </p>  <p><strong>How to Query Individual Properties of the &quot;userAccountControl&quot; Active Directory User property using LDAP      <br /></strong><a href="http://blogs.msdn.com/b/muaddib/archive/2008/10/08/query-individual-properties-of-the-useraccountcontrol-active-directory-user-property.aspx">http://blogs.msdn.com/b/muaddib/archive/2008/10/08/query-individual-properties-of-the-useraccountcontrol-active-directory-user-property.aspx</a></p>  <p><strong>How to use the UserAccountControl flags to manipulate user account properties      <br /></strong> http://support.microsoft.com/kb/305144</p>]]></content:encoded>
    </item>
    <item>
      <title>Understanding and Managing the Certificate Stores Used for Smart Card Logon</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/understanding-and-managing-the-certificate-stores-used-for-smart-card-logon</link>
      <pubDate>Fri, 18 Oct 2013 10:55:00 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2013/10/18/understanding-and-managing-the-certificate-stores-used-for-smart-card-logon/</guid>
      <description><![CDATA[Recently I was onsite helping a customer clean up some certificates related to smart card...]]></description>
      <content:encoded><![CDATA[<p>Recently I was onsite helping a customer clean up some certificates related to smart card logon.&nbsp; One of the things I find challenging about PKI and specifically about smart card&nbsp; logon is remembering how and where to publish certificates.&nbsp; It seems like every time I work on an issue related to smart card logon and I need to re-learn the information.&nbsp; Today I decided to write it all down while it is &ldquo;fresh&rdquo;.&nbsp; This article will not explain how to implement a complete smart card logon solution but instead explain in more detail how to manage the certificates and stores used for smart card logon.&nbsp;</p>
<p><strong>Caution</strong> &ndash; before making changes to the Certificates or Certificate Stores&nbsp;in your environment make sure you understand the impact of the change you are making.&nbsp; Modifying the Certificate stores via Active Directory containers or Group Policy will affect a large number of computers and can break smart card logon or applications.&nbsp;</p>
<p>In order to enable smart card logon there are a number of certificates that need to be published (installed) on each computer into the correct store.&nbsp; The certificates required can be published via Group Policy, published into Active Directory or even into the local registry of each computer manually (not recommended).&nbsp; The following information will explain the stores used to enable smart card logon at a high level and explain how to view the contents of the store as using several methods.</p>
<h2>Certificate Stores</h2>
<p>A Certificate Store can be thought of as a logical container in the operating system that holds one or more certificates.&nbsp; The most common way to view the certificate stores is using the Certificates MMC snap-in as shown below (click graphic for larger view).</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/6153.image_3D5A31E3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/6153.image_5F00_3D5A31E3.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/5428.image_thumb_43A39922.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/5428.image_5F00_thumb_5F00_43A39922.png" alt="image" width="605" height="279" border="0" /></a></p>
<p>By default the Certificates snap-in displays the logical view of each store.&nbsp; In reality this logical view is comprised of the certificates from each of the physical certificate stores on the computer.&nbsp; These physical locations are located in the registry in different keys.&nbsp; When you look at the registry location you will see keys labeled with hexadecimal numbers.&nbsp; These numbers are the thumbprint for each certificate in the store.&nbsp; The certificate information is stored in the registry as a BLOB (Binary Large object) and cannot be viewed within the registry.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/3465.image_332B2827.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/3465.image_5F00_332B2827.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/3324.image_thumb_2E48746B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/3324.image_5F00_thumb_5F00_2E48746B.png" alt="image" width="605" height="362" border="0" /></a></p>
<p>To configure the snap-in to show the physical stores do the following:</p>
<ol>
<li>Right-click the Certificates Node &gt; View &gt; Options</li>
<li>Check the Physical certificate stores box <br /> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/4401.image_7E2129A7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/4401.image_5F00_7E2129A7.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/6087.image_thumb_5D99E9F5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/6087.image_5F00_thumb_5F00_5D99E9F5.png" alt="image" width="244" height="191" border="0" /></a></li>
</ol>
<p>You will notice in the graphic below there are now three additional nodes that represent the physical stores on the local computer; Registry, Group Policy and Enterprise</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/3288.image_0D579275.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/3288.image_5F00_0D579275.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/7838.image_thumb_56110B39.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/7838.image_5F00_thumb_5F00_56110B39.png" alt="image" width="598" height="314" border="0" /></a></p>
<p>Another fun fact about working with certificate stores is different names are used to represent the stores depending on the tool you are using.&nbsp; This is perhaps the most confusing aspect of working with certificates and stores.&nbsp; The table below shows the conventional name of the store as viewed in the Certificates snap-in and the name used in other tools.</p>
<p>&nbsp;</p>
<table style="width: 575px;" border="1" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td valign="top" width="150"><strong>Certificates Snap-in</strong></td>
<td valign="top" width="150"><strong>Enterprise PKI Snap-in</strong></td>
<td valign="top" width="150"><strong>CERTUTIL Command</strong></td>
<td valign="top" width="150"><strong>Registry</strong></td>
</tr>
<tr>
<td valign="top" width="150">Trusted Root Certification Authorities</td>
<td valign="top" width="150">Certificates Authorities Container tab</td>
<td valign="top" width="150">Root</td>
<td valign="top" width="150">Root</td>
</tr>
<tr>
<td valign="top" width="150">Intermediate Certification Authorities</td>
<td valign="top" width="150">AIA Container tab</td>
<td valign="top" width="150">SubCA (publish to AD) <br />CA (View local store)</td>
<td valign="top" width="150">CA</td>
</tr>
<tr>
<td valign="top" width="150">Third-Party Root Certification Authorities</td>
<td valign="top" width="150">not applicable</td>
<td valign="top" width="150">AuthRoot</td>
<td valign="top" width="150">AuthRoot</td>
</tr>
<tr>
<td valign="top" width="150">Personal</td>
<td valign="top" width="150">not applicable</td>
<td valign="top" width="150">MY</td>
<td valign="top" width="150">MY</td>
</tr>
<tr>
<td valign="top" width="150">not applicable</td>
<td valign="top" width="150">NTAuthCertificates tab</td>
<td valign="top" width="150">NTAuthCA (publish to AD) <br />NTAuth (View)</td>
<td valign="top" width="150">not applicable</td>
</tr>
</tbody>
</table>
<p>Note the AIA Container and the NTAuthCertificates are not certificate stores but containers in Active directory in the Configuration partition.&nbsp; They are included here because the name mapping helps when using the CERTUTIL command to publish certificates into Active Directory.&nbsp; Certificates in the AIA Container are published to clients in the Enterprise physical store described in more detail below.</p>
<h3>Registry (Physical Store)</h3>
<p>These are certificates published into the local registry of the computer.&nbsp; The certificates can be found in the following registry key:</p>
<blockquote>
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates&nbsp;&nbsp;</p>
</blockquote>
<p>To view these certificates using CERTUTIL type the following:</p>
<blockquote>
<p>CERTUTIL -viewstore &lt;store name&gt; where store name is MY, Root, CA, AuthRoot</p>
</blockquote>
<h3>Group Policy (Physical Store)</h3>
<p>These certificates are published to the physical store via Group Policy and are updated when Group Policy refreshes.</p>
<p>These are certificate published via a Group Policy and can be found in the following registry key:</p>
<blockquote>
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SystemCertificates</p>
</blockquote>
<p>To view these certificates using CERTUTIL type the following:</p>
<blockquote>
<p>CERTUTIL -viewstore -GroupPolicy &lt;store name&gt; where store name is MY, Root, CA, AuthRoot</p>
</blockquote>
<h3>Enterprise (Physical Store)</h3>
<p>These certificates are published into Active Directory containers.&nbsp; There is a background process that runs to update the local operating system&nbsp;when the computer Group Policy is updated.&nbsp; <br /><strong>NOTE</strong> &ndash; If the Task Scheduler is disabled then the computer will not receive these certificates.&nbsp;</p>
<p>If you make changes to the certificate data stored in AD you can you can refresh this data on local computer by running GPUPDATE /FORCE /TARGET:COMPUTER.</p>
<p>The certificates can be found in the following registry key:</p>
<blockquote>
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\EnterpriseCertificates</p>
</blockquote>
<p>To view these certificates using CERTUTIL type the following:</p>
<blockquote>
<p>CERTUTIL -viewstore -enterprise &lt;store name&gt; where store name is MY, Root, CA, AuthRoot</p>
</blockquote>
<h3>AIA Container (Active Directory)</h3>
<p>Contains CA certificates that can be retrieved by clients using the authority information access (AIA) certificate extension to build a valid certificate chain and to retrieve any cross-certificates issued by the CA.</p>
<p>Certificates published to this container will be published into the Intermediate Certification Authorities store on domain joined computers.</p>
<p>To view the contents of the store use the Enterprise PKI snap-in (PKIVIEW.MSC).&nbsp; Certificates cannot be published to this store using the snap-in.</p>
<p>To publish certificates to this store using CERTUTIL type the following:</p>
<blockquote>
<p>CERTUTIL -f -dspublish &lt;cert file name&gt; SubCA</p>
</blockquote>
<h3>NTAuthCertificates Container (Active Directory)</h3>
<p>Contains all of the CA certificates in the current forest. Certificates are added automatically when a new CA is installed by a member of the Enterprise Admins group. Certificates can also be added manually by using the <strong>Manage AD Containers</strong> dialog box.</p>
<p>To publish certificates to this store using CERTUTIL type the following:</p>
<blockquote>
<p>CERTUTIL -f -dspublish &lt;cert file name&gt; NTAuthCA</p>
</blockquote>
<h3>Certificate Authorities Container (Active Directory)</h3>
<p>Contains the certificates for trusted root CAs in the forest. Root CA certificates are added automatically when a member of Enterprise Admins sets up an enterprise root CA or stand-alone root CA that is joined to the domain. Root CA certificates can also be added manually from the command prompt but not through the <strong>Manage AD Containers</strong> dialog box.</p>
<p>Certificates published to this container will be published to the Trusted Root Certification Store on domain joined computers.</p>
<p>To publish certificates to this container using CERTUTIL type the following:</p>
<blockquote>
<p>CERTUTIL -f -dspublish &lt;cert file name&gt; RootCA</p>
</blockquote>
<h2>Smart Card Logon</h2>
<p>During smart card logon the user&nbsp;proves their identity to a domain controller by means of a certificate,&nbsp;conversely&nbsp;the domain controller&nbsp;must prove its identity to the client with&nbsp;it's own&nbsp;certificate.&nbsp; Both sides of this mutual authentication must be successful before a successful logon can occur.&nbsp; When a certificate is used for authentication the following three&nbsp;tests are performed to make sure the certificates are valid:</p>
<ul>
<li>The certificate is within its validation period.&nbsp; The certificate falls within the&nbsp;issued and expired dates on the certificate.</li>
<li>The certificate must chain to a trusted root certificate.&nbsp; The computer validating the certificate must trust the root certificate it chains to.</li>
<li>The certificate has not been revoked.&nbsp; The computer validating the certificate must be able to confirm the certificate has not been revoked.&nbsp; The computer must be able to retrieve a copy of the certificate revocation list (CRL) from the certificate authority that issued the certificate or use some other method for validation like OCSP.</li>
</ul>
<p>If any one of these checks fails, on either side of the mutual authentication, then logon will fail.</p>
<p>In order to use smart cards for logon you need to have a few things in place:</p>
<ul>
<li>Identity certificates for all domain controllers that were issued by a trusted source.</li>
<li>Identity certificates for each user issued by a trusted source.</li>
<li>Certificates from each of the issuing certificate authorities (Issuing CA in diagram below) that the identity certificates above were generated on.</li>
<li>All certificates need to be placed in the correct certificate stores.</li>
<li>All certificates used must be trusted.</li>
</ul>
<p>Most of the organizations I have worked with to implement smart card logon use certificates from a third-party certificate authority outside their organization.&nbsp; To enable smart card logon you need to publish these external certificates into the appropriate certificate stores.&nbsp; The first step is to get your computers and users to &ldquo;trust&rdquo; the certificates from the third-party.&nbsp; This is done by taking the third-party root certificate, the certificate from the top of the external third-party hierarchy (offline Root CA in diagram below), and publishing to the&nbsp;Trusted Root Certification Authorities store.&nbsp;</p>
<p><img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_technet/askds/WindowsLiveWriter/DesigningandImplementingaPKIPartIDesigna_884F/image_4.png" original-url="http://blogs.technet.com/blogfiles/askds/WindowsLiveWriter/DesigningandImplementingaPKIPartIDesigna_884F/image_4.png" alt="" /></p>
<p>This can be accomplished in two ways.&nbsp; You can configure a Group Policy to publish the new root certificate to the Trusted Root Certification Authorities store on all computers or you can publish it to Active Directory using CERTUTIL or the Enterprise PKI snap-in.</p>
<p>To use the Enterprise PKI snap-in right-click on &ldquo;Enterprise PKI&rdquo; and select Manage AD Containers. Select &ldquo;Certificate Authorities Container&rdquo; tab and click the Add button and navigate to the certificate file&nbsp;you want to add.</p>
<blockquote>
<p><strong>NOTE</strong> &ndash; If you have an internal PKI infrastructure the snap-in will load quickly.&nbsp; If you do not it will be very slow because it is trying to contact your internal (non-existent) PKI.&nbsp; Be patient.</p>
<p align="center"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/6153.image_7D722DCF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/6153.image_5F00_7D722DCF.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/7077.image_thumb_788F7A13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/7077.image_5F00_thumb_5F00_788F7A13.png" alt="image" width="238" height="244" border="0" /></a></p>
</blockquote>
<p>To use CERTUTIL to publish the certificate to the Certificate Authorities container type the following command:</p>
<blockquote>
<p>CERTUTIL -f -dspublish &lt;cert file name&gt; RootCA</p>
</blockquote>
<p>To use Group Policy to publish the certificates follow the instructions in the following article:</p>
<blockquote>
<p>Use Policy to Distribute Certificates <br /><a href="http://technet.microsoft.com/en-us/library/cc772491.aspx">http://technet.microsoft.com/en-us/library/cc772491.aspx</a></p>
</blockquote>
<p>The identity certificates used by the domain controllers and smart cards are issued from one or more Issuing CAs.&nbsp; Next you need to place the certificate(s) from each of the Issuing CAs in the appropriate stores.&nbsp; You need to publish the certificates from each of the issuing CAs into the NTAuthCertificates store.&nbsp; This is can be accomplished by using CERTUTIL or the Enterprise PKI mmc snap-in.</p>
<p>To use the Enterprise PKI snap-in right-click on &ldquo;Enterprise PKI&rdquo; and select Manage AD Containers. Select &ldquo;NTAuthCertificates&rdquo; tab and click the Add button and navigate to the certificate you want to add.</p>
<p>To use CERTUTIL type the following command:</p>
<blockquote>
<p>CERTUTIL -f -dspublish &lt;cert file name&gt; NTAuthCA</p>
</blockquote>
<p>The final step is to publish the certificates from each of the Issuing CAs into the Intermediate Certificate Authorities store on each computer.&nbsp; This can be accomplished using Group Policy or publishing the certificates into Active Directory using CERTUTIL or the Enterprise PKI snap-in.</p>
<p>To use the Enterprise PKI snap-in right-click on &ldquo;Enterprise PKI&rdquo; and select Manage AD Containers. Select &ldquo;AIA Container&rdquo; tab and click the Add button and navigate to the certificate you want to add.</p>
<p>To use CERTUTIL type the following command:</p>
<blockquote>
<p>CERTUTIL -f -dspublish &lt;cert file name&gt; SubCA</p>
</blockquote>
<h2>Troubleshooting Duplicate Certificates in the Certificate Stores</h2>
<p>In some case you will see two copies of the same certificate in a store.&nbsp; This can happen when you publish the certificate using two different methods.&nbsp; The screenshot below demonstrates this (click graphic for larger view).</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/7536.image_70B8D14A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/7536.image_5F00_70B8D14A.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/7242.image_thumb_3906171A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/7242.image_5F00_thumb_5F00_3906171A.png" alt="image" width="607" height="303" border="0" /></a></p>
<p>In order to find out why this is occurring we need to look at the physical stores.&nbsp; To configure the snap-in to show the physical stores do the following:</p>
<ol>
<li>Right-click the Certificates Node &gt; View &gt; Options</li>
<li>Check the Physical certificate stores box <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/4861.image_68C3BF99.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/4861.image_5F00_68C3BF99.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/1738.image_thumb_44323215.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/1738.image_5F00_thumb_5F00_44323215.png" alt="image" width="244" height="191" border="0" /></a></li>
</ol>
<p>As you can see in the two screen captures below we are publishing the CORP NAP CA 2 certificate in the Group Policy physical Store as well as the Enterprise physical store.&nbsp; When we view the certificates in the logical view (previous screen capture) we see two copies of the certificate because we have two copies stored on the computer in two different stores.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/6557.image_466EBAD1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/6557.image_5F00_466EBAD1.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0121.image_thumb_411FD420.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0121.image_5F00_thumb_5F00_411FD420.png" alt="image" width="610" height="304" border="0" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/4278.image_10F8895D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/4278.image_5F00_10F8895D.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/1651.image_thumb_209B251F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/1651.image_5F00_thumb_5F00_209B251F.png" alt="image" width="622" height="310" border="0" /></a></p>
<h2>Reference</h2>
<p><strong>How to import third-party certification authority (CA) certificates into the Enterprise NTAuth store <br /></strong><a href="http://support.microsoft.com/kb/295663">http://support.microsoft.com/kb/295663</a></p>
<p><strong>Guidelines for enabling smart card logon with third-party certification authorities <br /></strong><a href="http://support.microsoft.com/kb/281245">http://support.microsoft.com/kb/281245</a></p>
<p><strong>Designing and Implementing a PKI: Part I Design and Planning <br /></strong><a href="http://blogs.technet.com/b/askds/archive/2009/09/01/designing-and-implementing-a-pki-part-i-design-and-planning.aspx">http://blogs.technet.com/b/askds/archive/2009/09/01/designing-and-implementing-a-pki-part-i-design-and-planning.aspx</a></p>
<p><strong>Use Policy to Distribute Certificates</strong> <br /><a href="http://technet.microsoft.com/en-us/library/cc772491.aspx">http://technet.microsoft.com/en-us/library/cc772491.aspx</a></p>
<p><strong>Relationship of the Configuration Container and Certificate Store <br /></strong><a href="http://technet.microsoft.com/en-us/library/cc758636(v=WS.10).aspx">http://technet.microsoft.com/en-us/library/cc758636(v=WS.10).aspx</a></p>
<p><strong>Managing Active Directory Containers with Enterprise PKI <br /></strong><a href="http://technet.microsoft.com/en-us/library/cc754126.aspx">http://technet.microsoft.com/en-us/library/cc754126.aspx</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How to Determine Which DNS Server(s) Have Scavenging Enabled Using PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/muaddib/how-to-determine-which-dns-servers-have-scavenging-enabled-using-powershell</link>
      <pubDate>Sat, 03 Aug 2013 12:07:00 GMT</pubDate>
      <dc:creator><![CDATA[DCBaker]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/muaddib/2013/08/03/how-to-determine-which-dns-servers-have-scavenging-enabled-using-powershell/</guid>
      <description><![CDATA[One of my duties as a Microsoft Premier Field Engineer (PFE) is to make sure the products a customer...]]></description>
      <content:encoded><![CDATA[<p>One of my duties as a Microsoft Premier Field Engineer (PFE) is to make sure the products a customer is currently using are configured properly and the customer is getting all the functionality the product provides.&nbsp; Whenever I&rsquo;m working with customers on any DNS issue I always check to see if they are using DNS scavenging.&nbsp; DNS scavenging enables your DNS server to remove stale records periodically based on parameters you set.</p>
<p>Customers tend to fall into two groups when it comes to DNS scavenging.&nbsp; The first group has scavenging configured and it is working well.&nbsp; The second group turned on scavenging in the past, caused an outage, and have refused to try and use scavenging since then.&nbsp; When someone tells me they had a bad experience with scavenging in the past I know they probably just &ldquo;threw the switch&rdquo; without doing any of the prep work required to insure critical records do not get deleted.</p>
<p>There are plenty of DNS Scavenging articles out there (see below) so I won&rsquo;t repeat it here. The high-level steps required to enable scavenging are as follows:</p>
<ol>
<li>Disable scavenging on ALL DNS servers.</li>
<li>Enable scavenging on the DNS zones and monitor the time stamps on all records in the zones for a week or two to confirm DNS hosts are updating the time stamps on the A (host) records.&nbsp; Pay close attention to servers to make sure their records are being updated.</li>
<li>Configured the zone scavenging interval.</li>
<li>Backup your zone data just in case.</li>
<li>Enable scavenging on a single DNS server and monitor for desired results</li>
</ol>
<p>The remainder of this post will be about step 1 and how to find DNS server with scavenging enabled.&nbsp; If you only have a few domain controllers running DNS you can view the Properties for each DNS server as shown below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/7776.image_39ABFC57.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/7776.image_5F00_39ABFC57.png"><img style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/72/13/metablogapi/0842.image_thumb_06DBF5E3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-72-13-metablogapi/0842.image_5F00_thumb_5F00_06DBF5E3.png" alt="image" width="249" height="291" border="0" /></a></p>
<p>&nbsp;</p>
<p>If you have dozens or hundreds of domain controllers then you need an easier way.&nbsp; The PowerShell script shown below will dump the DNS server name and scavenging settings for each DNS server in your domain.&nbsp; If you see a scavenging interval greater than zero you know scavenging is enabled on the server.</p>
<p>#---------------BEGIN SCRIPT CODE------------------ <br /> #################################################### <br /> # DATE: June 13, 2013&nbsp;&nbsp; <br /> # AUTHOR:&nbsp; Don Baker <br /> # SCRIPT:&nbsp; GET-DNSScavengingData.ps1 <br /> # PURPOSE: Find DNS server(s) with scavenging enabled <br /> #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> # <br /> # REVISON: <br /> #################################################### <br />cls <br /> #get a list of domain controllers in domain (replace Contoso with your domain)<br /> $DCs=(GET-ADDOMAIN -Identity Contoso).ReplicadirectoryServers</p>
<p>#loop through list of DCs and dump lines with "scavenging" in them <br />foreach ($dc in $DCs) <br /> { <br />&nbsp;&nbsp;&nbsp; $output = dnscmd $DC /info <br />&nbsp;&nbsp;&nbsp; #Write-host $output |fl <br />&nbsp;&nbsp;&nbsp; $string =$output |Select-string "Scavenging" <br />&nbsp;&nbsp;&nbsp; Write-host $DC <br />&nbsp;&nbsp;&nbsp; Write-host $string <br />&nbsp;&nbsp;&nbsp; Write-host "" <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> } <br /> #-----------------END SCRIPT CODE------------------</p>
<p>&nbsp;</p>
<p><strong>Sample Output</strong></p>
<p>As you can see below server DC1 has scavenging enabled and set to 7 days (168 hours) and the other server has it disabled.</p>
<p>&nbsp;</p>
<p>DC1.AD.CONTOSO.COM <br />&nbsp;&nbsp;&nbsp; ScavengingInterval&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 168</p>
<p>DC2CORE.AD.CONTOSO.COM <br />&nbsp;&nbsp;&nbsp; ScavengingInterval&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Resources</strong></p>
<p>Don't be afraid of DNS Scavenging. Just be patient <br /><a href="http://blogs.technet.com/b/networking/archive/2008/03/19/don-t-be-afraid-of-dns-scavenging-just-be-patient.aspx">http://blogs.technet.com/b/networking/archive/2008/03/19/don-t-be-afraid-of-dns-scavenging-just-be-patient.aspx</a>&nbsp; <br />&nbsp; <br /> Understanding Aging and Scavenging <br /><a href="http://technet.microsoft.com/en-us/library/cc771677(v=WS.10).aspx">http://technet.microsoft.com/en-us/library/cc771677(v=WS.10).aspx</a> <br />&nbsp; <br /> Enable Aging and Scavenging for DNS <br /><a href="http://technet.microsoft.com/en-us/library/cc771362(v=WS.10).aspx">http://technet.microsoft.com/en-us/library/cc771362(v=WS.10).aspx</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>