<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Goatee PFE</title><subtitle type="html">Blog of Microsoft Premier Field Engineer Ashley McGlone featuring PowerShell scripts for Active Directory.</subtitle><id>http://blogs.technet.com/b/ashleymcglone/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/" /><link rel="self" type="application/atom+xml" href="http://blogs.technet.com/b/ashleymcglone/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2012-09-15T01:00:00Z</updated><entry><title>Touch-Free PowerShell DCPROMO in Windows Server 2012</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2013/04/18/touch-free-powershell-dcpromo-in-windows-server-2012.aspx" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2013/04/18/touch-free-powershell-dcpromo-in-windows-server-2012.aspx</id><published>2013-04-18T12:00:00Z</published><updated>2013-04-18T12:00:00Z</updated><content type="html">&lt;h2&gt;DCPROMO Keeping You Up At Night?&lt;/h2&gt;
&lt;p&gt;Do you schedule DCPROMO activities for the weekend?&amp;nbsp; After hours?&amp;nbsp; Middle of the night?&amp;nbsp; I remember those days.&amp;nbsp; Often it was hard to get in the right frame of mind to think through all of the exact procedural steps during those late night change controls.&amp;nbsp; It was always good to have a thorough implementation plan.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s post will show you how to easily promote and demote a Windows Server 2012 domain controller remotely with a script.&amp;nbsp; You don&amp;rsquo;t even need to logon to the target server.&lt;/p&gt;
&lt;h2&gt;PowerShell DCPROMO in Windows Server 2012&lt;/h2&gt;
&lt;p&gt;In Windows Server 2012 &lt;strong&gt;DCPROMO&lt;/strong&gt; is gone.&amp;nbsp; The replacement is the &lt;strong&gt;ADDSDeployment&lt;/strong&gt; module, and it is packed full of PowerShell goodness.&amp;nbsp; Another key fact is that remoting is enabled by default in Windows Server 2012.&amp;nbsp; See the potential here?&amp;nbsp; Now that we&amp;rsquo;re in PowerShell land we can use remoting to promote a DC without logging on.&amp;nbsp; The new Server Manager GUI uses this same technique.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre style="margin: 10px; border: 10px solid #012456; color: #ffffff; font-family: monospace; background-color: #012456;"&gt;PS C:\&amp;gt; Get-Command -Module ADDSDeployment | ft Name

Name
----
Add-ADDSReadOnlyDomainControllerAccount
Install-ADDSDomain
Install-ADDSDomainController
Install-ADDSForest
Test-ADDSDomainControllerInstallation
Test-ADDSDomainControllerUninstallation
Test-ADDSDomainInstallation
Test-ADDSForestInstallation
Test-ADDSReadOnlyDomainControllerAccountCreation
Uninstall-ADDSDomainController
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Change control.&amp;nbsp; Can&amp;rsquo;t live with it.&amp;nbsp; Can&amp;rsquo;t live without it.&lt;/h2&gt;
&lt;p&gt;Scripting a change control is handy for several reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If your shop has a separate implementation team, then you know they should execute it precisely.&lt;/li&gt;
&lt;li&gt;You can test it in a lab, and then do it the same way in production.&lt;/li&gt;
&lt;li&gt;You know exactly what changed.&lt;/li&gt;
&lt;li&gt;You don&amp;rsquo;t have to worry about missing a step at 3AM.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Generally change controls have three plans:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implementation&lt;/li&gt;
&lt;li&gt;Validation&lt;/li&gt;
&lt;li&gt;Back-Out&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You have all three of these scripts for DCPROMO in today&amp;rsquo;s post.&amp;nbsp; Read through the scripts and the comments to see how easy it can be.&lt;/p&gt;
&lt;h2&gt;Script Overview&lt;/h2&gt;
&lt;p&gt;The DCPROMO implementation script hinges on three key cmdlets:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install-WindowsFeature&lt;/li&gt;
&lt;li&gt;Invoke-Command&lt;/li&gt;
&lt;li&gt;Install-ADDSDomainController&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;First, we install the role for Active Directory Domain Services using the &lt;strong&gt;ComputerName&lt;/strong&gt; parameter.&amp;nbsp; Next we use &lt;strong&gt;Invoke-Command&lt;/strong&gt; to remotely execute the DCPROMO with &lt;strong&gt;Install-ADDSDomainController&lt;/strong&gt;.&amp;nbsp; &lt;span style="background-color: #ffff00;"&gt;Notice the comments in the code for Invoke-Command.&amp;nbsp; It is really important to understand the &lt;strong&gt;$using&lt;/strong&gt; variable prefix.&amp;nbsp; This little item tripped me up for several hours until a peer reminded me about it.&amp;nbsp; See &lt;/span&gt;&lt;a title="about_Remote_Variables" href="http://technet.microsoft.com/en-us/library/jj149005.aspx" target="_blank"&gt;&lt;span style="background-color: #ffff00;"&gt;about_Remote_Variables&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: #ffff00;"&gt; for the full explanation.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The validation script is short and sweet.&amp;nbsp; It checks for the new AD domain controller object, key services, and the SYSVOL share.&amp;nbsp; Obviously there are many other checks you could add.&amp;nbsp; See the link at the bottom of this post for a great DC validation checklist.&lt;/p&gt;
&lt;p&gt;Finally, the back-out script is much like the implementation script, except it calls the &lt;em&gt;uninstall&lt;/em&gt; cmdlets in reverse order.&lt;/p&gt;
&lt;h2&gt;Implementation&lt;/h2&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Prompt for credentials to reuse throughout the script&lt;/span&gt;            
&lt;span style="color: #ff4500;"&gt;$cred&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Get-Credential&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Cohovineyard\Administrator&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Echo the date for reference in the console output&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-Date&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Query the current list of domain controllers before the new one&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-ADDomainController&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Filter&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;*&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
    &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Site&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;IPv4Address&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AutoSize&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Import the module containing Get-WindowsFeature&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Import-Module&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;ServerManager&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# List the currently installed features on the remote server&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-WindowsFeature&lt;/span&gt; &lt;span style="color: #000080;"&gt;-ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;             
    &lt;span style="color: #0000ff;"&gt;Where-Object&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Installed&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Install the role for AD-Domain-Services&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Install-WindowsFeature&lt;/span&gt; &lt;span style="color: #000080;"&gt;&amp;ndash;Name&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;AD-Domain-Services&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;&amp;ndash;ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;-IncludeManagementTools&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# List the currently installed features on the remote server&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Notice AD-Domain-Services is now in the list&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-WindowsFeature&lt;/span&gt; &lt;span style="color: #000080;"&gt;-ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;             
    &lt;span style="color: #0000ff;"&gt;Where-Object&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Installed&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Promote a new domain controller in the existing domain&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Adjust the parameters to meet your own needs&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Notice we're going to handle the reboot ourselves&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;##### BIG THING TO NOTICE #####&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Notice that the -Credential parameter variable is prefaced with "$using:".&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# This is a PS v3 feature, and it is required when passing variables&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# into a remote session. Invoke-Command is based on PowerShell remoting.&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Any other parameters that you turn into variables will need "$using:".&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Invoke-Command&lt;/span&gt; &lt;span style="color: #000080;"&gt;&amp;ndash;ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000080;"&gt;&amp;ndash;ScriptBlock&lt;/span&gt; &lt;span style="color: #000000;"&gt;{&lt;/span&gt;            
            
    &lt;span style="color: #0000ff;"&gt;Import-Module&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;ADDSDeployment&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;            
            
    &lt;span style="color: #0000ff;"&gt;Install-ADDSDomainController&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-NoGlobalCatalog:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-CreateDnsDelegation:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-CriticalReplicationOnly:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-DatabasePath&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;"C:\Windows\NTDS"&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-DomainName&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;"CohoVineyard.com"&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-InstallDns:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$true&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-LogPath&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;"C:\Windows\NTDS"&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-NoRebootOnCompletion:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$true&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-ReplicationSourceDC&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;"CVDC1.CohoVineyard.com"&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-SiteName&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;"Ohio"&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-SysvolPath&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;"C:\Windows\SYSVOL"&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-Force:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$true&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-Credential&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;$using:cred&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-Confirm:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-SafeModeAdministratorPassword&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
            &lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;ConvertTo-SecureString&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;'P@ssw0rd'&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AsPlainText&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Force&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;            
&lt;span style="color: #000000;"&gt;}&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# We are going to manage the restart ourselves.&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Restart-Computer&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;-Wait&lt;/span&gt; &lt;span style="color: #000080;"&gt;-For&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;PowerShell&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Force&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Confirm:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Once fully restarted and promoted, query for a fresh list of DCs.&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Notice our new DC in the list.&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-ADDomainController&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Filter&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;*&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
    &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Site&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;IPv4Address&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AutoSize&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Echo the date and time for job completion.&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-Date&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h2&gt;Validation&lt;/h2&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #0000ff;"&gt;Import-Module&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;ActiveDirectory&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Query the current list of domain controllers&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-ADDomainController&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Filter&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;*&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
    &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Site&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;IPv4Address&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AutoSize&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Check random services common to DCs&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-Service&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;adws&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt;&lt;span style="color: #8a2be2;"&gt;kdc&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt;&lt;span style="color: #8a2be2;"&gt;netlogon&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt;&lt;span style="color: #8a2be2;"&gt;dns&lt;/span&gt; &lt;span style="color: #000080;"&gt;-ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvdc1&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Check for presence of SYSVOL&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Test-Path&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;\\cvdc1\SYSVOL&lt;/span&gt;            
&lt;/pre&gt;
&lt;h2&gt;Back-Out&lt;/h2&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Prompt for credentials to reuse throughout the script&lt;/span&gt;            
&lt;span style="color: #ff4500;"&gt;$cred&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Get-Credential&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Cohovineyard\Administrator&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Echo the date for reference in the console output&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-Date&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Query the current list of domain controllers before the removal&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-ADDomainController&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Filter&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;*&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
    &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Site&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;IPv4Address&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AutoSize&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Reset the error variable&lt;/span&gt;            
&lt;span style="color: #ff4500;"&gt;$error&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;.&lt;/span&gt;&lt;span style="color: #000000;"&gt;Clear&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Remove the domain controller in the existing domain&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;##### BIG THING TO NOTICE #####&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Notice that the -Credential parameter variable is prefaced with "$using:".&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# This is a PS v3 feature, and it is required when passing variables&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# into a remote session. Invoke-Command is based on PowerShell remoting.&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Any other parameters that you turn into variables will need "$using:".&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Invoke-Command&lt;/span&gt; &lt;span style="color: #000080;"&gt;&amp;ndash;ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000080;"&gt;&amp;ndash;ScriptBlock&lt;/span&gt; &lt;span style="color: #000000;"&gt;{&lt;/span&gt;            
            
    &lt;span style="color: #0000ff;"&gt;Uninstall-ADDSDomainController&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Confirm:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
       &lt;span style="color: #000080;"&gt;-LocalAdministratorPassword&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
            &lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;ConvertTo-SecureString&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;'P@ssw0rd'&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AsPlainText&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Force&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
       &lt;span style="color: #000080;"&gt;-DemoteOperationMasterRole:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$true&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
       &lt;span style="color: #000080;"&gt;-Credential&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;$using:cred&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
       &lt;span style="color: #000080;"&gt;-Force:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$true&lt;/span&gt;            
&lt;span style="color: #000000;"&gt;}&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Exit if the uninstall was unsuccessful&lt;/span&gt;            
&lt;span style="color: #00008b;"&gt;If&lt;/span&gt; &lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$error&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt; &lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;span style="color: #00008b;"&gt;break&lt;/span&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Give the server time to go down&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Start-Sleep&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Seconds&lt;/span&gt; &lt;span style="color: #800080;"&gt;5&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# The DC removal also removes the host A record in DNS.&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# This effectively disables any other remoting until the server reboots.&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# Therefore we tell the Uninstall to do the reboot by omitting the&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# switch -NoRebootOnCompletion, and then we loop until we can confirm&lt;/span&gt;            
&lt;span style="color: #006400;"&gt;# the server is reachable again and services are started.&lt;/span&gt;            
&lt;span style="color: #00008b;"&gt;Do&lt;/span&gt;    &lt;span style="color: #000000;"&gt;{&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Start-Sleep&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Seconds&lt;/span&gt; &lt;span style="color: #800080;"&gt;1&lt;/span&gt; &lt;span style="color: #000000;"&gt;}&lt;/span&gt;            
&lt;span style="color: #00008b;"&gt;Until&lt;/span&gt; &lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;Get-CIMInstance&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Win32_Bios&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
        &lt;span style="color: #000080;"&gt;-ErrorAction&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;SilentlyContinue&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Uninstall the AD DS &amp;amp; DNS roles&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Import-Module&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;ServerManager&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Uninstall-WindowsFeature&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;&amp;ndash;Name&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;AD-Domain-Services&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;DNS&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;RSAT-AD-Tools&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;RSAT-AD-PowerShell&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;&amp;ndash;ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;-IncludeManagementTools&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;-Confirm:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Restart the server and wait for services to come back up&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Restart-Computer&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #000000;"&gt;` &lt;/span&gt;
    &lt;span style="color: #000080;"&gt;-Wait&lt;/span&gt; &lt;span style="color: #000080;"&gt;-For&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;PowerShell&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Force&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Confirm:&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$false&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# View the roles to verify that AD-Domain-Services is really gone&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-WindowsFeature&lt;/span&gt; &lt;span style="color: #000080;"&gt;-ComputerName&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;cvmember1.cohovineyard.com&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;             
    &lt;span style="color: #0000ff;"&gt;Where-Object&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Installed&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Query for a fresh list of DCs. Confirm it is gone from the list.&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-ADDomainController&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Filter&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;*&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
    &lt;span style="color: #0000ff;"&gt;Format-Table&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Name&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Site&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;IPv4Address&lt;/span&gt; &lt;span style="color: #000080;"&gt;-AutoSize&lt;/span&gt;            
            
&lt;/pre&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400;"&gt;# Echo the date and time for job completion.&lt;/span&gt;            
&lt;span style="color: #0000ff;"&gt;Get-Date&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h2&gt;Script Notes&lt;/h2&gt;
&lt;p&gt;Like other demo scripts I&amp;rsquo;ve posted there is plenty of room for improvement.&amp;nbsp; Consider these key opportunities regarding the scripts above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The functionality in these scripts requires Windows 8 with &lt;a title="RSAT" href="http://www.microsoft.com/en-us/download/details.aspx?id=28972" target="_blank"&gt;RSAT&lt;/a&gt; or Windows Server 2012.&lt;/li&gt;
&lt;li&gt;Be sure to adjust the values for the parameters on the cmdlets that do all of the heavy lifting.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Read-Host&lt;/strong&gt; to prompt for the password instead of embedding it in plain text.&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;Start-Transcript&lt;/strong&gt; and &lt;strong&gt;Stop-Transcript&lt;/strong&gt; for logging your activity.&lt;/li&gt;
&lt;li&gt;End the script with a &lt;strong&gt;Send-MailMessage&lt;/strong&gt; that attaches the transcript in an email to you.&lt;/li&gt;
&lt;li&gt;You can swap out all of the hard-coded computer names with variables to make it more reusable.&lt;/li&gt;
&lt;li&gt;You could promote the DC &lt;a title="from your smartphone" href="http://blogs.technet.com/b/ashleymcglone/archive/2013/02/05/how-to-do-powershell-on-your-phone.aspx" target="_blank"&gt;from your smartphone&lt;/a&gt; with one hand tied behind your back.&lt;/li&gt;
&lt;li&gt;You could schedule the script to run at 3AM while you are nestled in bed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="background-color: #ffff00;"&gt;Download the full code from the &lt;a title="TechNet Script Gallery" href="http://gallery.technet.microsoft.com/Touch-Free-PowerShell-f4a6ad2b" target="_blank"&gt;&lt;span style="background-color: #ffff00;"&gt;TechNet Script Gallery&lt;/span&gt;&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;Related Articles&lt;/h2&gt;
&lt;p&gt;See this TechNet article for the complete textbook explanation of promoting a new DC in Windows Server 2012: &lt;br /&gt;&lt;a title="Install a Replica Windows Server 2012 Domain Controller in an Existing Domain (Level 200)" href="http://technet.microsoft.com/en-us/library/jj574134.aspx" target="_blank"&gt;Install a Replica Windows Server 2012 Domain Controller in an Existing Domain (Level 200)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My buddies over at the AskPFEPlat blog have a great checklist for introducing and removing DCs.&amp;nbsp; Use this list to build your own robust validation script: &lt;br /&gt;&lt;a title="First, Do No Harm" href="http://blogs.technet.com/b/askpfeplat/archive/2012/08/06/first-do-no-harm.aspx?Redirected=true" target="_blank"&gt;First, Do No Harm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another buddy on AskPFEPlat has written a great article for your first 2012 DC:&lt;br /&gt;&lt;a title="Introducing the first Windows Server 2012 Domain Controller (Part 1 of 2)" href="http://blogs.technet.com/b/askpfeplat/archive/2012/09/03/introducing-the-first-windows-server-2012-domain-controller.aspx" target="_blank"&gt;Introducing the first Windows Server 2012 Domain Controller (Part 1 of 2)&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3567421" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="Invoke-Command" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Invoke_2D00_Command/" /><category term="Remoting" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Remoting/" /><category term="v3" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/v3/" /><category term="Windows Server 2012" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+Server+2012/" /><category term="Windows 8" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+8/" /><category term="Install-ADDSDomainController" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Install_2D00_ADDSDomainController/" /><category term="Install-WindowsFeature" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Install_2D00_WindowsFeature/" /></entry><entry><title>Active Directory OU Permissions Report: Free PowerShell Script Download</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2013/03/25/active-directory-ou-permissions-report-free-powershell-script-download.aspx" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2013/03/25/active-directory-ou-permissions-report-free-powershell-script-download.aspx</id><published>2013-03-25T15:55:00Z</published><updated>2013-03-25T15:55:00Z</updated><content type="html">&lt;h3&gt;Who owns your OUs?&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3250.MP9003095431_5F00_57E72CEF.jpg"&gt;&lt;img style="float: right; display: inline; background-image: none;" title="MP900309543[1]" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/5153.MP9003095431_5F00_thumb_5F00_1AE2FB5D.jpg" alt="MP900309543[1]" width="145" height="98" align="right" border="0" /&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Have you ever lost your keys? It is a scary feeling. Someone out there could have keys to your house and your car. Your personal safety could be at risk. The same is true in Active Directory.&amp;nbsp; Do you know who has the keys to all of your accounts?&lt;/p&gt;
&lt;h3&gt;The Problem&lt;/h3&gt;
&lt;p&gt;In &lt;strong&gt;Active Directory&lt;/strong&gt; we need to know who has the keys to our &lt;strong&gt;organizational units&lt;/strong&gt; (OUs), the place where our users and computers live. Over the years OUs have grown to meet needs. Different teams may have been delegated access for managing users, groups, and computers. Then you come along as the new administrator. &lt;span style="background-color: #ffff00;"&gt;You probably have no idea where &lt;strong&gt;permissions&lt;/strong&gt; have been granted to your OUs. And the scary thing is&amp;hellip; neither does anyone else.&lt;/span&gt;&lt;span&gt;&amp;nbsp; I know, because I&amp;rsquo;ve been there.&amp;nbsp; I hear the same thing from our customers.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Out-of-the-box we do not have a specific tool to report all of the OU permissions. You have to click each OU and view the security tab one-by-one, and we all know that is entirely impractical.&amp;nbsp; Today&amp;rsquo;s post contains a script download to generate a report of this vital information.&lt;/p&gt;
&lt;h3&gt;OU Permissions&lt;/h3&gt;
&lt;p&gt;OU permissions are multi-faceted. In other words&amp;hellip; it&amp;rsquo;s complicated. They have a number of properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Principal&lt;/li&gt;
&lt;li&gt;Allow/Deny&lt;/li&gt;
&lt;li&gt;Scope&lt;/li&gt;
&lt;li&gt;Applies To&lt;/li&gt;
&lt;li&gt;Permissions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;rsquo;ll see the following dialog when you add a permission. This is enough to explain the complexity of the group access notation:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/8311.clip_5F00_image002_5F00_010EC52E.jpg"&gt;&lt;img style="display: inline; background-image: none;" title="clip_image002" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/8838.clip_5F00_image002_5F00_thumb_5F00_14BBAEC2.jpg" alt="clip_image002" width="599" height="388" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now look how many &lt;strong&gt;Applies to:&lt;/strong&gt; options there are.&amp;nbsp; Notice that this box scrolls a long way.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/2018.clip_5F00_image003_5F00_137715E3.png"&gt;&lt;img style="display: inline; background-image: none;" title="clip_image003" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/1616.clip_5F00_image003_5F00_thumb_5F00_5D25EDD3.png" alt="clip_image003" width="315" height="428" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What we need is a report that lists the contents of the &lt;strong&gt;Advanced&lt;/strong&gt; permissions GUI like this for every OU:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/7028.clip_5F00_image005_5F00_34A70BBF.jpg"&gt;&lt;img style="display: inline; background-image: none;" title="clip_image005" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3252.clip_5F00_image005_5F00_thumb_5F00_5A308920.jpg" alt="clip_image005" width="514" height="346" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The matrix of potential permission configurations is mind-blogging.&lt;/p&gt;
&lt;h3&gt;The Solution: PowerShell&lt;/h3&gt;
&lt;p&gt;I had wondered if a report like this could be as simple as:&lt;/p&gt;
&lt;pre style="background-color: #f0f0f0;"&gt;Import-Module ActiveDirectory
cd AD:
dir &amp;ndash;recurse &amp;ndash;directory | Get-ACL&lt;/pre&gt;
&lt;p&gt;Of course what works in our imaginations is rarely as simple in real life.&amp;nbsp; No, that code would not do it.&amp;nbsp; However, the concept is the same:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get a list of all OUs&lt;/li&gt;
&lt;li&gt;Loop through the OUs to retrieve their permissions&lt;/li&gt;
&lt;li&gt;Export all data to a CSV file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Our good friend &lt;strong&gt;Get-ACL&lt;/strong&gt; reports on more than file system permissions.&amp;nbsp; We can use this same cmdlet to query OU permissions as well.&amp;nbsp; Notice that we preface the OU distinguished name with &lt;span style="background-color: #ffff00;"&gt;AD:\&lt;/span&gt;.&amp;nbsp; Any time you query permissions with Get-ACL you need to expand the &lt;strong&gt;Access&lt;/strong&gt; property to see the list of permission entries (ACEs):&lt;/p&gt;
&lt;pre style="background-color: #f0f0f0;"&gt;Get-Acl -Path "&lt;span style="background-color: #ffff00;"&gt;AD:\&lt;/span&gt;OU=Domain Controllers,DC=wingtiptoys,DC=local" |
  Select-Object -ExpandProperty Access
&lt;/pre&gt;
&lt;p&gt;Here is an example of an &lt;strong&gt;ActiveDirectoryAccessRule&lt;/strong&gt; object that is returned for an OU:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3364.image_5F00_58EBF041.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/8103.image_5F00_thumb_5F00_58138A57.png" alt="image" width="604" height="114" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We get an entry like this for every permission assigned to the OU.&amp;nbsp; My first instinct was to simply dump a list of these to CSV and be done with it.&amp;nbsp; But then I noticed the &lt;strong&gt;ObjectType &lt;/strong&gt;and &lt;strong&gt;InheritedObjectType&lt;/strong&gt; properties.&amp;nbsp; Hmmmm.&amp;nbsp; These are ugly GUIDs&amp;hellip; not what we need for the report.&amp;nbsp; We need to translate these to the names of the objects that receive the permissions.&amp;nbsp; These names are what we see in that long drop-down list in the screenshot above.&lt;/p&gt;
&lt;p&gt;To make a long story short I stayed up until 3AM researching this and traced it all down in the &lt;strong&gt;Active Directory Technical Specifications (MS-ADTS)&lt;/strong&gt; here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="3.1.1.2.3 Attributes" href="http://msdn.microsoft.com/en-us/library/cc223202.aspx" target="_blank"&gt;3.1.1.2.3 Attributes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="3.1.1.2.3.3 Property Set" href="http://msdn.microsoft.com/en-us/library/cc223204.aspx" target="_blank"&gt;3.1.1.2.3.3 Property Set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="5.1.3.2.1 Control Access Rights" href="http://msdn.microsoft.com/en-us/library/cc223512.aspx" target="_blank"&gt;5.1.3.2.1 Control Access Rights&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You are welcome to read these pages for yourself to understand the relationships.&amp;nbsp; Essentially these GUID values are stored on attributes of selected objects in the schema and configuration partitions of the AD database.&amp;nbsp; You can query these to build a list of names that will make the report readable.&amp;nbsp; So that&amp;rsquo;s what I did and put them into a hash table for quick look-ups when we generate the report.&lt;/p&gt;
&lt;h3&gt;The Big Finish&lt;/h3&gt;
&lt;p&gt;When we script it all out we get a report that looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/5238.image_5F00_5662BE83.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/5287.image_5F00_thumb_5F00_7B13D5FA.png" alt="image" width="594" height="191" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Obviously there are too many columns to read in the screenshot, but it is quite thorough.&amp;nbsp; Now you can use &lt;a title="filters" href="http://www.trainsignal.com/blog/beginner-excel-2010-data-filters" target="_blank"&gt;filters&lt;/a&gt; and &lt;a title="pivot tables" href="http://office.microsoft.com/en-us/excel-help/create-or-delete-a-pivottable-or-pivotchart-report-HP010342375.aspx?CTT=3" target="_blank"&gt;pivot tables&lt;/a&gt; in Excel to analyze the data and produce reports showing exactly which OUs have delegated permissions, what kind of permissions, and who has them.&amp;nbsp; Likewise you can pivot the report by group to see a list of all OUs that a group can control.&amp;nbsp; You may want to filter the output by the &lt;strong&gt;IsInherited&lt;/strong&gt; property.&amp;nbsp; By filtering for &lt;strong&gt;FALSE&lt;/strong&gt; you will find everywhere that permissions are explicitly delegated in the OU tree.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;&lt;span style="background-color: #ffff00;"&gt;&lt;span style="background-color: #ffff00;"&gt;I would advise all Active Directory shops to run and review this report on a quarterly basis to make sure there are no surprise administrators lurking in your domain.&lt;/span&gt;&lt;/span&gt; The report can be quite large for any size organization.&amp;nbsp; Perhaps this would be a good report to feed to the Information Security team, if you have one.&amp;nbsp; Now you know who holds the keys.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Download the full script from the &lt;a title="TechNet Script Gallery" href="http://gallery.technet.microsoft.com/Active-Directory-OU-1d09f989" target="_blank"&gt;TechNet Script Gallery&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3560561" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="Get-ACL" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Get_2D00_ACL/" /><category term="OU" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/OU/" /><category term="Organizational Unit" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Organizational+Unit/" /></entry><entry><title>How to do PowerShell on your phone</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2013/02/05/how-to-do-powershell-on-your-phone.aspx" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2013/02/05/how-to-do-powershell-on-your-phone.aspx</id><published>2013-02-05T16:05:00Z</published><updated>2013-02-05T16:05:00Z</updated><content type="html">&lt;p&gt;Even Spiderman would envy this web action. Today we're going to walk through setting up a &lt;strong&gt;portable PowerShell v3 Web Access demo&lt;/strong&gt;. Using this demo guide you can explore PowerShell from any web-capable device: your phone, your tablet, or your &lt;a title="Raspberry Pi" href="http://www.raspberrypi.org/" target="_blank"&gt;Raspberry Pi&lt;/a&gt;.&amp;nbsp; The links in this post will guide you to all of the key documentation to build your own PowerShell Web Access lab.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/7776.GoateePFE_2D00_PowerShell_2D00_Phone_2D00_Surface_2D00_Laptop_2D00_VM_2D00_Edit_5F00_3FF7C45E.jpg"&gt;&lt;img style="display: inline; background-image: none;" title="GoateePFE-PowerShell-Phone-Surface-Laptop-VM-Edit" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/6523.GoateePFE_2D00_PowerShell_2D00_Phone_2D00_Surface_2D00_Laptop_2D00_VM_2D00_Edit_5F00_thumb_5F00_448DCF18.jpg" alt="GoateePFE-PowerShell-Phone-Surface-Laptop-VM-Edit" width="543" height="402" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Thanks to my buddy &lt;/em&gt;&lt;a title="Bruce Adamczak" href="http://blogs.technet.com/b/bruce_adamczak/" target="_blank"&gt;&lt;em&gt;Bruce Adamczak&lt;/em&gt;&lt;/a&gt;&lt;em&gt; for the picture above.&amp;nbsp; Bruce snapped it while I was doing this demo for a customer in the field.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A couple weeks ago I was flying home from helping a customer get their Active directory healthy, and it dawned on me that I had everything I needed for a wow-factor PowerShell demo right there in my backpack. When I landed in Atlanta I put this demo together between flights. I was grinning ear-to-ear with my laptop, Surface, and Windows Phone sprawled out on one of those tiny airport waiting area seats. I know people thought I looked goofy&amp;hellip; dude with a goatee grinning at his laptop and tablet and phone all at once.&lt;/p&gt;
&lt;p&gt;One of my favorite Iron Man quotes is from the first movie when Obadiah Stane says, "Tony Stark was able to build this in a cave&amp;hellip; with a box of scraps!" In other words, this demo will only take a few pieces to get rolling.&amp;nbsp; And I&amp;rsquo;m not Tony Stark.&lt;/p&gt;
&lt;h3&gt;The Plan&lt;/h3&gt;
&lt;p&gt;The demo consists of a domain controller VM and an IIS VM running on my laptop, both on an internal network. The IIS VM has another virtual network connection configured for the external network with a static IP at the upper end of the same IP range issued from DHCP on the WiFi access point. My phone and tablet are getting DHCP from the same WiFi access point. Technically we could put the DC on the same external network, but using a separate internal network would be more like reality where the web server has a reverse proxy to access internal resources.&amp;nbsp; Here is a crude illustration:&amp;nbsp; (Hey, I&amp;rsquo;m an engineer, not an artist.)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3580.clip_5F00_image001_5F00_239A5C71.png"&gt;&lt;img style="display: inline; background-image: none;" title="clip_image001" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/2480.clip_5F00_image001_5F00_thumb_5F00_49FC3FBC.png" alt="clip_image001" width="548" height="220" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;The Parts&lt;/h3&gt;
&lt;p&gt;Here is all you need to get this going:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A wireless access point - I used my Verizon MiFi.&lt;/li&gt;
&lt;li&gt;A laptop running Windows 8 &lt;a title="Client HyperV" href="http://blogs.msdn.com/b/b8/archive/2011/09/07/bringing-hyper-v-to-windows-8.aspx" target="_blank"&gt;Client HyperV&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;A wifi tablet with a browser - I used my new Microsoft &lt;a title="Surface" href="http://surface.com/" target="_blank"&gt;Surface&lt;/a&gt; RT.&lt;/li&gt;
&lt;li&gt;A wifi smartphone with a browser - I used my Verizon &lt;a title="HTC 8X" href="http://www.htc.com/www/smartphones/htc-wp-8x/" target="_blank"&gt;HTC 8X&lt;/a&gt; Windows Phone 8.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Wireless&lt;/h3&gt;
&lt;p&gt;Any WiFi access point or router should do. Configure DHCP so that you have at least one extra address above the range.&amp;nbsp; This extra address will be statically assigned to your IIS server external virtual NIC.&amp;nbsp; I used the address 192.168.1.200.&lt;/p&gt;
&lt;h3&gt;Client HyperV&lt;/h3&gt;
&lt;p&gt;You&amp;rsquo;ll need a 64 bit install of Windows 8.&amp;nbsp; Most newer laptops have &lt;a title="SLAT (second layer address translation)" href="http://social.technet.microsoft.com/wiki/contents/articles/1401.hyper-v-list-of-slat-capable-cpus-for-hosts.aspx" target="_blank"&gt;SLAT (second layer address translation)&lt;/a&gt; built in to support Client HyperV. Install HyperV from Windows Features.&amp;nbsp; Use &lt;a title="this post" href="http://blogs.msdn.com/b/b8/archive/2011/09/07/bringing-hyper-v-to-windows-8.aspx" target="_blank"&gt;this post&lt;/a&gt; for setup instructions.&lt;/p&gt;
&lt;p&gt;Technically you would only need one VM for this demo: a Windows Server 2012 install running Directory Services and IIS. Obviously that would never be recommended in a production environment.&amp;nbsp; I have four VMs for more demo flexibility:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows Server 2012 Domain Controller&lt;/li&gt;
&lt;li&gt;Windows Server 2012 Member Server&lt;/li&gt;
&lt;li&gt;Windows Server 2012 IIS Server&lt;/li&gt;
&lt;li&gt;Windows 8 client&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can download evaluation installs here for your own free testing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="Windows Server 2012 evaluation" href="http://technet.microsoft.com/en-us/evalcenter/hh670538.aspx?ocid=&amp;amp;wt.mc_id=TEC_108_1_33" target="_blank"&gt;Windows Server 2012 evaluation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="Windows 8 Enterprise evaluation" href="http://technet.microsoft.com/en-US/evalcenter/hh699156.aspx" target="_blank"&gt;Windows 8 Enterprise evaluation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of the VMs are joined to the test domain on the DC.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/6281.Screenshot_2D00_12_5F00_2255C392.png"&gt;&lt;img style="display: inline; background-image: none;" title="Screenshot (12)" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/7356.Screenshot_2D00_12_5F00_thumb_5F00_0E5C30FC.png" alt="Screenshot (12)" width="590" height="295" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Networking&lt;/h3&gt;
&lt;p&gt;This is the tricky part. I'm not a HyperV expert, but I know enough to configure internal and external networks using the virtual switch (after I read the help). VMs on the internal network use the static addresses pictured in my crude illustration above.&amp;nbsp; Then I can use &lt;a title="Remote Desktop Connection Manager" href="http://www.microsoft.com/en-us/download/details.aspx?id=21101" target="_blank"&gt;Remote Desktop Connection Manager&lt;/a&gt; to RDP into each virtual server from the host laptop where I have a static IP configured on the internal bridge NIC.&amp;nbsp; The RDP part is optional but convenient.&amp;nbsp; Most folks will use the HyperV virtual machine connection to interact with the VMs.&lt;/p&gt;
&lt;p&gt;On the web server VM I configured two NICs: one internal and one external.&amp;nbsp; Inside the VM the internal NIC has the static 10.x.x.x address and the external NIC has the static 192.168.1.200 address.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/8726.image_5F00_13CAA1A0.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/4520.image_5F00_thumb_5F00_76E17CCA.png" alt="image" width="509" height="480" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Web Server&lt;/h3&gt;
&lt;p&gt;Once you have built your IIS VM you can use &lt;a title="this article" href="http://blogs.msdn.com/b/powershell/archive/2012/06/27/windows-powershell-web-access-basic-installation-guide.aspx" target="_blank"&gt;this article&lt;/a&gt; from the PowerShell team to step through the PowerShell Web Access setup. I was surprised that this only took five minutes in my lab. They did a good job building the setup cmdlets to automate all of the IIS configuration. Call the site "pswa".&amp;nbsp; Here is &lt;a title="another link" href="http://blogs.msdn.com/b/powershell/archive/2012/07/18/windows-powershell-web-access-install.aspx" target="_blank"&gt;another link&lt;/a&gt; for more setup options.&amp;nbsp; If you want the full textbook documentation it is on TechNet &lt;a title="here" href="http://technet.microsoft.com/en-us/library/hh831611.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Web Clients&lt;/h3&gt;
&lt;p&gt;Now create a favorite or shortcut from Internet Explorer on the Windows 8 client VM, on the tablet browser, and on the phone browser. The URL should look something like this: http&lt;span style="background-color: #ffff00;"&gt;s&lt;/span&gt;://192.168.1.200/pswa .&amp;nbsp; Any browser that supports &lt;a title="HTTPS, JavaScript, and cookies" href="http://technet.microsoft.com/en-us/library/hh831417.aspx" target="_blank"&gt;HTTPS, JavaScript, and cookies&lt;/a&gt; should work.&lt;/p&gt;
&lt;p&gt;PS &amp;ndash; I tried this on my &lt;a title="XBOX" href="http://support.xbox.com/en-US/apps/internet-explorer/internet-explorer-setup" target="_blank"&gt;XBOX&lt;/a&gt; with the new IE app.&amp;nbsp; However, it did not appear to work.&amp;nbsp; From what I understand the XBOX browser does not support JavaScript.&amp;nbsp; I could be wrong.&amp;nbsp; Let me know if you get this to work.&lt;/p&gt;
&lt;h3&gt;Bringing It All Together&lt;/h3&gt;
&lt;p&gt;Once you&amp;rsquo;ve walked through these links and ironed out the kinks you should have a working PowerShell Web Access lab.&amp;nbsp; When you hit the URL you&amp;rsquo;ll get a page that looks like this.&amp;nbsp; Note that I have filled in the credentials and target computer name.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/2548.image_5F00_2A3D4027.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/6747.image_5F00_thumb_5F00_308416B5.png" alt="image" width="415" height="338" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;By the way, you will likely get a security prompt in the browser that the web site&amp;rsquo;s certificate is invalid.&amp;nbsp; You can safely ignore that, because we&amp;rsquo;re just using a test certificate in the lab.&amp;nbsp; For Windows clients you may need to launch the browser as Administrator to bypass that warning.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;After clicking the &lt;strong&gt;Sign In&lt;/strong&gt; button you&amp;rsquo;ll get the PowerShell console.&amp;nbsp; As they say in the movies, &amp;ldquo;I&amp;rsquo;m in!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/2134.image_5F00_3AD53B15.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/0878.image_5F00_thumb_5F00_01522B1E.png" alt="image" width="444" height="85" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a title="this article" href="http://technet.microsoft.com/en-us/library/hh831417.aspx" target="_blank"&gt;this article&lt;/a&gt; for all of the tips on using the PowerShell Web Access console.&amp;nbsp; You&amp;rsquo;ve got to try this from your phone.&amp;nbsp; For example, most phone touch keyboards do not have a TAB key for doing TAB completion in the PowerShell console.&amp;nbsp; That&amp;rsquo;s why we put the little TAB icon on the toolbar at the bottom.&amp;nbsp; We also added up/down arrows for cycling through the command history.&lt;/p&gt;
&lt;p&gt;A PFE peer of mine, Rick Sheikh,&amp;nbsp;wrote a very &lt;a title="thorough post" href="http://blogs.technet.com/b/askpfeplat/archive/2012/09/17/want-remote-powershell-management-from-your-browser-see-how-powershell-web-access-in-windows-server-2012-may-help.aspx" target="_blank"&gt;thorough post&lt;/a&gt; recently on PowerShell Web Access.&amp;nbsp; I would encourage you to read it for all of the possible configuration and security options you can tweak.&lt;/p&gt;
&lt;h3&gt;Bring The Wow&lt;/h3&gt;
&lt;p&gt;Now what?&amp;nbsp; We&amp;rsquo;re in.&amp;nbsp; Any way to add some &amp;ldquo;wow&amp;rdquo; to this demo?&amp;nbsp; You bet.&lt;/p&gt;
&lt;p&gt;Go watch &lt;a title="this TechEd session" href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/WSV414" target="_blank"&gt;this TechEd session&lt;/a&gt; with &lt;a title="Travis" href="http://channel9.msdn.com/Events/Speakers/travis+jones" target="_blank"&gt;Travis&lt;/a&gt; and &lt;a title="Hemant" href="http://channel9.msdn.com/Events/Speakers/hemant+mahawar" target="_blank"&gt;Hemant&lt;/a&gt;.&amp;nbsp; Fast forward to the 52 minute mark where they discuss disconnected sessions and then transition to PowerShell Web Access.&amp;nbsp; I posted a copy of &lt;a title="these demo scripts" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/08/21/what-s-new-in-powershell-v3-demos-to-download.aspx" target="_blank"&gt;these demo scripts&lt;/a&gt; when I spoke at TechMentor last autumn.&amp;nbsp; (Thanks, Travis and Hemant!)&amp;nbsp; Download the scripts, watch the video demo, and see if you can recreate the part at the end where they &amp;ldquo;pull a rabbit out of the hat&amp;rdquo; in the web session.&amp;nbsp; That&amp;rsquo;s the wow, especially when you do it from your phone.&amp;nbsp; I saved the commands into a demo.ps1 script to run from the phone instead of typing it all during a live demo.&lt;/p&gt;
&lt;h3&gt;Presentation Setup&lt;/h3&gt;
&lt;p&gt;When I do this demo for an audience here are the steps I take to utilize the lab:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Boot up the Verizon MiFi and connect the devices.&amp;nbsp; I have already added the wireless network to my phone and Surface so that they connect right away.&lt;/li&gt;
&lt;li&gt;Boot up the VMs on my laptop.&lt;/li&gt;
&lt;li&gt;Create a shortcut on the phone and tablet pointing to the PowerShell Web Access page hosted on my laptop VM.&amp;nbsp; Test the page from each device to make sure it is working.&lt;/li&gt;
&lt;li&gt;Connect my laptop to the projector.&amp;nbsp; Plug in the Surface VGA dongle so that it is ready.&lt;/li&gt;
&lt;li&gt;Enable Presenter mode on the laptop and the Surface.&amp;nbsp; (Windows + X, Mobility Center, Presentation Settings)&lt;/li&gt;
&lt;li&gt;Do the PowerShell Web Access talk from the laptop.&amp;nbsp; Use the scripts linked above for the demos.&amp;nbsp; Start the disconnected job with the counting demo.&lt;/li&gt;
&lt;li&gt;Switch over to the Windows 8 client VM and demo PowerShell Web Access from a normal desktop browser but &lt;span style="text-decoration: underline;"&gt;don&amp;rsquo;t pull the results from the disconnected session yet&lt;/span&gt;.&amp;nbsp; Discuss convenience at work or at home.&lt;/li&gt;
&lt;li&gt;Disconnect the VGA cable from the laptop and plug it into the Surface VGA dongle.&lt;/li&gt;
&lt;li&gt;Launch the PowerShell Web Access shortcut from the tablet.&amp;nbsp; Log in.&amp;nbsp; Demo a couple commands from the web console but &lt;span style="text-decoration: underline;"&gt;don&amp;rsquo;t pull the results from the disconnected session yet&lt;/span&gt;.&amp;nbsp; Discuss how cool this would be from the recliner at home.&lt;/li&gt;
&lt;li&gt;Switch over to the Camera app on the Surface.&amp;nbsp; Now the camera is live on the big screen.&amp;nbsp; Tell the people in the front row to wave.&lt;/li&gt;
&lt;li&gt;Position the phone in front of the tablet camera so the audience can see it.&amp;nbsp; Launch the shortcut for PowerShell Web Access on the phone.&amp;nbsp; Turn it to landscape mode.&amp;nbsp; Log in.&amp;nbsp; Discuss how handy this is if you have to fix something at work while at a soccer game with the kids.&lt;/li&gt;
&lt;li&gt;Demo PowerShell from the web console on the phone.&amp;nbsp; Do a &amp;ldquo;dir&amp;rdquo; to show the demo.ps1 file you pre-staged earlier in the Administrator profile folder on the server.&amp;nbsp; Then type &amp;ldquo;Get-Content .\demo.ps1&amp;rdquo; to show what the script will do.&amp;nbsp; You can use TAB complete with Get-Content for added effect.&lt;/li&gt;
&lt;li&gt;Now run the demo.ps1 file with the two lines to reconnect the session and display the running output from the disconnected session.&amp;nbsp; Wow!&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Imagine The Possibilities&lt;/h3&gt;
&lt;p&gt;As you might guess the setup will require some time on your part.&amp;nbsp; It is not really that difficult, but there are a lot of steps.&amp;nbsp; The fun part is all the learning along the way.&amp;nbsp; And when you&amp;rsquo;re done it is quite impressive.&amp;nbsp; Sometimes I run the lab on my home network so that I can use my Windows Phone or Surface to play with PowerShell from anywhere in the house.&amp;nbsp; Yip.&amp;nbsp; I&amp;rsquo;m a geek.&amp;nbsp; And I bet you are, too, if you&amp;rsquo;re still reading at this point.&lt;/p&gt;
&lt;p&gt;Now that you have a super-cool PowerShell Web Access lab what can you do with it?&amp;nbsp; With over 2,400 cmdlets to explore and PowerShell under the covers of all the Windows server products the sky is the limit.&amp;nbsp; Imagine the possibilities for remote administration now across all products and technologies with PowerShell from your phone or tablet.&lt;/p&gt;
&lt;p&gt;Typing on the phone keyboard may be tedious, but when you&amp;rsquo;re offline at a family event it is much easier than driving into the office to take care of business.&amp;nbsp; &lt;span style="text-decoration: underline;"&gt;And that is why we created PowerShell Web Access&lt;/span&gt;.&amp;nbsp; Time for some PowerShell web slinging.&amp;nbsp; Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3550466" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="v3" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/v3/" /><category term="Windows Server 2012" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+Server+2012/" /><category term="Windows 8" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+8/" /><category term="Surface" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Surface/" /><category term="Windows Phone" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+Phone/" /><category term="PowerShell Web Access" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell+Web+Access/" /></entry><entry><title>Called Out: From 2012 to 2013</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2013/01/30/called-out-from-2012-to-2013.aspx" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2013/01/30/called-out-from-2012-to-2013.aspx</id><published>2013-01-30T14:00:00Z</published><updated>2013-01-30T14:00:00Z</updated><content type="html">&lt;p&gt;&lt;a title="PowerShell Saturday, March 2012, Columbus, OH" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/03/14/five-free-ways-to-script-active-directory-in-powershell-part-2.aspx" target="_blank"&gt;&lt;img style="display: inline; background-image: none;" title="clip_image001" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/0143.clip_5F00_image001_5F00_0B8099BC.png" alt="clip_image001" width="564" height="226" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Called Out&lt;/h3&gt;
&lt;p&gt;Departing from the usual scripting today's post is a reflection on 2012 and a look ahead at goals for 2013.&amp;nbsp; The overall theme today is the &lt;a title="Heroes To Mentors vision" href="http://blogs.msdn.com/b/kaevans/archive/2012/02/04/moving-from-heroes-to-mentors.aspx" target="_blank"&gt;Heroes To Mentors vision&lt;/a&gt; we have embraced within &lt;a title="Microsoft PFE" href="http://twitter.com/search?q=mspfe" target="_blank"&gt;Microsoft PFE&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Brian Jackett is a coworker and friend of mine (pictured far left above) who specializes in SharePoint and PowerShell. He has been very active in the SharePoint community coordinating and speaking at events. He's a great PFE, and I'm sure you would enjoy having him come to your company to help with your SharePoint or teach a workshop. Check out his blog &lt;a href="http://briantjackett.com" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Brian "called me out" in his &lt;a href="http://briantjackett.com/archive/2013/01/17/goals-for-2013.aspx" target="_blank"&gt;blog post this month&lt;/a&gt;. Each year he blogs about his goals for the year and encourages colleagues to do the same. This time &lt;a href="http://blogs.msdn.com/b/besidethepoint" target="_blank"&gt;Josh&lt;/a&gt; and I drew the short straw. (grin) Thanks, Brian. Really, this is a good thing to do, and I encourage everyone to do the same. I've done this in some form or fashion over the last few years, and it has always been a rewarding experience.&lt;/p&gt;
&lt;h3&gt;Last Year In Review&lt;/h3&gt;
&lt;p&gt;Last autumn I celebrated two years of blogging on TechNet, and I have continued to meet my goal of one solid post monthly. Many of you have either commented or contacted me through the blog, and I enjoy that dialog. Keep it coming. Here are my top five posts of all time based on traffic:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2011/03/17/step-by-step-how-to-use-active-directory-powershell-cmdlets-against-2003-domain-controllers.aspx" target="_blank"&gt;Step-by-Step: How to use Active Directory PowerShell cmdlets against 2003 domain controllers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2011/01/19/finally-copy-and-merge-gpos-powershell-saves-the-day.aspx" target="_blank"&gt;Finally! Copy and merge GPOs! PowerShell saves the day!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2011/05/19/using-powershell-to-resolve-token-size-issues-caused-by-sid-history.aspx" target="_blank"&gt;Using PowerShell to resolve Token Size issues caused by SID history&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2011/11/23/how-to-remove-sid-history-with-powershell.aspx" target="_blank"&gt;How To Remove SID History With PowerShell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2012/01/03/everything-you-need-to-get-started-with-active-directory.aspx" target="_blank"&gt;Everything you need to get started with Active Directory&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In 2012 I also had the privilege of meeting many of you in person either on site as a Premier customer, at a conference, or at a user group event. It has been fun sharing Active Directory PowerShell and new PowerShell v3 features with you in person:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;March - &lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2012/03/14/five-free-ways-to-script-active-directory-in-powershell-part-2.aspx" target="_blank"&gt;PowerShell Saturday&lt;/a&gt;, Columbus, OH&lt;/li&gt;
&lt;li&gt;July - TechReady, Seattle, WA&lt;/li&gt;
&lt;li&gt;August - &lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2012/08/21/what-s-new-in-powershell-v3-demos-to-download.aspx" target="_blank"&gt;TechMentor&lt;/a&gt;, Seattle, WA&lt;/li&gt;
&lt;li&gt;September - &lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2012/09/15/active-directory-powershell-notes-from-the-field.aspx" target="_blank"&gt;PowerShell Saturday&lt;/a&gt;, Charlotte, NC&lt;/li&gt;
&lt;li&gt;November - &lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2012/11/09/dogfoodcon-2012-columbus-ohio.aspx" target="_blank"&gt;DogFoodCon&lt;/a&gt;, Columbus, OH&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thanks to your visits my blog has consistently ranked in the top 10% of TechNet blog traffic for the last year. Thank you for your support and feedback. This blog is all about helping folks with practical needs. Let me know if there are topics you would like me to cover here.&lt;/p&gt;
&lt;p&gt;I should also thank all of you who have &lt;a href="https://twitter.com/GoateePFE" target="_blank"&gt;Tweeted&lt;/a&gt; my blog posts. It is encouraging, and I appreciate your help spreading the good news of PowerShell for Active Directory.&lt;/p&gt;
&lt;h3&gt;2013 Professional Goals&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;This year I was promoted to &lt;strong&gt;senior PFE&lt;/strong&gt;, and I want to make the most of it. I want to develop others around me and share more development opportunities with my peers as my &lt;strong&gt;mentors&lt;/strong&gt; have done for me. &amp;nbsp;Bruce Adamczak was the first to follow my lead and started a very successful &lt;a title="TechNet blog" href="http://blogs.technet.com/b/bruce_adamczak" target="_blank"&gt;TechNet blog&lt;/a&gt;.&amp;nbsp; Next I have invited &lt;a href="http://social.technet.microsoft.com/Profile/tom%20moser%20%5Bmsft%5D/activity" target="_blank"&gt;Tom Moser&lt;/a&gt; to co-present with me at an upcoming internal training event.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PFE Industry Leadership&lt;/strong&gt; is one of our goals as an organization within Microsoft, telling the value story of PFE and helping build the brand. I enjoy talking&amp;nbsp;about the cool stuff we get to do as PFEs. This builds "street cred" in the community for us individually and for Microsoft as a company. I will explore this more in the coming year and develop a training guide for PFEs who want to speak at conferences.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://technet.microsoft.com/en-us/scriptcenter/bb410849" target="_blank"&gt;Ed Wilson&lt;/a&gt; took me under his wing as a &lt;strong&gt;mentee&lt;/strong&gt; last year, and we are both enjoying our monthly conversations. Ed and Theresa have both become good friends, and I look forward to more mentoring this year. &lt;strong&gt;Thank you&lt;/strong&gt;, Ed, for the opportunities you have given me.&lt;/li&gt;
&lt;li&gt;I really enjoy &lt;strong&gt;blogging and scripting&lt;/strong&gt;. This year I plan to publish some updates for the SIDHistory PowerShell Module, and I would like to write a new module for cleaning up groups in Active Directory. Send me your ideas on what would help with group cleanup.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2013 Personal Goals&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Like Brian I am a man of &lt;strong&gt;faith&lt;/strong&gt;, and I want to grow closer to God. I have already begun getting up 30 minutes earlier each day to pray and read the Bible. Any parent of teenagers would agree with me that more prayer is a good thing.&lt;/li&gt;
&lt;li&gt;In February I will begin getting up another 30 minutes earlier to &lt;strong&gt;exercise&lt;/strong&gt; in some awkward geek fashion. I plan to alternate days between cardio and strength training. I tried jogging two years ago and quickly developed a stress fracture in my right knee (twice). I plan on easing into it this time.&lt;/li&gt;
&lt;li&gt;Brian is getting married this year, and I have been &lt;strong&gt;married for 21 years&lt;/strong&gt;. I always strive to be a &lt;strong&gt;better husband and father&lt;/strong&gt;, and this year is no different. We have some special family events coming up this year, and I am looking forward to those.&amp;nbsp; PS - Brian, my wife and I fondly refer to those pictures of our pre-marriage years as&amp;hellip; "the skinny pictures".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is an exciting time in IT and especially at Microsoft. I am really enjoying&amp;nbsp;our new releases: &lt;a href="http://www.windowsphone.com" target="_blank"&gt;Windows Phone 8&lt;/a&gt;, &lt;a href="http://surface.com" target="_blank"&gt;Surface&lt;/a&gt;, &lt;a href="http://windows.microsoft.com/en-US/windows/home" target="_blank"&gt;Windows 8&lt;/a&gt;, &lt;a href="http://blogs.technet.com/b/windowsserver/" target="_blank"&gt;Windows Server 2012&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/b/powershell/" target="_blank"&gt;PowerShell v3&lt;/a&gt;. I look forward to what our customer can accomplish with these new tools both personally and professionally. Let me know how I can help.&amp;nbsp; Consider yourself "called out".&lt;/p&gt;
&lt;p&gt;Ashley &lt;br /&gt;GoateePFE&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3548453" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="Goals" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Goals/" /><category term="Year in Review" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Year+in+Review/" /><category term="Heroes To Mentors" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Heroes+To+Mentors/" /></entry><entry><title>Free Download: CMD to PowerShell Guide for AD</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2013/01/02/free-download-cmd-to-powershell-guide-for-ad.aspx" /><link rel="enclosure" type="application/pdf" length="42860" href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-03-54-23-12/PowerShell-Cmd-Line-Conversion-Guide-AD.pdf" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2013/01/02/free-download-cmd-to-powershell-guide-for-ad.aspx</id><published>2013-01-02T14:00:00Z</published><updated>2013-01-02T14:00:00Z</updated><content type="html">&lt;h3&gt;New Years Resolution&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3817.large_5F005F00_5447958713_5F00_1A01B398.jpg"&gt;&lt;img style="float: right; display: inline; background-image: none;" title="Skip the treadmill.  Learn PowerShell." src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/6557.large_5F005F00_5447958713_5F00_thumb_5F00_6B3BFAF5.jpg" alt="Skip the treadmill.  Learn PowerShell." width="154" height="154" align="right" border="0" /&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Hi folks. It's your friendly, neighborhood PFE again. In order to avoid the long lines to buy a treadmill the first week of January I thought I would save you some time and give you an easier New Years Resolution&amp;hellip; &lt;em&gt;Learn PowerShell.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;It's time to part with "blankie".&lt;/h3&gt;
&lt;p&gt;For years many of us have relied on trusty command line utilities like PING, IPCONFIG, and REPADMIN. Some of us are still hanging on to those instead of embracing the brave new world of PowerShell.&lt;/p&gt;
&lt;p&gt;In an effort to assist with the transition and to introduce some of the cool &lt;a title="new cmdlets in PowerShell v3" href="http://technet.microsoft.com/en-us/library/hh857339" target="_blank"&gt;new cmdlets in PowerShell v3&lt;/a&gt; I have created a &lt;strong&gt;free reference guide&lt;/strong&gt; showing how the old meets the new. For example, instead of PING try the PowerShell cmdlet Test-Connection, instead of NSLOOKUP use Resolve-DNSName, instead of GPUPDATE use Invoke-GPUpdate.&lt;/p&gt;
&lt;p&gt;The guide attached at the bottom of this blog post contains four packed pages of PowerShell pleasure for your perusing.&lt;/p&gt;
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;Why would someone want to use PowerShell instead of command line utilities? There are several reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Command line utilities often give us the data we want, but it is &lt;strong&gt;flat text&lt;/strong&gt; that requires parsing to do anything else with it. Have you ever scripted a command line PING and tried to find the result? Yeah, I have, and it's a pain. Now with PowerShell you can simply reference the ping result properties coming back to easily get the actual data involved.&lt;/li&gt;
&lt;li&gt;Is your favorite command line utility always &lt;strong&gt;available&lt;/strong&gt;? When you would RDP to a server back in the day you had no idea if the adminpak.msi or the Windows Resource Kit was installed. Now you know that PowerShell is always there on Windows Server 2008 R2 and above.&lt;/li&gt;
&lt;li&gt;PowerShell cmdlets mostly use the same &lt;strong&gt;syntax&lt;/strong&gt;. You no longer have to figure out what the right switch is for the remote computer name. Now it is always "-ComputerName".&lt;/li&gt;
&lt;li&gt;PowerShell is not just the future, it's &lt;strong&gt;now&lt;/strong&gt;. Version 1 was released five years ago. Now all of the Microsoft server products use PowerShell. Windows 8 and Server 2012 now have thousands of cmdlets at your finger tips.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Free Download&lt;/h3&gt;
&lt;p&gt;While studying the new 2012 cmdlets in preparation for conference talks last summer I created a quick cheat sheet for PowerShell equivalence to REPADMIN and DNSCMD. The other day I sat down and expanded this to include a raft of familiar utilities:&lt;/p&gt;
&lt;table style="width: 400px;" border="0" cellspacing="0" cellpadding="2"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="133"&gt;
&lt;p&gt;REPADMIN &lt;br /&gt; DCPROMO &lt;br /&gt; CSVDE &lt;br /&gt; NETDOM &lt;br /&gt; NLTEST &lt;br /&gt; GPUPDATE &lt;br /&gt; GPRESULT&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="133"&gt;
&lt;p&gt;DSGET &lt;br /&gt; DSQUERY &lt;br /&gt; DSADD &lt;br /&gt; DSMOD &lt;br /&gt;DSRM &lt;br /&gt;DSMOVE &lt;br /&gt;DSACLS&lt;/p&gt;
&lt;/td&gt;
&lt;td valign="top" width="133"&gt;
&lt;p&gt;DNSCMD &lt;br /&gt; NSLOOKUP &lt;br /&gt; PING &lt;br /&gt; IPCONFIG &lt;br /&gt; NETSTAT&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This guide will get you off and running to convert any old batch files you still have lying around or hiding in scheduled tasks.&lt;/p&gt;
&lt;h3&gt;Four pages. Really?&lt;/h3&gt;
&lt;p&gt;Yes. I know that sounds like a lot to learn, but the good news is I can't remember them all either. I work for Microsoft, and I still use &lt;a title="Show-Command" href="http://technet.microsoft.com/library/hh849915.aspx" target="_blank"&gt;Show-Command&lt;/a&gt;, &lt;a title="Get-Command" href="http://technet.microsoft.com/library/hh849711.aspx" target="_blank"&gt;Get-Command&lt;/a&gt;, and &lt;a title="Get-Help" href="http://technet.microsoft.com/library/hh849696.aspx" target="_blank"&gt;Get-Help&lt;/a&gt; on a daily basis. That's why we put those cmdlets in the box. With over 2,400 cmdlets now there's a good chance we've got you covered for anything you need. If not, let us know on the &lt;a title="Connect site" href="https://connect.microsoft.com/powershell" target="_blank"&gt;Connect site&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are so many &lt;a title="command line utilities" href="http://www.microsoft.com/download/en/details.aspx?id=2632" target="_blank"&gt;command line utilities&lt;/a&gt; out there that I had to limit my focus to those related to Active Directory. Hopefully this post will inspire others in the community to compile similar guides for their technologies.&lt;/p&gt;
&lt;h3&gt;Disclaimer&lt;/h3&gt;
&lt;p&gt;I created this guide based on my personal knowledge of the tools and the help text that they print. In other words this is not a top secret guide published by Microsoft product groups, and I have not tested every single entry. Some of these will require you to use Get-Help to explore the capabilities. I built this by hand in Excel, so you may be able to find some gaps in the list. If you find any omissions or corrections please &lt;a title="send them my way" href="http://blogs.technet.com/b/ashleymcglone/contact.aspx" target="_blank"&gt;send them my way&lt;/a&gt;, and I'll update the document.&lt;/p&gt;
&lt;p&gt;Enjoy. Happy New Year!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;photo credit: &lt;a href="http://www.flickr.com/photos/eccampbellphotography/5447958713/"&gt;eccampbell&lt;/a&gt; via &lt;a href="http://photopin.com"&gt;photopin&lt;/a&gt; &lt;a href="http://creativecommons.org/licenses/by-sa/2.0/"&gt;cc&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3542312" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="v3" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/v3/" /><category term="Windows Server 2012" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+Server+2012/" /><category term="Windows 8" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+8/" /></entry><entry><title>TIP: 2 Ways userAccountControl Is Easier In AD PowerShell</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/12/13/tip-2-ways-useraccountcontrol-is-easier-in-ad-powershell.aspx" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2012/12/13/tip-2-ways-useraccountcontrol-is-easier-in-ad-powershell.aspx</id><published>2012-12-13T14:00:00Z</published><updated>2012-12-13T14:00:00Z</updated><content type="html">&lt;h3&gt;Background&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/4201.image_5F00_7758665B.png"&gt;&lt;img style="float: right; display: inline; background-image: none;" title="userAccountControl" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/5773.image_5F00_thumb_5F00_246D532A.png" alt="userAccountControl" width="290" height="384" align="right" border="0" /&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Anyone who wants to write scripts for &lt;strong&gt;Active Directory&lt;/strong&gt; will eventually run into the famous &lt;strong&gt;userAccountControl&lt;/strong&gt; attribute.&amp;nbsp; Usually this comes up when you are searching for disabled accounts.&amp;nbsp; Actually this attribute is a bit flag for 22 different account settings!&amp;nbsp; You can find them clearly documented in &lt;a title="KB305144" href="http://support.microsoft.com/kb/305144" target="_blank"&gt;KB305144&lt;/a&gt;.&amp;nbsp; In the GUI you find these settings represented by checkboxes in Active Directory Users and Computers (ADUC) (pictured right).&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve done my share of VBScripts over the last 10 years, and this always took more lines of code than I wanted to write.&amp;nbsp; In &lt;a title="this example" href="http://blogs.technet.com/b/heyscriptingguy/archive/2005/05/12/how-can-i-get-a-list-of-all-the-disabled-user-accounts-in-active-directory.aspx" target="_blank"&gt;this example&lt;/a&gt; on the Hey Scripting Guy blog you can see it would take 14 lines of code to report on disabled accounts.&amp;nbsp; To make matters worse you had to understand LDAP bitwise filter syntax.&amp;nbsp; In an &lt;a title="earlier post" href="http://blogs.technet.com/b/ashleymcglone/archive/2011/07/12/rip-off-the-bandaid-with-powershell-using-bitwise-ldap-filters-to-search-and-destroy-manual-server-connection-objects.aspx" target="_blank"&gt;earlier post&lt;/a&gt; I demonstrated this syntax for querying AD based on a bit value.&lt;/p&gt;
&lt;p&gt;The good news is that in Windows Server 2008 R2 and above we have two cmdlets that make this easy.&lt;/p&gt;
&lt;h3&gt;One Line Of PowerShell&lt;/h3&gt;
&lt;p&gt;With the Active Directory module for PowerShell and the &lt;a title="Search-ADAccount" href="http://technet.microsoft.com/en-us/library/ee617247" target="_blank"&gt;Search-ADAccount&lt;/a&gt; cmdlet those 14 lines of VBScript turn into a single line:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;PS C:\&amp;gt; Search-ADAccount -AccountDisabled&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To limit the results to users or computers you can try one of these handy switches:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;PS C:\&amp;gt; Search-ADAccount &amp;ndash;AccountDisabled &amp;ndash;UsersOnly&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;PS C:\&amp;gt; Search-ADAccount &amp;ndash;AccountDisabled &amp;ndash;ComputersOnly&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The Search-ADAccount cmdlet has several switches that target the userAccountControl bit flags:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AccountDisabled&lt;/li&gt;
&lt;li&gt;AccountExpired&lt;/li&gt;
&lt;li&gt;AccountExpiring&lt;/li&gt;
&lt;li&gt;LockedOut&lt;/li&gt;
&lt;li&gt;PasswordExpired&lt;/li&gt;
&lt;li&gt;PasswordNeverExpires&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now we don&amp;rsquo;t have to fuss with all of the fancy LDAP syntax.&lt;/p&gt;
&lt;h3&gt;But wait&amp;hellip; there&amp;rsquo;s more!&lt;/h3&gt;
&lt;p&gt;The &lt;a title="Set-ADAccountControl" href="http://technet.microsoft.com/en-us/library/ee617249.aspx" target="_blank"&gt;Set-ADAccountControl&lt;/a&gt; cmdlet gives us 12 switches to toggle these checkboxes via script:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AccountNotDelegated&lt;/li&gt;
&lt;li&gt;AllowReversiblePasswordEncryption&lt;/li&gt;
&lt;li&gt;CannotChangePassword&lt;/li&gt;
&lt;li&gt;DoesNotRequirePreAuth&lt;/li&gt;
&lt;li&gt;Enabled&lt;/li&gt;
&lt;li&gt;HomedirRequired&lt;/li&gt;
&lt;li&gt;MNSLogonAccount&lt;/li&gt;
&lt;li&gt;PasswordNeverExpires&lt;/li&gt;
&lt;li&gt;PasswordNotRequired&lt;/li&gt;
&lt;li&gt;TrustedForDelegation&lt;/li&gt;
&lt;li&gt;TrustedToAuthForDelegation&lt;/li&gt;
&lt;li&gt;UseDESKeyOnly&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now you can turn the flags on and off like this:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;PS C:\&amp;gt; &lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;Set-ADAccountControl JoeUser &amp;ndash;PasswordNeverExpires $true&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;PS C:\&amp;gt; &lt;/span&gt;&lt;span style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New;"&gt;Set-ADAccountControl JoeUser &amp;ndash;PasswordNeverExpires $false&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Wow!&amp;nbsp; Now that was easy.&lt;/p&gt;
&lt;h3&gt;PS&amp;hellip;&lt;/h3&gt;
&lt;p&gt;Closing reminders:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You&amp;rsquo;ll need the &lt;a title="RSAT" href="http://social.technet.microsoft.com/wiki/contents/articles/2202.remote-server-administration-tools-rsat-for-windows-vista-windows-7-windows-8-windows-server-2008-windows-server-2008-r2-and-windows-server-2012-dsforum2wiki.aspx#Download%20links" target="_blank"&gt;RSAT&lt;/a&gt; for Windows 7 or Windows 8 to get the cmdlets on your workstation.&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t forget to type &lt;span style="font-family: Courier New;"&gt;Import-Module ActiveDirectory&lt;/span&gt; before trying these one-liners.&lt;/li&gt;
&lt;li&gt;You can even run these against legacy 2003 or 2008 domain controllers using the guidance &lt;a title="http://aka.ms/ADPS2003" href="http://aka.ms/ADPS2003" target="_blank"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3540546" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="userAccountControl" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/userAccountControl/" /><category term="Set-ADAccountControl" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Set_2D00_ADAccountControl/" /><category term="Search-ADAccount" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Search_2D00_ADAccount/" /></entry><entry><title>AD PowerShell Password Reset Shortcut for Helpdesk</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/11/26/ad-powershell-password-reset-shortcut-for-helpdesk.aspx" /><link rel="enclosure" type="text/plain" length="2620" href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-03-53-30-13/ADPS_5F00_Password_5F00_Reset_5F00_Batch.txt" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2012/11/26/ad-powershell-password-reset-shortcut-for-helpdesk.aspx</id><published>2012-11-26T14:00:00Z</published><updated>2012-11-26T14:00:00Z</updated><content type="html">&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Back in May I released a &lt;a title="post" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/05/05/powershell-tip-active-directory-account-unlock-shortcut-for-help-desk.aspx" target="_blank"&gt;post&lt;/a&gt; on the &lt;a title="Hey Scripting Guy" href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/05/weekend-scripter-active-directory-account-unlock-shortcut-for-help-desk.aspx" target="_blank"&gt;Hey Scripting Guy&lt;/a&gt; blog showing how to create a shortcut to &lt;strong&gt;unlock a user account with a PowerShell desktop shortcut&lt;/strong&gt;.&amp;nbsp; That post was very popular, and the comments evolved into another shortcut to reset passwords.&amp;nbsp; Due to the popularity and utility of the idea I decided it deserved its own blog post.&amp;nbsp; I&amp;rsquo;ve also learned a little more about the &lt;a title="Set-ADAccountPassword" href="http://technet.microsoft.com/en-us/library/ee617261.aspx" target="_blank"&gt;Set-ADAccountPassword&lt;/a&gt; cmdlet to simplify my previous code.&lt;/p&gt;
&lt;h3&gt;Monday Morning on &amp;ldquo;The Desk&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;You know the drill.&amp;nbsp; It&amp;rsquo;s Monday morning.&amp;nbsp; Last Friday 47 users decided it was a good idea to change their password before the weekend.&amp;nbsp; It&amp;rsquo;s Monday.&amp;nbsp; They forgot, just like I would.&amp;nbsp; Personally I never change my password on a Friday for this reason.&amp;nbsp; I need a couple days to use it before the weekend.&lt;/p&gt;
&lt;p&gt;What could make this worse?&amp;nbsp; Holiday weekends&amp;hellip; like US Thanksgiving.&amp;nbsp; (grin)&amp;nbsp; Now it&amp;rsquo;s been at least five days since I reset that password.&amp;nbsp; There&amp;rsquo;s no chance I&amp;rsquo;ll remember it unless it&amp;rsquo;s written down on that sticky note under the mouse pad.&lt;/p&gt;
&lt;p&gt;Now all 47 of those users must call the helpdesk first thing Monday before they can begin another week of productivity for the company.&amp;nbsp; The self-service password project has not gotten enough budget or resources for implementation, and until it does every Monday morning is going to look very familiar.&amp;nbsp; That&amp;rsquo;s where we come in with PowerShell.&lt;/p&gt;
&lt;h3&gt;The Options&lt;/h3&gt;
&lt;p&gt;How many different ways can we reset a password?&amp;nbsp; Let&amp;rsquo;s make a quick list:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a title="Active Directory Users and Computers" href="http://technet.microsoft.com/en-us/library/cc782255(v=WS.10).aspx" target="_blank"&gt;Active Directory Users and Computers (ADUC)&lt;/a&gt; &amp;ndash; Despite the several clicks involved this is the first choice for many folks.&amp;nbsp; It&amp;rsquo;s been working for 12 years now.&amp;nbsp; Why change now?&lt;/li&gt;
&lt;li&gt;&lt;a title="Active Directory Administrative Center" href="http://technet.microsoft.com/en-us/library/dd861290.aspx" target="_blank"&gt;Active Directory Administrative Center (ADAC)&lt;/a&gt; &amp;ndash; This is the new AD-GUI-with-PowerShell-under-the-covers version of ADUC, and it puts password resets on the front page for easy access.&amp;nbsp; Give this one a try.&amp;nbsp; It&amp;rsquo;s free with your Windows Server 2008 R2 (or 2012) RSAT.&amp;nbsp; This is slightly faster.&lt;/li&gt;
&lt;li&gt;&lt;a title="DSMOD" href="http://technet.microsoft.com/en-us/library/cc782255(v=WS.10).aspx#BKMK_CMD" target="_blank"&gt;DSMOD&lt;/a&gt; &amp;ndash; Yeah.&amp;nbsp; It&amp;rsquo;s an option, but you need to type the distinguished name for the user.&amp;nbsp; Cool, but just not practical.&lt;/li&gt;
&lt;li&gt;That in-house identity app written seven years ago by a special project team in InfoSec.&amp;nbsp; Um.&amp;nbsp; Yeah.&amp;nbsp; Way too many clicks.&lt;/li&gt;
&lt;li&gt;&lt;a title="PowerShell" href="http://technet.microsoft.com/en-us/library/ee617261.aspx" target="_blank"&gt;PowerShell&lt;/a&gt;.&amp;nbsp; Wait&amp;hellip; can you click in PowerShell?&amp;nbsp; Kind of. It&amp;rsquo;s going to be a single double-click.&amp;nbsp; Much faster.&lt;/li&gt;
&lt;li&gt;Etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Bring The &amp;lsquo;Shell To The &amp;lsquo;Desk&lt;/h3&gt;
&lt;p&gt;Attached at the bottom of this post you&amp;rsquo;ll find a simple text file with these lines (note that these one-liners have been wrapped for display purposes):&lt;/p&gt;
&lt;pre&gt;: 100 characters
: &lt;span style="background-color: #ffff00;"&gt;Reset Password&lt;/span&gt;
@echo off&amp;amp;&amp;amp;powershell -NoE -C "&amp;amp;{ipmo ActiveDirectory;
&lt;span style="background-color: #ffff00;"&gt;Set-ADAccountPassword&lt;/span&gt; (Read-Host 'User') -R}"

: 123 characters
: Reset Password
: &lt;span style="background-color: #ffff00;"&gt;User must change password at next logon&lt;/span&gt;
@echo off&amp;amp;&amp;amp;powershell -NoE -C "&amp;amp;{ipmo ActiveDirectory;
Set-ADAccountPassword ($u=Read-Host 'User') -R;&lt;span style="background-color: #ffff00;"&gt;Set-ADUser $u -Ch 1&lt;/span&gt;}"

: 154 characters
: Reset Password
: User must change password at next logon
: &lt;span style="background-color: #ffff00;"&gt;Alternate credentials &lt;/span&gt;@echo off&amp;amp;&amp;amp;powershell -NoE -C "&amp;amp;{ipmo ActiveDirectory;
Set-ADAccountPassword ($u=Read-Host 'User') -R &lt;span style="background-color: #ffff00;"&gt;-Cr ($c=Get-Credential)&lt;/span&gt;;
Set-ADUser $u -Ch 1 &lt;span style="background-color: #ffff00;"&gt;-Cr $c&lt;/span&gt;}"

: 191 characters
: Reset Password
: User must change password at next logon
: Alternate credentials
: &lt;span style="background-color: #ffff00;"&gt;Target a specific DC&lt;/span&gt;
@echo off&amp;amp;&amp;amp;powershell -NoE -C "&amp;amp;{ipmo ActiveDirectory;
Set-ADAccountPassword -Cr ($c=Get-Credential) &lt;span style="background-color: #ffff00;"&gt;-S ($s=Read-Host 'DC')&lt;/span&gt;
 -I ($u=Read-Host 'User') -R;Set-ADUser $u -Ch 1 -Cr $c &lt;span style="background-color: #ffff00;"&gt;-Server $s&lt;/span&gt;}"

&lt;/pre&gt;
&lt;p&gt;Depending on how you would like to perform the password reset there are four options presented here for your shortcut.&amp;nbsp; Simply copy the line you want to use and paste it into a batch file on the desktop for the helpdesk.&amp;nbsp; Here are the flavors:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Password reset&lt;/li&gt;
&lt;li&gt;User must change password at next logon (always a good idea)&lt;/li&gt;
&lt;li&gt;Reset the password using alternate credentials&lt;/li&gt;
&lt;li&gt;Target a different domain controller to initiate the change&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Just copy the line you want into a text file on the desktop and put &amp;lsquo;.BAT&amp;rsquo; at the end of the file name.&amp;nbsp; Enjoy!&lt;/p&gt;
&lt;h3&gt;The Code&lt;/h3&gt;
&lt;p&gt;At first glance these lines may be a bit challenging to understand.&amp;nbsp; That&amp;rsquo;s because I&amp;rsquo;ve maximized the use of aliases and abbreviations to tighten these lines down to merely a few characters.&amp;nbsp; I usually avoid these for readability, but in this case I was aiming for brevity.&amp;nbsp; Plus it&amp;rsquo;s just fun.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s break down the longest line:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;@echo off&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;This is batch language to hide the commands when you run them.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&amp;amp;&amp;amp;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;This is how we cheat in batch language and put everything on one line.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;powershell -NoE &amp;ndash;C&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Launch PowerShell, leave the window open when complete (in case there are any errors to view), and run this command&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;"&amp;amp;{&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Now we&amp;rsquo;re in PowerShell, and the &amp;lsquo;&amp;amp;&amp;rsquo; is the invoke operator.&amp;nbsp; This tells PowerShell to run everything inside the code block { }.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;ipmo ActiveDirectory;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Import-Module ActiveDirectory.&amp;nbsp; Then &amp;lsquo;;&amp;rsquo; is the new line character so we can cheat in PowerShell and keep it all on one line.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Set-ADAccountPassword -Cr ($c=Get-Credential) -S ($s=Read-Host 'DC') -I ($u=Read-Host 'User') -R;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;This is where the magic happens.&amp;nbsp; There is no alias to shorten the cmdlet, but we&amp;rsquo;ve abbreviated all of the parameters: Credential, Server, Identity, and Reset.&amp;nbsp; By capturing each of these values into a variable we can reuse them in the next cmdlet without having to prompt for the values again.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Set-ADUser $u -Ch 1 -Cr $c -Server $s}"&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;ChangePasswordAtLogon become &amp;lsquo;Ch&amp;rsquo;. &amp;lsquo;Cr&amp;rsquo; again is Credential.&amp;nbsp; Because this cmdlet has so many parameters beginning with &amp;lsquo;S&amp;rsquo; we have to use the full parameter name for &amp;lsquo;Server&amp;rsquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;What other language could do this in less than 200 characters?&amp;nbsp; Now that&amp;rsquo;s PowerShell!&lt;/p&gt;
&lt;h3&gt;One Small Prerequisite&lt;/h3&gt;
&lt;p&gt;In order for the helpdesk to use this code they will need to install the Windows 7 or Windows 8 &lt;a title="Remote Server Administration Tools (RSAT)" href="http://social.technet.microsoft.com/wiki/contents/articles/2202.remote-server-administration-tools-rsat-for-windows-vista-windows-7-windows-8-windows-server-2008-windows-server-2008-r2-and-windows-server-2012-dsforum2wiki.aspx" target="_blank"&gt;Remote Server Administration Tools (RSAT)&lt;/a&gt; and turn on the feature &lt;strong&gt;Active Directory Module for Windows PowerShell&lt;/strong&gt;.&amp;nbsp; Most likely the RSAT are already installed for other administrative tasks, so they can check the GUI box pictured here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/5852.image_5F00_3BB81117.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/5543.image_5F00_thumb_5F00_61ADC16D.png" alt="image" width="379" height="332" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;&amp;lsquo;Tis The Season&lt;/h3&gt;
&lt;p&gt;Password resets will never go out of season.&amp;nbsp; Armed with these new batch lines perhaps your Monday mornings will go faster and the elves in the toy shop can get back to what they do best&amp;hellip; making new &lt;a title="Microsoft Surface" href="http://www.microsoft.com/Surface" target="_blank"&gt;Microsoft Surface&lt;/a&gt; tablets to put under the Christmas tree.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3533013" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="Helpdesk" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Helpdesk/" /><category term="Set-ADUser" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Set_2D00_ADUser/" /><category term="Set-ADAccountPassword" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Set_2D00_ADAccountPassword/" /></entry><entry><title>DogfoodCon 2012 - Columbus, Ohio</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/11/09/dogfoodcon-2012-columbus-ohio.aspx" /><link rel="enclosure" type="application/zip" length="508190" href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-03-53-09-99/ADPSStepByStep_2D00_GoateePFE.zip" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2012/11/09/dogfoodcon-2012-columbus-ohio.aspx</id><published>2012-11-09T14:00:00Z</published><updated>2012-11-09T14:00:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3808.image_5F00_39601A70.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/4075.image_5F00_thumb_5F00_05B7AE12.png" alt="image" width="594" height="110" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Today I have the privilege of speaking at &lt;a title="http://www.dogfoodcon.com" href="http://www.dogfoodcon.com" target="_blank"&gt;DogfoodCon 2012&lt;/a&gt; in Columbus, Ohio.&amp;nbsp; My topic is &lt;strong&gt;&amp;ldquo;Active Directory PowerShell Step-By-Step&amp;rdquo;&lt;/strong&gt;.&amp;nbsp; This post includes a download of the slide deck and demo scripts for the session.&lt;/p&gt;
&lt;p&gt;Here are the resource links that I shared today:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="RSAT Download for Windows 7 &amp;amp; Windows 8" href="http://social.technet.microsoft.com/wiki/contents/articles/2202.remote-server-administration-tools-rsat-for-windows-vista-windows-7-windows-8-windows-server-2008-windows-server-2008-r2-and-windows-server-2012-dsforum2wiki.aspx#Download%20links" target="_blank"&gt;RSAT Download for Windows 7 &amp;amp; Windows 8&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="Active Directory Management Gateway Service" href="http://aka.ms/ADPS2003" target="_blank"&gt;Active Directory Management Gateway Service&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="Five Free Ways To Script Active Directory" href="http://aka.ms/ADPS5ways" target="_blank"&gt;Five Free Ways To Script Active Directory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="TechNet AD PowerShell Docs (v2)" href="http://technet.microsoft.com/en-us/library/dd378937(WS.10).aspx" target="_blank"&gt;TechNet AD PowerShell Docs (v2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="TechNet AD PowerShell Docs (v3)" href="http://technet.microsoft.com/library/hh852274.aspx" target="_blank"&gt;TechNet AD PowerShell Docs (v3)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="What&amp;rsquo;s New In The Active Directory PowerShell Module for 2012" href="http://technet.microsoft.com/en-us/library/dd378783(WS.10).aspx" target="_blank"&gt;What&amp;rsquo;s New In The Active Directory PowerShell Module for 2012&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3530999" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="Columbus" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Columbus/" /><category term="v3" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/v3/" /><category term="Windows Server 2012" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+Server+2012/" /><category term="DogFoodCon" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/DogFoodCon/" /></entry><entry><title>AD Group History Mystery: PowerShell v3 REPADMIN</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/10/17/ad-group-history-mystery-powershell-v3-repadmin.aspx" /><link rel="enclosure" type="text/plain" length="3047" href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-03-52-56-06/get-user-group-membership-history.p_2D00_s_2D00_1.txt" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2012/10/17/ad-group-history-mystery-powershell-v3-repadmin.aspx</id><published>2012-10-17T13:00:00Z</published><updated>2012-10-17T13:00:00Z</updated><content type="html">&lt;p&gt;&lt;img src="http://webdev.digitalfilmtree.com/blog/wp-content/uploads/2011/09/iStock_000012938166Small.jpg" alt="" width="193" height="127" align="right" /&gt;&lt;/p&gt;
&lt;p&gt;I remember back in high school the janitor had this massive ring of keys on his belt.&amp;nbsp; The keys would jingle with each step as he pushed the broom down the hall.&amp;nbsp; It was like his own percussion section accompanying the tune he whistled.&amp;nbsp; So what does this have to do with PowerShell?&lt;/p&gt;
&lt;h3&gt;The Scenario&lt;/h3&gt;
&lt;p&gt;After speaking about &lt;a href="http://aka.ms/SIDHistory" target="_blank"&gt;SID history and token size&lt;/a&gt; at &lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2012/09/15/active-directory-powershell-notes-from-the-field.aspx" target="_blank"&gt;PowerShell Saturday&lt;/a&gt; last month an attendee approached me with a common concern.&amp;nbsp; I was so excited to code the answer that I did it in the airport on the way home.&lt;/p&gt;
&lt;p&gt;Joe User has been with the company for 23 years and has accumulated more group memberships than the entire desktop support team.&amp;nbsp; Joe has rotated through five different departments during his career and managed to survive all of the layoffs.&amp;nbsp; As a result he has access to every share in the company.&amp;nbsp; Even worse his access &lt;a href="http://blogs.technet.com/b/ashleymcglone/archive/2011/05/19/using-powershell-to-resolve-token-size-issues-caused-by-sid-history.aspx" target="_blank"&gt;token is so big that it won&amp;rsquo;t fit through the door&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/6431.image_5F00_187FE51F.png"&gt;&lt;img style="float: right; display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/1145.image_5F00_thumb_5F00_4C47DB70.png" alt="image" width="244" height="225" align="right" border="0" /&gt;&lt;/a&gt;We would love to clean up his group memberships, but we have no way of knowing when he was added to all these groups.&amp;nbsp; If we could see the dates he joined those groups it would give us a clue about removing just the older group memberships.&amp;nbsp; Without this information his token will continue to bloat&amp;hellip; just like that overloaded key ring swinging on the janitor's hip.&lt;/p&gt;
&lt;h3&gt;Where can we find group membership details?&lt;/h3&gt;
&lt;p&gt;When you look into the member attribute of an AD group you&amp;rsquo;ll find a list of all members in distinguished name format.&amp;nbsp; But that&amp;rsquo;s it.&amp;nbsp; There is no smoking gun or finger prints that tell you how they got there.&amp;nbsp; However, there is a little-known piece of data called &lt;strong&gt;&lt;em&gt;replication metadata&lt;/em&gt;&lt;/strong&gt; that can tell us exactly what we need.&amp;nbsp; This data is quite special for groups, because it shows us the date individual members were added and removed.&amp;nbsp; Awesome!&amp;nbsp; But if you try to view it in the GUI it looks like ugly hex.&lt;/p&gt;
&lt;h3&gt;REPADMIN is so last decade&lt;/h3&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/2211.image_5F00_7CFAE31B.png"&gt;&lt;img style="float: right; display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/7506.image_5F00_thumb_5F00_09889038.png" alt="image" width="234" height="244" align="right" border="0" /&gt;&lt;/a&gt;That&amp;rsquo;s where REPADMIN helps with the handy &lt;em&gt;showObjMeta&lt;/em&gt; parameter.&amp;nbsp; While this command will show us the data, it wraps and scrolls so much in the console that it is difficult to read.&amp;nbsp; Also it is extremely painful to parse with any kind of script.&lt;/p&gt;
&lt;p&gt;Try it for yourself:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&lt;strong&gt;repadmin.exe /showObjMeta DCNAME &amp;ldquo;CN=GroupName,OU=SomeOU,DC=contoso,DC=com&amp;rdquo;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is a cool command that I&amp;rsquo;ve used for forensic investigations in the past to see when an attribute was last modified and which DC originated the change.&amp;nbsp; Then you may be able to trace it down in the logs on that DC to find the account that made the change.&amp;nbsp; You can read more about this &lt;a href="http://blogs.technet.com/b/ad/archive/2006/06/12/435501.aspx" target="_blank"&gt;here&lt;/a&gt; and &lt;a href="http://technet.microsoft.com/en-us/library/cc742104(v=WS.10).aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Can I do it with PowerShell?&amp;nbsp; Please say yes.&lt;/h3&gt;
&lt;p&gt;Way back in PowerShell v1 MVP Brandon Shell wrote a script called &lt;a href="http://bsonposh.com/archives/253" target="_blank"&gt;Get-ADObjectReplicationMetadata&lt;/a&gt; to do this.&amp;nbsp; The AD cmdlets in PowerShell v2 had little parity with REPADMIN.&amp;nbsp; Now in PowerShell v3 the AD cmdlets have made good progress.&amp;nbsp; We still have a ways to go, but you can see in the chart below that PowerShell is catching up with REPADMIN.&amp;nbsp; &lt;em&gt;This is an unofficial comparison chart that I created based on my own observations.&amp;nbsp; Any corrections or additions are welcome.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Notice now we have one of my new favorite cmdlets &lt;a href="http://technet.microsoft.com/en-us/library/hh852209.aspx" target="_blank"&gt;Get-ADReplicationAttributeMetadata&lt;/a&gt;.&amp;nbsp; When I found this in the Windows Server 2012 beta it was like Christmas morning!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table style="width: 582px; list-style-type: disc; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;&lt;colgroup&gt;&lt;col style="mso-width-source: userset; mso-width-alt: 6509;" width="178" /&gt;&lt;/colgroup&gt;&lt;colgroup&gt;&lt;col style="mso-width-source: userset; mso-width-alt: 14774;" width="404" /&gt;&lt;/colgroup&gt;
&lt;tbody&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl66" style="vertical-align: bottom; white-space: nowrap;" width="178" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;&lt;strong&gt;REPADMIN&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl66" style="vertical-align: bottom; white-space: nowrap;" width="404"&gt;&lt;span style="font-size: 11pt;"&gt;&lt;strong&gt;PowerShell&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="xl66" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;&lt;strong&gt;2012 Cmdlets&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/FailCache&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADReplicationFailure&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/Queue&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADReplicationQueueOperation&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/ReplSingleObj&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Sync-ADObject&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/ShowConn&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADReplicationConnection&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl67" style="vertical-align: bottom; white-space: nowrap; background-color: yellow;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/ShowObjMeta&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl67" style="vertical-align: bottom; white-space: nowrap; background-color: yellow;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADReplicationAttributeMetadata&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/ShowRepl&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;/ReplSum&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADReplicationPartnerMetadata&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/ShowUTDVec&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADReplicationUpToDatenessVectorTable&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/SiteOptions&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Set-ADReplicationSite&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="xl66" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;&lt;strong&gt;2008 R2 Cmdlets&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/ShowAttr&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADObject&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/SetAttr&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Set-ADObject&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&lt;span style="font-size: 11pt;"&gt;/PRP&lt;/span&gt;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADDomainControllerPasswordReplicationPolicy&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Add-ADDomainControllerPasswordReplicationPolicy&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Remove-ADDomainControllerPasswordReplicationPolicy&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADAccountResultantPasswordReplicationPolicy&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="height: 16.5pt;"&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;" height="22"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="xl65" style="vertical-align: bottom; white-space: nowrap;"&gt;&lt;span style="font-size: 11pt;"&gt;Get-ADDomainControllerPasswordReplicationPolicyUsage&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;The Script&lt;/h3&gt;
&lt;p&gt;Here is the PowerShell goodness we&amp;rsquo;ve been awaiting (also attached at the bottom of the post):&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #0000ff;"&gt;Import-Module&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;ActiveDirectory&lt;/span&gt;            
            
&lt;span style="color: #ff4500;"&gt;$username&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;=&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;&lt;span style="background-color: #ffff00;"&gt;"janitor"&lt;/span&gt;&lt;/span&gt;            
&lt;span style="color: #ff4500;"&gt;$userobj&lt;/span&gt;  &lt;span style="color: #a9a9a9;"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Get-ADUser&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;$username&lt;/span&gt;            
            
&lt;span style="color: #0000ff;"&gt;Get-ADUser&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;$userobj&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;.&lt;/span&gt;&lt;span style="color: #000000;"&gt;DistinguishedName&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Properties&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;memberOf&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
 &lt;span style="color: #0000ff;"&gt;Select-Object&lt;/span&gt; &lt;span style="color: #000080;"&gt;-ExpandProperty&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;memberOf&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
 &lt;span style="color: #0000ff;"&gt;ForEach-Object&lt;/span&gt; &lt;span style="color: #000000;"&gt;{&lt;/span&gt;            
    &lt;span style="color: #0000ff;"&gt;&lt;span style="background-color: #ffff00;"&gt;Get-ADReplicationAttributeMetadata&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;$_&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Server&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;&lt;span style="background-color: #ffff00;"&gt;localhost&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #000080;"&gt;&lt;span style="background-color: #ffff00;"&gt;-ShowAllLinkedValues&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;             
      &lt;span style="color: #0000ff;"&gt;Where-Object&lt;/span&gt; &lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;$_&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;.&lt;/span&gt;&lt;span style="color: #000000;"&gt;AttributeName&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;-eq&lt;/span&gt; &lt;span style="color: #8b0000;"&gt;'member'&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;-and&lt;/span&gt;             
      &lt;span style="color: #ff4500;"&gt;$_&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;.&lt;/span&gt;&lt;span style="color: #000000;"&gt;AttributeValue&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;-eq&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;$userobj&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;.&lt;/span&gt;&lt;span style="color: #000000;"&gt;DistinguishedName&lt;/span&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt;            
      &lt;span style="color: #0000ff;"&gt;Select-Object&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;FirstOriginatingCreateTime&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;Object&lt;/span&gt;&lt;span style="color: #a9a9a9;"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;AttributeValue&lt;/span&gt;            
    &lt;span style="color: #000000;"&gt;}&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Sort-Object&lt;/span&gt; &lt;span style="color: #8a2be2;"&gt;FirstOriginatingCreateTime&lt;/span&gt; &lt;span style="color: #000080;"&gt;-Descending&lt;/span&gt; &lt;span style="color: #a9a9a9;"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Out-GridView&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I realize that it looks complicated, but it is practically a one-liner.&amp;nbsp; Notice the highlighted pieces:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You&amp;rsquo;ll need to provide a username in the appropriate variable.&amp;nbsp; This can be a short user ID or a distinguished name.&lt;/li&gt;
&lt;li&gt;The metadata cmdlet needs the switch &lt;strong&gt;&lt;em&gt;ShowAllLinkedValues&lt;/em&gt;&lt;/strong&gt; in order to return all of the group membership metadata.&amp;nbsp; You only need this parameter with AD objects containing linked values.&lt;/li&gt;
&lt;li&gt;Replace &lt;em&gt;localhost&lt;/em&gt; with the FQDN of your nearest DC containing the user account in question.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Note that you will need a &lt;/em&gt;&lt;a href="http://technet.microsoft.com/en-us/evalcenter/hh670538.aspx" target="_blank"&gt;&lt;em&gt;Windows Server 2012&lt;/em&gt;&lt;/a&gt;&lt;em&gt; domain controller and optionally the AD PowerShell module installed from the &lt;/em&gt;&lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=28972" target="_blank"&gt;&lt;em&gt;Windows 8 RSAT&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When you run this script you&amp;rsquo;ll get a clean grid view full of dated group memberships.&amp;nbsp; If any groups are missing in the list, then they have likely not been converted to &lt;a href="http://blogs.technet.com/b/askds/archive/2010/03/30/best-practices-around-active-directory-authoritative-restores-in-windows-server-2003-and-2008.aspx" target="_blank"&gt;Linked Value Replication (LVR)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/3288.image_5F00_6109AE23.png"&gt;&lt;img style="display: inline; background-image: none;" title="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/6013.image_5F00_thumb_5F00_1FFB2EBF.png" alt="image" width="587" height="155" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It would be easy to wrap this code into a function or module where you could reuse it for processing a large number of accounts.&amp;nbsp; You could pipe a list of users into it, and then send the results to a CSV file.&amp;nbsp; To scale it more efficiently you could simply dump the member metadata for every group in the domain instead of retrieving it multiple times for multiple users.&lt;/p&gt;
&lt;h3&gt;Do Your Part: Reduce Token Bloat Today&lt;/h3&gt;
&lt;p&gt;Armed with this code you can now begin the process of reviewing token bloat users and their group memberships.&amp;nbsp; Hopefully the date information will empower you to remove them from some of those stale groups.&amp;nbsp; Who knows, you might even be able to get by with a smaller key ring.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3525606" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="Token Size" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Token+Size/" /><category term="v3" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/v3/" /><category term="REPADMIN" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/REPADMIN/" /><category term="Windows Server 2012" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Windows+Server+2012/" /><category term="Token Bloat" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Token+Bloat/" /><category term="Groups" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Groups/" /></entry><entry><title>Active Directory PowerShell Notes From The Field</title><link rel="alternate" type="text/html" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/09/15/active-directory-powershell-notes-from-the-field.aspx" /><link rel="enclosure" type="application/octet-stream" length="4251754" href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-03-51-88-20/PSSAT002.zip" /><id>http://blogs.technet.com/b/ashleymcglone/archive/2012/09/15/active-directory-powershell-notes-from-the-field.aspx</id><published>2012-09-15T05:00:00Z</published><updated>2012-09-15T05:00:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/1715.image_5F00_097A9F25.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-84-58-metablogapi/0257.image_5F00_thumb_5F00_330E6A58.png" width="601" height="119" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;PowerShell Saturday 002&lt;/h3&gt;
&lt;p&gt;Today I have the privilege of speaking at the second-ever &lt;a title="PowerShell Saturday" href="http://powershellsaturday.com/002/" target="_blank"&gt;PowerShell Saturday&lt;/a&gt; event.&amp;nbsp; As a Microsoft Premier Field Engineer I get to meet many customers and help them with their &lt;strong&gt;Active Directory&lt;/strong&gt; and &lt;strong&gt;PowerShell&lt;/strong&gt; needs. I&amp;rsquo;ve taken some of that experience and wrapped it into a presentation called &lt;em&gt;&lt;strong&gt;Active Directory PowerShell Notes From The Field&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The session includes these four topics:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using Active Directory PowerShell to find schema update history&lt;/li&gt;
&lt;li&gt;Using PowerShell to migrate DNS zones&lt;/li&gt;
&lt;li&gt;Using Active Directory PowerShell to remediate token size issues caused by SID history&lt;/li&gt;
&lt;li&gt;A brief look at what&amp;rsquo;s new in Active Directory PowerShell v3&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These notes from the field come from scripting that I've done to assist customers with real-world needs.&amp;nbsp; The purpose of the session is to demonstrate the power of PowerShell for automating Active Directory solutions for every-day scenarios AND to inspire you to learn PowerShell.&amp;nbsp; To help with the learning part I have included several resources here for your reading pleasure.&lt;/p&gt;
&lt;p&gt;Attached to the bottom of this post you will find a file containing the DNS sample code and a PDF of the PowerPoint presentation.&amp;nbsp; You can view these files&amp;nbsp;while you listen to the 75 minutes &lt;span style="background-color: #ffff00;"&gt;session recording &lt;a title="MP3 session recording" href="http://sdrv.ms/RkVJjl"&gt;&lt;span style="background-color: #ffff00;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;h3&gt;Resources&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Code from the presentation &lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="http://blogs.technet.com/b/ashleymcglone/archive/2012/01/05/how-to-find-ad-schema-update-history-using-powershell.aspx" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/01/05/how-to-find-ad-schema-update-history-using-powershell.aspx" target="_blank"&gt;Schema Updates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;DNS Migration - &lt;em&gt;Attached at the bottom of this blog post.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.technet.com/b/ashleymcglone/archive/tags/sid+history/" href="http://blogs.technet.com/b/ashleymcglone/archive/tags/sid+history/" target="_blank"&gt;SID History&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Active Directory PowerShell Documentation&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="http://technet.microsoft.com/library/hh852274.aspx" href="http://technet.microsoft.com/library/hh852274.aspx" target="_blank"&gt;AD DS Administration Cmdlets in Windows PowerShell&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;TechEd 2012 Sessions on Channel9 &lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/SIA312" href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/SIA312" target="_blank"&gt;What's New in Active Directory in Windows Server 2012&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/SIA404" href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/SIA404" target="_blank"&gt;Deep Dive on Windows Server Active Directory PowerShell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://channel9.msdn.com/search?term=teched+2012+powershell&amp;amp;type=Events" href="http://channel9.msdn.com/search?term=teched+2012+powershell&amp;amp;type=Events" target="_blank"&gt;List of All TechEd 2012 PowerShell Sessions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Books &lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118027310,miniSiteCd-SYBEX.html" href="http://www.wiley.com/WileyCDA/WileyTitle/productCd-1118027310,miniSiteCd-SYBEX.html" target="_blank"&gt;Automating Active Directory Administration with Windows PowerShell 2.0 (SYBEX) by Ken St. Cyr &amp;amp; Laura Hunter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;PowerShell Saturday 001&lt;/h3&gt;
&lt;p&gt;If you would like to download the demos and audio recording of my presentation at the first PowerShell Saturday back in March you can find that &lt;a title="http://blogs.technet.com/b/ashleymcglone/archive/2012/03/14/five-free-ways-to-script-active-directory-in-powershell-part-2.aspx" href="http://blogs.technet.com/b/ashleymcglone/archive/2012/03/14/five-free-ways-to-script-active-directory-in-powershell-part-2.aspx" target="_blank"&gt;here&lt;/a&gt;.&amp;nbsp; In that session I covered &lt;em&gt;Five Free Ways To Script Active Directory&lt;/em&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3518820" width="1" height="1"&gt;</content><author><name>Ashley McGlone</name><uri>http://blogs.technet.com/Ashley-McGlone/ProfileUrlRedirect.ashx</uri></author><category term="PowerShell" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell/" /><category term="AD" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/AD/" /><category term="Active Directory" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/Active+Directory/" /><category term="v3" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/v3/" /><category term="PowerShell Saturday" scheme="http://blogs.technet.com/b/ashleymcglone/archive/tags/PowerShell+Saturday/" /></entry></feed>