<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Dmitry's PowerBlog: PowerShell and beyond &#187; oneliner</title>
	<atom:link href="http://dmitrysotnikov.wordpress.com/category/oneliner/feed/" rel="self" type="application/rss+xml" />
	<link>http://dmitrysotnikov.wordpress.com</link>
	<description>Dmitry Sotnikov's view on PowerShell, PowerGUI and everything he sees around</description>
	<lastBuildDate>Mon, 30 Nov 2009 11:00:31 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='dmitrysotnikov.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/930c8793b5aed06d07140b3be0db9d23?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Dmitry's PowerBlog: PowerShell and beyond &#187; oneliner</title>
		<link>http://dmitrysotnikov.wordpress.com</link>
	</image>
			<item>
		<title>Find large objects in AD</title>
		<link>http://dmitrysotnikov.wordpress.com/2009/06/08/find-large-objects-in-ad/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2009/06/08/find-large-objects-in-ad/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 10:00:34 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=1256</guid>
		<description><![CDATA[How do you find the user accounts which take up the most space in Active Directory database?
I have just had this very question from a customer who has some BLOB attributes added to user objects and suspect that some of these got much bigger than the others. As result, the overall AD database is now [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=1256&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>How do you find the user accounts which take up the most space in Active Directory database?</p>
<p>I have just had this very question from a customer who has some BLOB attributes added to user objects and suspect that some of these got much bigger than the others. As result, the overall AD database is now way bigger than the customer would like to have (affecting performance, backups, replication, and so on.)</p>
<p>The problem they had is finding these objects.</p>
<p>My first reaction was: just do a <code><a href="http://wiki.powergui.org/index.php/Get-QADUser">Get-QADUser</a></code> and sort the objects by size &#8211; how much easier can it get? Well, the problem is that there is just <a href="http://www.eggheadcafe.com/community/aspnet/2/9568/here-is-what-chris-brumme.aspx">no SizeOf function in PowerShell</a> &#8211; the system would not tell you how big a given object is.</p>
<p>The workaround I found was very simple. If we cannot get the in-memory size of an object &#8211; we can still export it to a file and measure the file size. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So here is my script:</p>
<pre><span style="color:#008000;">#</span><span style="color:#008000;"> Use a different value of SizeLimit </span><span style="color:#008000;">
#</span><span style="color:#008000;"> if you want a subset of accounts to test the script</span><span style="color:#008000;">
</span><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SizeLimit</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-IncludeAllProperties</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">ForEach</span><span style="color:#000000;"> {
    </span><span style="color:#000080;">$_</span><span style="color:#000000;"> |  </span><span style="color:#5F9EA0;font-weight:bold;">Export-Clixml</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">$($_.samAccountName).xml</span><span style="color:#800000;">"</span><span style="color:#000000;">
}
</span><span style="color:#5F9EA0;font-weight:bold;">dir</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">sort</span><span style="color:#000000;"> </span><span style="color:#800000;">Length</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Descending</span></pre>
<p>In a nutshell, all it does is goes through all AD user accounts, and exports each into xml file.</p>
<p>Then I just sort them by size.</p>
<p>The cool part about using ForEach-Object and not keeping all objects in an array is that this is actually very efficient from memory consumption perspective &#8211; <a href="http://dmitrysotnikov.wordpress.com/2007/07/24/optimize-powershell-performance-and-memory-consumption/">each object gets cleared from memory after it is saved to xml</a>.</p>
<p>Throughout running the script powershell.exe process was consuming only about 30-40MB of RAM.</p>
<p>One thing to note is that in most domains this script will take a long time to execute (hours). You can make it faster if you can limit the scope of Get-QADUser either by some attributes (SearchRoot, Enabled/Disabled, City, and so on) or properties (I was retrieving all, but if you actually know which properties contribute the most to the size you can include just these properties.) Again, see <a href="http://dmitrysotnikov.wordpress.com/2007/07/24/optimize-powershell-performance-and-memory-consumption/">this post for more consideration on optimizing the script</a>.</p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for cmdlets">cmdlets</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F;title=Find%20large%20objects%20in%20AD" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Find%20large%20objects%20in%20AD&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F&amp;Title=Find%20large%20objects%20in%20AD" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F&amp;title=Find%20large%20objects%20in%20AD" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F&amp;title=Find%20large%20objects%20in%20AD" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Find%20large%20objects%20in%20AD&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2009%2F06%2F08%2Ffind%2Dlarge%2Dobjects%2Din%2Dad%2F" target="_blank">Furl</a> |  </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/1256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/1256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/1256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/1256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/1256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/1256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/1256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/1256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/1256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/1256/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=1256&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2009/06/08/find-large-objects-in-ad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>AD cmdlets for object undelete</title>
		<link>http://dmitrysotnikov.wordpress.com/2009/05/07/ad-cmdlets-for-object-undelete/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2009/05/07/ad-cmdlets-for-object-undelete/#comments</comments>
		<pubDate>Thu, 07 May 2009 22:01:24 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=1181</guid>
		<description><![CDATA[Another great new feature in Quest&#8217;s free AD cmdlets 1.2 is ability to locate deleted (tombstoned) Active Directory objects and restore them back.
Locating is very straight-forward: you just add the -Tombstone switch to the Get-* cmdlet of your choice and now your query searches deleted rather than live objects.
Restoring is even easier &#8211; all you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=1181&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Another great new feature in Quest&#8217;s free <a href="http://dmitrysotnikov.wordpress.com/2009/04/10/ad-cmdlets-reference-updated/">AD cmdlets 1.2</a> is ability to locate deleted (<a href="http://technet.microsoft.com/en-us/magazine/cc137800.aspx">tombstoned</a>) Active Directory objects and restore them back.</p>
<p>Locating is very straight-forward: you just add the -Tombstone switch to the Get-* cmdlet of your choice and now your query searches deleted rather than live objects.</p>
<p>Restoring is even easier &#8211; all you need is pipeline the deleted objects into <a title="Restore-QADDeletedObject" href="http://wiki.powergui.org/index.php/Restore-QADDeletedObject"><code>Restore-QADDeletedObject</code></a>.</p>
<p>And the best thing of all is that this works great with Windows 2003 Active Directory &#8211; so you can start taking advantage of the feature right away!</p>
<p>For example:</p>
<p><code># List all tombstoned user accounts</code><br />
<code>Get-QADUser -Tombstone</code></p>
<p><code># Restore accounts deleted from a specific OU</code><br />
<code>Get-QADUser -Tombstone  -LastKnownParent 'OU=People,DC=company,dc=local' | Restore-QADDeletedObject</code></p>
<p><code># Restore accounts deleted today</code><br />
<code>Get-QADUser -Tombstone  –LastChangedOn (get-date) | Restore-QADDeletedObject</code></p>
<p><code># Restore a specific deleted user</code><br />
<code>Get-QADUser -Tombstone –Name 'John Smith*' | Restore-QADDeletedObject</code></p>
<p>One gotcha to keep in mind is that when objects are tombstoned computer and user objects are stored in AD exactly the same way. This makes <a href="http://wiki.powergui.org/index.php/Get-QADUser">Get-QADUser</a> actually return both user and computer objects. <a href="http://blogs.microsoft.co.il/blogs/ScriptFanatic/">Shay</a> found this workaround to make sure that only user objects are returned:</p>
<p><code># Return all tombstoned user accounts but no computer objects</code><br />
<code>Get-QADUser -Tombstone -SizeLimit 0 -ldap '(&amp;(!samAccountName=*$))'</code></p>
<p>Other Get-* cmdlets which now have these -Tombstone and -LastKnownParent parameters are:<a title="Get-QADComputer" href="http://wiki.powergui.org/index.php/Get-QADComputer"></a></p>
<ul>
<li><a title="Get-QADComputer" href="http://wiki.powergui.org/index.php/Get-QADComputer">Get-QADComputer</a></li>
<li><a title="Get-QADGroup" href="http://wiki.powergui.org/index.php/Get-QADGroup">Get-QADGroup</a></li>
<li><a title="Get-QADObject" href="http://wiki.powergui.org/index.php/Get-QADObject">Get-QADObject</a></li>
<li><a title="Get-QADPasswordSettingsObject" href="http://wiki.powergui.org/index.php/Get-QADPasswordSettingsObject">Get-QADPasswordSettingsObject</a></li>
</ul>
<p><a title="Get-QADUser" href="http://wiki.powergui.org/index.php/Get-QADUser"></a>For more information on what a tombstoned object is and how tombstone-based undelete is different from full recovery see <a href="http://technet.microsoft.com/en-us/magazine/cc137800.aspx">Gil’s article here</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/1181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=1181&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2009/05/07/ad-cmdlets-for-object-undelete/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>Update AD from CSV</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/10/03/update-active-directory-user-accounts-from-csv-file/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/10/03/update-active-directory-user-accounts-from-csv-file/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 08:00:58 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=697</guid>
		<description><![CDATA[Suppose you have a CSV file (a text file with columns separated by commas) with the properties for AD user accounts you want to update. How do you do this in PowerShell?
Turns out, that we talked a lot about creating new accounts from CSV files before, but not about updating existing ones. Let&#8217;s fix this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=697&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Suppose you have a CSV file (a text file with columns separated by commas) with the properties for AD user accounts you want to update. How do you do this in PowerShell?</p>
<p>Turns out, that we talked a lot about <a href="http://dmitrysotnikov.wordpress.com/2008/01/21/ad-user-provisioning-from-csv-got-easier/">creating new accounts from CSV files</a> before, but not about updating existing ones. Let&#8217;s fix this right away.</p>
<p>I will be using AD user accounts in my examples, but it is fairly easy to adapt them to other AD objects: groups, computers, OUs, DNS records, and so on.</p>
<p>The command actually depends on the CSV you get. The easiest case is when the column names are exactly the same as <a href="http://wiki.powergui.org/index.php/Set-QADUser">Set-QADUser parameters</a>. For example, let&#8217;s say you have a CSV file in which you have a <code>samAccountName </code>column which you want to use to locate the accounts to update and <code>Title </code>and <code>Department </code>columns with the new values to set:</p>
<p><code>samAccountName,Title,Department</code><br />
<code>test1,Manager,Accounting</code><br />
<code>test2,Developer,RD</code><br />
<code>test3,SC,Pre-Sales</code></p>
<p>The onliner to apply this file to your AD is as simple as:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Import-Csv</span><span style="color:#000000;"> </span><span style="color:#800000;">c</span><span style="color:#000000;">:\</span><span style="color:#800000;">update.csv</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">Set-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Identity</span><span style="color:#000000;"> { </span><span style="color:#000080;">$_</span><span style="color:#000000;">.samAccountName }</span></p>
<p>You basically pipe import into <span style="color:#5F9EA0;font-weight:bold;">Set-QADUser</span> and specify which column to use as the identity anchor.</p>
<p>Easy!</p>
<p>Now, suppose that life is not so easy and either you do not control the column labels or you need to update attributes which either do not match the parameter names or have no matching parameters at all. Like:</p>
<p><code>samAccountName,Job,ExtensionAttribute1,ExtensionAttribute2</code><br />
<code>test1,Manager,M,Yes</code><br />
<code>test2,Developer,S,No</code><br />
<code>test3,SC,XXL,Maybe</code></p>
<p>The automated column matching will not work here but we can use ForEach-Object loop and match the parameters manually + use ObjectAttributes for attributes with no parameters:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Import-Csv</span><span style="color:#000000;"> </span><span style="color:#800000;">c</span><span style="color:#000000;">:\</span><span style="color:#800000;">update.csv</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">ForEach-Object</span><span style="color:#000000;"> {<br />
    </span><span style="color:#5F9EA0;font-weight:bold;">Set-QADUser</span><span style="color:#000000;"> </span><span style="color:#000080;">$_</span><span style="color:#000000;">.samAccountName </span><span style="color:#5F9EA0;font-style:italic;">-Title</span><span style="color:#000000;"> </span><span style="color:#000080;">$_</span><span style="color:#000000;">.Job </span><span style="color:#5F9EA0;font-weight:bold;">`</span><span style="color:#000000;"><br />
    </span><span style="color:#5F9EA0;font-style:italic;">-ObjectAttributes</span><span style="color:#000000;"> @{ExtensionAttribute1</span><span style="color:#FF0000;">=</span><span style="color:#000000;">(</span><span style="color:#000080;">$_</span><span style="color:#000000;">.ExtensionAttribute1);<br />
                        ExtensionAttribute2</span><span style="color:#FF0000;">=</span><span style="color:#000000;">(</span><span style="color:#000080;">$_</span><span style="color:#000000;">.ExtensionAttribute2)}<br />
}<br />
</span></p>
<p>Now we can update from CSV any account properties we want!</p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/Examples" target="_blank" rel="tag" title="Link to Technorati Tag category for Examples">Examples</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for cmdlets">cmdlets</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F;title=Update%20AD%20from%20CSV" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Update%20AD%20from%20CSV&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F&amp;Title=Update%20AD%20from%20CSV" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F&amp;title=Update%20AD%20from%20CSV" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F&amp;title=Update%20AD%20from%20CSV" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Update%20AD%20from%20CSV&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F10%2F03%2Fupdate%2Dactive%2Ddirectory%2Duser%2Daccounts%2Dfrom%2Dcsv%2Dfile%2F" target="_blank">Furl</a> |  </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/697/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=697&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/10/03/update-active-directory-user-accounts-from-csv-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>List all Constructed Attributes</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/08/11/list-all-active-directorycomputed-attributes/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/08/11/list-all-active-directorycomputed-attributes/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 11:45:14 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=524</guid>
		<description><![CDATA[Constructed (or computed) Attributes are an important part of the way Active Directory is functioning. Basically, these are not real attributes, in the sense that they do not really exist, but are calculated by AD when being queried. They contain very useful info (for example well known primaryGroupToken and modifyTimeStamp) but they obviously have a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=524&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Constructed (or computed) Attributes are an important part of the way Active Directory is functioning. Basically, these are not real attributes, in the sense that they do not really exist, but are calculated by AD when being queried. They contain very useful info (for example well known primaryGroupToken and modifyTimeStamp) but they obviously <a href="https://blogs.technet.com/efleis/archive/2004/11/17/258710.aspx">have a few limitations</a> such as not being &#8220;settable&#8221; or not available for filtering, so knowing which are which is quite useful!</p>
<p>Here&#8217;s how you get a list of all computed attributes in your AD:</p>
<p style="text-align:left;"><span style="font-weight:bold;color:#5f9ea0;">Get-QADObject</span><span style="color:#000000;"> </span><span style="font-style:italic;color:#5f9ea0;">-SearchRoot</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">CN=Schema,CN=Configuration,dc=MyDomain,dc=COM</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="font-style:italic;color:#5f9ea0;">-Type</span><span style="color:#000000;"> </span><span style="color:#800000;">attributeSchema</span><span style="color:#000000;"> </span><span style="font-style:italic;color:#5f9ea0;">-IncludedProperties</span><span style="color:#000000;"> </span><span style="color:#800000;">systemFlags</span><span style="color:#000000;"> </span><span style="font-style:italic;color:#5f9ea0;">-SizeLimit</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;"> | </span><span style="color:#0000ff;">where</span><span style="color:#000000;"> {</span><span style="color:#000080;">$_</span><span style="color:#000000;">.SystemFlags </span><span style="color:#ff0000;">-band</span><span style="color:#000000;"> </span><span style="color:#000000;">4</span><span style="color:#000000;">}</span></p>
<p>Basically, this one-liner retrieves all (<code>-SizeLimit 0</code>) attributes (<code>-type attributeSchema</code>) from the Schema partition (<code>-SearchRoot "CN=Schema,CN=Configuration,dc=MyDomain,dc=COM"</code>), together with their system flags (<code>-IncludedProperties systemFlags</code>), and leaves just the ones with <a href="http://msdn.microsoft.com/en-us/library/cc199140.aspx">FLAG_ATTR_IS_CONSTRUCTED</a> (<code>where {$_.SystemFlags -band 4}</code>).</p>
<p>Thanks to Andrey Moiseev who shared this with me recently!</p>
<p>[UPDATE] Check out Aleksandar&#8217;s post on making this oneliner <a href="http://powershellers.blogspot.com/2008/08/ldap-query-versus-where.html">run 40 times faster</a>. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span class="technoratitag">Tags: <a title="Link to Technorati Tag category for AD" rel="tag" href="http://www.technorati.com/tag/AD" target="_blank">AD</a>, <a title="Link to Technorati Tag category for AD cmdlets" rel="tag" href="http://www.technorati.com/tag/AD+cmdlets" target="_blank">AD cmdlets</a>, <a title="Link to Technorati Tag category for Active Directory" rel="tag" href="http://www.technorati.com/tag/Active+Directory" target="_blank">Active Directory</a>, <a title="Link to Technorati Tag category for Examples" rel="tag" href="http://www.technorati.com/tag/Examples" target="_blank">Examples</a>, <a title="Link to Technorati Tag category for PowerShell" rel="tag" href="http://www.technorati.com/tag/PowerShell" target="_blank">PowerShell</a>, <a title="Link to Technorati Tag category for cmdlets" rel="tag" href="http://www.technorati.com/tag/cmdlets" target="_blank">cmdlets</a>, <a title="Link to Technorati Tag category for one-liner" rel="tag" href="http://www.technorati.com/tag/one-liner" target="_blank">one-liner</a>, <a title="Link to Technorati Tag category for oneliner" rel="tag" href="http://www.technorati.com/tag/oneliner" target="_blank">oneliner</a></span><br />
<span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F;title=List%20all%20Computed%20Attributes" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=List%20all%20Computed%20Attributes&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F&amp;Title=List%20all%20Computed%20Attributes" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F&amp;title=List%20all%20Computed%20Attributes" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F&amp;title=List%20all%20Computed%20Attributes" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=List%20all%20Computed%20Attributes&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F08%2F11%2Flist%2Dall%2Dactive%2Ddirectorycomputed%2Dattributes%2F" target="_blank">Furl</a> | </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/524/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/524/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/524/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=524&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/08/11/list-all-active-directorycomputed-attributes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding the latest logon time</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/07/18/finding-the-latest-logon-time/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/07/18/finding-the-latest-logon-time/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 10:00:30 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=437</guid>
		<description><![CDATA[How do you find out when was the last time a particular user logged on?
(Get-QADUser username).lastLogon looks like an obvious answer but there are a few gotchas to be aware of.
The main of them: lastLogon attribute is actually not replicated between domain controllers so if you have more than one DC (which I am sure [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=437&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>How do you find out when was the last time a particular user logged on?</p>
<p><code>(Get-QADUser username).lastLogon</code> looks like an obvious answer but there are a few gotchas to be aware of.</p>
<p>The main of them: <code>lastLogon </code>attribute is actually not replicated between domain controllers so if you have more than one DC (which I am sure you do) you need to get it from all of them and get the latest of them.</p>
<p>Here&#8217;s the PowerShell code which does that:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADComputer</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-ComputerRole</span><span style="color:#000000;"> </span><span style="color:#800000;">DomainController</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">foreach</span><span style="color:#000000;"> {<br />
    (</span><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Service</span><span style="color:#000000;"> </span><span style="color:#000080;">$_</span><span style="color:#000000;">.Name </span><span style="color:#5F9EA0;font-style:italic;">-SamAccountName</span><span style="color:#000000;"> </span><span style="color:#800000;">username</span><span style="color:#000000;">).LastLogon.Value<br />
} | Measure-Latest</span></p>
<p>Basically, we are getting a list of all DCs in the company, then prompting each of them for the user&#8217;s lastLogon time, and then picking the latest of the values (<a href="http://dmitrysotnikov.wordpress.com/2008/07/16/measure-latest-finding-the-latest-date-time/">I am using my Measure-Latest function</a> &#8211; just copy/paste if before executing this command or put in your script.)</p>
<p>Note that there are utilities which can do that querying and comparison for you. <a href="http://www.netwrix.com/inactive_users_tracker_powershell.html">NetWrix guys even have a PowerShell cmdlet described here</a>, so you can do something like:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-NCInactiveUsers</span><span style="color:#5F9EA0;font-style:italic;"> -domain</span><span style="color:#800000;"> example.com</span><span style="color:#5F9EA0;font-style:italic;"> -days</span><span style="color:#800000;"> 15</span></p>
<p>You should also keep in mind that if your users do not log off and simply lock their workstations they do not log on either &#8211; Kuma is <a href="http://powergui.org/message.jspa?messageID=20708#20708">describing here how he has a script logging off users every night to avoid this</a>.</p>
<p>Another alternative is using <code>lastLogonTimeStamp</code> attribute instead. This one does indeed get replicated. It was introduced in Windows 2003 (make sure your schema is 2003-level or later). But keep in mind that this one is not real-time as <a href="http://msdn.microsoft.com/en-us/library/ms676824.aspx">it is only replicated every 9-14 days</a>.</p>
<p>So as long as you are looking for users who have not logged on for something bigger than 2 weeks you should be good using <a href="http://powergui.org/message.jspa?messageID=19348#19348">Shay&#8217;s script for locating inactive users</a>:</p>
<p><span style="color:#800080;">$now</span><span style="color:#000000;">=</span><span style="color:#5F9EA0;font-weight:bold;">get-date</span><span style="color:#000000;"><br />
</span><span style="color:#800080;">$daysSinceLastLogon</span><span style="color:#000000;">=</span><span style="color:#000000;">60</span><span style="color:#000000;"></p>
<p></span><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-sizeLimit</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;"> | </span><span style="color:#0000FF;">where</span><span style="color:#000000;"> {<br />
    </span><span style="color:#000080;">$_</span><span style="color:#000000;">.lastlogontimestamp.value </span><span style="color:#FF0000;">-and</span><span style="color:#000000;"> ((</span><span style="color:#800080;">$now</span><span style="color:#FF0000;">-</span><span style="color:#000080;">$_</span><span style="color:#000000;">.lastlogontimestamp.value).days </span><span style="color:#FF0000;">-gt</span><span style="color:#000000;"> </span><span style="color:#800080;">$daysSinceLastLogon</span><span style="color:#000000;">)<br />
} </span> | <span style="color:#5F9EA0;font-weight:bold;">Format-Table</span><span style="color:#000000;"> </span><span style="color:#800000;">Name</span><span style="color:#000000;">, </span><span style="color:#800000;">LastLogonTimeStamp</span></p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime;title=Finding%20the%20latest%20logon%20time" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Finding%20the%20latest%20logon%20time&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime&amp;Title=Finding%20the%20latest%20logon%20time" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime&amp;title=Finding%20the%20latest%20logon%20time" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime&amp;title=Finding%20the%20latest%20logon%20time" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Finding%20the%20latest%20logon%20time&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F07%2F18%2Ffinding%2Dthe%2Dlatest%2Dlogon%2Dtime" target="_blank">Furl</a> |  </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/437/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/437/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/437/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/437/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/437/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=437&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/07/18/finding-the-latest-logon-time/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>AD undelete cmdlets</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/06/05/ad-undelete-cmdlets-and-free-ui/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/06/05/ad-undelete-cmdlets-and-free-ui/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 07:00:49 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Freeware]]></category>
		<category><![CDATA[PowerGUI]]></category>
		<category><![CDATA[PowerPack]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=393</guid>
		<description><![CDATA[Darren has just posted a couple of cmdlets that let you list recently deleted AD objects and restore the ones you want back.
Get-SDMADTombstones -Filter Evans &#124; Restore-SDMADTombstones
Very cool! You can download them from SDM Software freeware page.
And if you are still not sure about using this in a command line, I have hacked together a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=393&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Darren <a href="http://sdmsoftware.com/blog/2008/06/powershell_hits_the_morgue.html">has just posted</a> a couple of cmdlets that let you list recently deleted AD objects and restore the ones you want back.</p>
<p><code>Get-SDMADTombstones -Filter Evans | Restore-SDMADTombstones</code></p>
<p>Very cool! You can download them from <a href="http://www.sdmsoftware.com/freeware">SDM Software freeware page</a>.</p>
<p>And if you are still not sure about using this in a command line, I have hacked together a simple PowerGUI pack on top of Darren&#8217;s snapin: </p>
<p><a href="http://dmitrysotnikov.files.wordpress.com/2008/06/tombstone-reanimation.png"><img src="http://dmitrysotnikov.files.wordpress.com/2008/06/tombstone-reanimation.png?w=300&#038;h=152" alt="AD Tombstone Reanimation cmdlets inside PowerGUI" width="300" height="152" class="alignnone size-medium wp-image-394" /></a></p>
<p>The <a href="http://powergui.org/entry.jspa?externalID=1915&amp;categoryID=21">AD tombstone reanimation pack is available for download</a> from the PowerGUI library. Now you have free command line <em>and</em> free admin UI to handle AD tombstone reanimation!</p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/Examples" target="_blank" rel="tag" title="Link to Technorati Tag category for Examples">Examples</a>, <a href="http://www.technorati.com/tag/Freeware" target="_blank" rel="tag" title="Link to Technorati Tag category for Freeware">Freeware</a>, <a href="http://www.technorati.com/tag/PowerGUI" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerGUI">PowerGUI</a>, <a href="http://www.technorati.com/tag/PowerPack" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerPack">PowerPack</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for cmdlets">cmdlets</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F;title=AD%20undelete%20cmdlets%20and%20free%20UI" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=AD%20undelete%20cmdlets%20and%20free%20UI&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F&amp;Title=AD%20undelete%20cmdlets%20and%20free%20UI" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F&amp;title=AD%20undelete%20cmdlets%20and%20free%20UI" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F&amp;title=AD%20undelete%20cmdlets%20and%20free%20UI" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=AD%20undelete%20cmdlets%20and%20free%20UI&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F05%2Fad%2Dundelete%2Dcmdlets%2Dand%2Dfree%2Dui%2F" target="_blank">Furl</a> |  </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/393/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/393/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/393/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=393&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/06/05/ad-undelete-cmdlets-and-free-ui/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>

		<media:content url="http://dmitrysotnikov.files.wordpress.com/2008/06/tombstone-reanimation.png?w=300" medium="image">
			<media:title type="html">AD Tombstone Reanimation cmdlets inside PowerGUI</media:title>
		</media:content>
	</item>
		<item>
		<title>Find and fix broken inheritance</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/06/04/find-and-fix-broken-inheritance/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/06/04/find-and-fix-broken-inheritance/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 07:00:34 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Exchange 2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=392</guid>
		<description><![CDATA[Broken permissions inheritance can be a source of multiple issues &#8211; with PowerShell you can get such issues located and fixed with an easy oneliner. 
Getting security inheritance blocked is easy &#8211; locating and setting it back can be hard. One big customer of ours once had most of their mail transport paralyzed with a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=392&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Broken permissions inheritance can be a source of multiple issues &#8211; with PowerShell you can get such issues located and fixed with an easy oneliner. </p>
<p>Getting security inheritance blocked is easy &#8211; locating and setting it back can be hard. One big customer of ours once had most of their mail transport paralyzed with a branch administrator clearing the inherit permissions checkbox he thought should not have been there. <a href="http://blankmanblog.spaces.live.com/blog/cns!D0A1CD5B821F0EF9!257.entry">Nicolas is reporting similar issues with Exchange 2007 deployments</a>.</p>
<p>Seeing whether an AD object has permissions inheritance blocked is as easy as checking the object&#8217;s <code>DirectoryEntry.psbase.ObjectSecurity.AreAccessRulesProtected</code> property.</p>
<p>So for example, to get a list of all users in the domain who has inheritance off you just need to run:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SizeLimit</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;"> | </span><span style="color:#0000FF;">where</span><span style="color:#000000;"> {</span><span style="color:#000080;">$_</span><span style="color:#000000;">.DirectoryEntry.psbase.ObjectSecurity.AreAccessRulesProtected}</span></p>
<p>I am using <span style="color:#5F9EA0;font-style:italic;">-SizeLimit</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span> so I retrieve all users and not just the default 1000.</p>
<p>Fixing inheritance is even easier with the new <code>Set-QADObjectSecurity</code> cmdlet introduced in <a href="http://dmitrysotnikov.wordpress.com/2008/05/02/whats-new-in-ad-cmdlets-110/">AD cmdlets 1.1</a>.</p>
<p>So if you want to fix inheritance for all AD users (caution: you might want to just get the list of the accounts first using the command above to make sure you do not &#8220;fix&#8221; legitimate exceptions) you just need to pipe the collection into <span style="color:#5F9EA0;font-weight:bold;">Set-QADObjectSecurity</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-UnlockInheritance</span>:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SizeLimit</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;"> | </span><span style="color:#0000FF;">where</span><span style="color:#000000;"> {</span><span style="color:#000080;">$_</span><span style="color:#000000;">.DirectoryEntry.psbase.ObjectSecurity.AreAccessRulesProtected} | </span><span style="color:#5F9EA0;font-weight:bold;">Set-QADObjectSecurity</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-UnlockInheritance</span></p>
<p>Easy!</p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/Examples" target="_blank" rel="tag" title="Link to Technorati Tag category for Examples">Examples</a>, <a href="http://www.technorati.com/tag/Exchange" target="_blank" rel="tag" title="Link to Technorati Tag category for Exchange">Exchange</a>, <a href="http://www.technorati.com/tag/Exchange+2007" target="_blank" rel="tag" title="Link to Technorati Tag category for Exchange 2007">Exchange 2007</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/Security" target="_blank" rel="tag" title="Link to Technorati Tag category for Security">Security</a>, <a href="http://www.technorati.com/tag/cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for cmdlets">cmdlets</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F;title=Find%20and%20fix%20broken%20inheritance" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Find%20and%20fix%20broken%20inheritance&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F&amp;Title=Find%20and%20fix%20broken%20inheritance" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F&amp;title=Find%20and%20fix%20broken%20inheritance" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F&amp;title=Find%20and%20fix%20broken%20inheritance" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Find%20and%20fix%20broken%20inheritance&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F06%2F04%2Ffind%2Dand%2Dfix%2Dbroken%2Dinheritance%2F" target="_blank">Furl</a> |  </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/392/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/392/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/392/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=392&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/06/04/find-and-fix-broken-inheritance/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>Changing AD permissions</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/05/30/changing-ad-permissions/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/05/30/changing-ad-permissions/#comments</comments>
		<pubDate>Fri, 30 May 2008 15:42:41 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=390</guid>
		<description><![CDATA[I&#8217;ve recently blogged about retrieving AD security with PowerShell, as you can probably guess for every Get-* there is a Set-* and AD cmdlets 1.1 provide you an easy way to change the permissions set on any AD object.
Add-QADPermission and Remove-QADPermission are your biggest friends here.
Well, obviously and the power of the PowerShell pipeline. My [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=390&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve recently blogged about <a href="http://dmitrysotnikov.wordpress.com/2008/05/13/read-active-directory-permissions/">retrieving AD security with PowerShell</a>, as you can probably guess for every Get-* there is a Set-* and <a href="http://dmitrysotnikov.wordpress.com/2008/05/02/whats-new-in-ad-cmdlets-110/">AD cmdlets 1.1</a> provide you an easy way to change the permissions set on any AD object.</p>
<p><code>Add-QADPermission</code> and <code>Remove-QADPermission</code> are your biggest friends here.</p>
<p>Well, obviously and the power of the PowerShell pipeline. My favorite example is copying permissions from one object to another with that simple oneliner:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;Dmitry Sotnikov&#8221;</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">Add-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;Evil Tween&#8221;</span><span style="color:#000000;"><br />
</span></p>
<p>This simple line is incredibly powerful. It takes all permissions directly set on the first objects and adds them onto the second one. Of course you could put <code>where </code>in the middle to do some filtering if you need.</p>
<p>Of course you can explicitly grant specific rights on specific objects. Suppose you want to give Administrator full control over an OU and everything in it. Easy:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Add-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">OU=Demo,DC=mydomain,DC=local</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Account</span><span style="color:#000000;"> </span><span style="color:#800000;">Administrator</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Rights</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">GenericAll</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"><br />
</span></p>
<p>You can use the <code>-Deny</code> parameter to deny access, -PropertySet to work with <a href="http://technet2.microsoft.com/windowsserver/en/library/2044d125-cfb2-428c-aa8c-c4e5ac007ba41033.mspx#BKMK_PropertySets">property sets</a> <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  and <code>-ApplyTo</code> to select whether you want to give rights only to this object or its children or any possible combination. So for example you could do:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Add-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">dirObjectIdentity</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Deny</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Account</span><span style="color:#000000;"> </span><span style="color:#800000;">trusteeIdentity</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Rights</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">WriteProperty</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-PropertySet</span><span style="color:#000000;"> (</span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">General-Information</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;">,</span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">Web-Information</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;">) </span><span style="color:#5F9EA0;font-style:italic;">-Property</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">samAccountName</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-ApplyTo</span><span style="color:#000000;"> </span><span style="color:#800000;">ThisObjectOnly</span><span style="color:#000000;"><br />
</span></p>
<p>You can also pipe any AD object into these cmdlets (<a href="http://dmitrysotnikov.wordpress.com/2008/05/13/read-active-directory-permissions/">similar to reading the objects</a>) for bulk operations:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-City</span><span style="color:#000000;"> </span><span style="color:#800000;">Orlando</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SecurityMask</span><span style="color:#000000;"> </span><span style="color:#800000;">Dacl</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">Add-QADPermission</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Account</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Rights</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">ReadProperty</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"><br />
</span></p>
<p>And, as you can easily guess <code>Remove-QADPermission</code> can delete any ACE in much the same way. For example, let&#8217;s remove all the Deny ACEs from a particular object:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">objectIdentity</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Deny</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">Remove-QADPermission</span></p>
<p>You can find more information and examples <a href="http://www.quest.com/activeroles_server/arms.aspx">in the user&#8217;s guide</a> and by typing <code>get-help</code> for any of these cmdlets.</p>
<p><a href="http://www.quest.com/activeroles_server/arms.aspx">Download the cmdlets</a> and give us your feedback <a href="http://powergui.org/forum.jspa?forumID=173">at the AD PowerShell discussion forums</a>.</p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/Examples" target="_blank" rel="tag" title="Link to Technorati Tag category for Examples">Examples</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/Security" target="_blank" rel="tag" title="Link to Technorati Tag category for Security">Security</a>, <a href="http://www.technorati.com/tag/cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for cmdlets">cmdlets</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F;title=Changing%20AD%20permissions" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Changing%20AD%20permissions&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F&amp;Title=Changing%20AD%20permissions" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F&amp;title=Changing%20AD%20permissions" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F&amp;title=Changing%20AD%20permissions" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Changing%20AD%20permissions&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F30%2Fchanging%2Dad%2Dpermissions%2F" target="_blank">Furl</a> |  </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/390/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/390/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/390/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=390&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/05/30/changing-ad-permissions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>Read Active Directory Permissions</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/05/13/read-active-directory-permissions/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/05/13/read-active-directory-permissions/#comments</comments>
		<pubDate>Tue, 13 May 2008 08:15:35 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Password management]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=367</guid>
		<description><![CDATA[One of the biggest advances of AD cmdlets 1.1 is support for AD security operations. In this post we will look at the Get-QADPermission cmdlet and how you can use it to read permissions set on AD objects.
To get a list of permissions set on an AD objects directly you just need to use:
Get-QADPermission Identity [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=367&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the biggest advances of <a href="http://dmitrysotnikov.wordpress.com/2008/05/02/whats-new-in-ad-cmdlets-110/">AD cmdlets 1.1</a> is support for AD security operations. In this post we will look at the <code>Get-QADPermission</code> cmdlet and how you can use it to read permissions set on AD objects.</p>
<p>To get a list of permissions set on an AD objects directly you just need to use:</p>
<p><code>Get-QADPermission <em>Identity</em></code> &#8211; where identity is Name, DN, Canonical name, Domain\Name, and so on. For example:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8216;</span></p>
<p>As usual you can pipeline a set of objects into the cmdlet to get results for all of them, e.g.:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SearchRoot</span><span style="color:#000000;"> </span><span style="color:#800000;">domain.local</span><span style="color:#000000;">/</span><span style="color:#800000;">employees</span><span style="color:#000000;">/</span><span style="color:#800000;">chicago</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SecurityMask</span><span style="color:#000000;"> </span><span style="color:#800000;">DACL</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"><br />
</span></p>
<p>Here I am getting access control for all permissions directly set on users in the <code>domain.local/employees/chicago</code> OU. Note that I am also using the <code>-SecurityMask</code> parameter to tell the <code>Get-QADUser</code> cmdlet to retrieve the access list (<code>DACL</code> &#8211; Discretionary Account Control List). This is optionally but highly recommended because if you use this parameter <code>Get-QADPermission</code> does not have to retrieve the DACL again &#8211; less calls to the DC, better performance.</p>
<p>The examples above deal only with the permissions set on the object directly, you can add inherited permissions by simply adding -Inherited. In a similar fashion, the <code>-SchemaDefault</code> parameter adds Account Control Entries (ACE) that came from the default security descriptor. So this will give you everything:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Inherited</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SchemaDefault</span></p>
<p>Or the same but much faster:<br />
<span style="color:#5F9EA0;font-weight:bold;">Get-QADUser</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Name</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SecurityMask</span><span style="color:#000000;"> </span><span style="color:#800000;">DACL</span><span style="color:#000000;"> | </span><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Inherited</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-SchemaDefault</span></p>
<p>You can look for the rights which specific trusties have:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Account</span><span style="color:#000000;"> (</span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">domain\bill</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;">, </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">self</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;">) </span><span style="color:#5F9EA0;font-style:italic;">-UseTokenGroups</span><span style="color:#000000;"><br />
</span></p>
<p>Note that I have added <code>-UseTokenGroups</code> to make sure I get Bill&#8217;s rights even if he got those via group membership.</p>
<p>Or for specific rights set on specific properties:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Rights</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">WriteProperty</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Property</span><span style="color:#000000;"> (</span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">samAccountName</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;">,</span><span style="color:#800000;">&#8216;</span><span style="color:#800000;">name</span><span style="color:#800000;">&#8216;</span><span style="color:#000000;">)<br />
</span></p>
<p>You can also check for extended rights. Let&#8217;s see if I can change my password:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Dmitry Sotnikov</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-account</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">self</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;">,</span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">everyone</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Allow</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-ExtendedRight</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">User-Change-Password</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-Inherited</span><span style="color:#000000;"> –</span><span style="color:#800000;">SchemaDefault</span><span style="color:#000000;"><br />
</span></p>
<p><code>-Allow</code> and <code>-Deny</code> parameters allow to check specifically for allowing and denying ACEs.</p>
<p>And there&#8217;s much much more: just check out:</p>
<p><span style="color:#5F9EA0;font-weight:bold;">get-help</span><span style="color:#000000;"> </span><span style="color:#800000;">Get-QADPermission</span><span style="color:#000000;"> </span><span style="color:#5F9EA0;font-style:italic;">-detailed</span><span style="color:#000000;"><br />
</span></p>
<p>Good job by the team trying to cover each and every case they could think of. If you can think of something they have not covered or implemented in a suboptimal way &#8211; please provide your feedback <a href="http://powergui.org/forum.jspa?forumID=173">in the AD PowerShell forum</a> &#8211; the team is there and listening.</p>
<p>Here&#8217;s the AD cmdlets download page which has the latest 1.1 beta drop.</p>
<p><span class="technoratitag">Tags: <a href="http://www.technorati.com/tag/AD" target="_blank" rel="tag" title="Link to Technorati Tag category for AD">AD</a>, <a href="http://www.technorati.com/tag/AD+cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for AD cmdlets">AD cmdlets</a>, <a href="http://www.technorati.com/tag/Active+Directory" target="_blank" rel="tag" title="Link to Technorati Tag category for Active Directory">Active Directory</a>, <a href="http://www.technorati.com/tag/Examples" target="_blank" rel="tag" title="Link to Technorati Tag category for Examples">Examples</a>, <a href="http://www.technorati.com/tag/Password+management" target="_blank" rel="tag" title="Link to Technorati Tag category for Password management">Password management</a>, <a href="http://www.technorati.com/tag/PowerShell" target="_blank" rel="tag" title="Link to Technorati Tag category for PowerShell">PowerShell</a>, <a href="http://www.technorati.com/tag/Security" target="_blank" rel="tag" title="Link to Technorati Tag category for Security">Security</a>, <a href="http://www.technorati.com/tag/cmdlets" target="_blank" rel="tag" title="Link to Technorati Tag category for cmdlets">cmdlets</a>, <a href="http://www.technorati.com/tag/one-liner" target="_blank" rel="tag" title="Link to Technorati Tag category for one-liner">one-liner</a>, <a href="http://www.technorati.com/tag/oneliner" target="_blank" rel="tag" title="Link to Technorati Tag category for oneliner">oneliner</a></span><br /><span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F;title=Read%20Active%20Directory%20Permissions" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Read%20Active%20Directory%20Permissions&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F&amp;Title=Read%20Active%20Directory%20Permissions" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F&amp;title=Read%20Active%20Directory%20Permissions" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F&amp;title=Read%20Active%20Directory%20Permissions" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Read%20Active%20Directory%20Permissions&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F05%2F13%2Fread%2Dactive%2Ddirectory%2Dpermissions%2F" target="_blank">Furl</a> |  </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/367/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/367/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/367/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=367&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/05/13/read-active-directory-permissions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
		<item>
		<title>Managing Terminal Services attributes with PowerShell</title>
		<link>http://dmitrysotnikov.wordpress.com/2008/02/13/managing-terminal-services-attributes-with-powershell/</link>
		<comments>http://dmitrysotnikov.wordpress.com/2008/02/13/managing-terminal-services-attributes-with-powershell/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 18:05:56 +0000</pubDate>
		<dc:creator>Dmitry Sotnikov</dc:creator>
				<category><![CDATA[AD]]></category>
		<category><![CDATA[AD cmdlets]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://dmitrysotnikov.wordpress.com/?p=320</guid>
		<description><![CDATA[Terminal Services properties is definitely a set of properties you would want to bulk-manage, and as we all know PowerShell is the best tool for any bulk operations.
We have recently (in the AD cmdlets 1.0.6 drop) improved the experience here (thanks to requests from Simon and George) and there are a few gotchas to keep [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=320&subd=dmitrysotnikov&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Terminal Services properties is definitely a set of properties you would want to bulk-manage, and as we all know PowerShell is the best tool for any bulk operations.</p>
<p>We have recently (in the <a href="http://dmitrysotnikov.wordpress.com/2007/12/20/ad-cmdlets-rtm/">AD cmdlets 1.0.6 drop</a>) improved the experience here (thanks to requests from <a href="http://powergui.org/thread.jspa?messageID=8603&amp;#8603">Simon</a> and <a href="http://powergui.org/thread.jspa?threadID=4815&amp;start=0&amp;tstart=0">George</a>) and there are a few gotchas to keep in mind &#8211; so I thought I would summarize this all in one blog post.</p>
<h3>Getting TS attributes</h3>
<p>Retrieving terminal services properties is easy. You just execute <code>Get-QADUser</code> and the objects retrieved will have the corresponding properties &#8211; for your convenience, all starting with Ts.</p>
<p><code>PS C:\&gt; get-qaduser "Dmitry Sotnikov" | format-list Ts*</code></p>
<p><code>TsProfilePath            : \\server\tsprofiles\DSotnikov</code><br />
<code>TsHomeDirectory          : \\server\tshome\DSotnikov</code><br />
<code>TsHomeDrive              : P:</code><br />
<code>TsAllowLogon             : True</code><br />
<code>TsRemoteControl          : 0</code><br />
<code>TsMaxDisconnectionTime   : 00:00:00</code><br />
<code>TsMaxConnectionTime      : 00:00:00</code><br />
<code>TsMaxIdleTime            : 00:00:00</code><br />
<code>TsReconnectionAction     : 1</code><br />
<code>TsBrokenConnectionAction : 0</code><br />
<code>TsConnectClientDrives    : True</code><br />
<code>TsConnectPrinterDrives   : True</code><br />
<code>TsDefaultToMainPrinter   : True</code><br />
<code>TsWorkDirectory          : c:\</code><br />
<code>TsInitialProgram         : C:\Program Files\Quest\Initialize.exe</code></p>
<p><strong>Important:</strong> Terminal services properties are only available when AD cmdlets are run on <strong>Windows Server 2003 or 2008</strong>. Workstation operating systems (XP, Vista) do not support programmatic TS administration so the properties will not be retrieved.</p>
<p><em><strong>[</strong></em><em><strong>Update</strong><strong>]</strong></em> See these <a href="http://dmitrysotnikov.wordpress.com/2008/07/23/system-requirements-for-powershell-terminal-services-management/">instructions on enabling Terminal Services management on XP and Vista</a>.</p>
<h3>Changing TS attributes</h3>
<p>TS properties are not (yet) available as Set-QADUser parameters and need to be changed as properties of retrived objects as shown in the example below:</p>
<p><code>$u = get-qaduser dsotnikov</code><br />
<code>$u.TsProfilePath = 'c:\profile'</code><br />
<code>$u.CommitChanges()</code></p>
<p><em><strong>[Update]</strong></em> With AD cmdlets 1.1.1 Set-QADUser exposes all the TS attributes as its parameters so changing TS attributes is now much easier:</p>
<p><code>get-qaduser -searchroot mydomain.local/uk/london | set-qaduser -TsHomeDrive 'P:'</code></p>
<p>Again, make sure you follow <a href="http://dmitrysotnikov.wordpress.com/2008/07/23/system-requirements-for-powershell-terminal-services-management/">the system requirements</a>.</p>
<h3>Property reference</h3>
<p>Here&#8217;s a quick reference to the properties (I borrowed some of the descriptions <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/iadstsuserex.asp">from the MSDN page</a>):</p>
<table border="1">
<tbody>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td><strong>TsProfilePath</strong></td>
<td>Roaming or mandatory profile path to use when the user logs on to the terminal server. The profile path is       in the following network path format:\\ServerName\<em>profiles folder name</em>\UserName</p>
<p class="note"><strong>Note</strong> A Terminal Services profile path is used only for logging on to a terminal server.</p>
</td>
</tr>
<tr>
<td><strong>TsHomeDirectory</strong></td>
<td>Home directory for the user. Each user on a terminal server has a unique home directory. This ensures that       application information is stored separately for each user in a multi-user environment.To set a home directory on the local computer, specify a local path; for example, C:\Path. To set a home       directory in a network environment, you must first set the       <strong>TsHomeDrive</strong> property, and then set this property to a UNC       path.</td>
</tr>
<tr>
<td><strong>TsHomeDrive</strong></td>
<td>Home drive for the user. In a network environment, this property is a string containing a drive       specification (a drive letter followed by a colon) to which the UNC path specified in the       <strong>TsHomeDirectory</strong> property is mapped.To set a home directory in a network environment, you must first set this property and then set the       <strong>TsHomeDirectory</strong> property.</td>
</tr>
<tr>
<td><strong>TsAllowLogon</strong></td>
<td>Value that specifies whether the user is allowed to log on to the terminal server.</td>
</tr>
<tr>
<td><strong>TsEnableRemoteControl</strong></td>
<td>Value that specifies whether to allow remote observation or remote control of the user&#8217;s Terminal Services       session. For a description of these values, see the       <a id="ctl00_rs1_mainContentContainer_ctl07" href="http://msdn2.microsoft.com/en-us/library/aa383818%28VS.85%29.aspx"><strong>RemoteControl</strong></a> method of       the <a id="ctl00_rs1_mainContentContainer_ctl08" href="http://msdn2.microsoft.com/en-us/library/aa383817%28VS.85%29.aspx"><strong>Win32_TSRemoteControlSetting</strong></a> WMI       class.</p>
<table class="clsStd" border="0">
<tbody>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<tr>
<td width="40%">Disable</td>
<td width="60%">0</td>
</tr>
<tr>
<td width="40%">EnableInputNotify</td>
<td width="60%">1</td>
</tr>
<tr>
<td width="40%">EnableInputNoNotify</td>
<td width="60%">2</td>
</tr>
<tr>
<td width="40%">EnableNoInputNotify</td>
<td width="60%">3</td>
</tr>
<tr>
<td width="40%">EnableNoInputNoNotify</td>
<td width="60%">4</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td><strong>TsMaxDisconnectionTime</strong></td>
<td>Maximum amount of time, in minutes, that a disconnected Terminal Services session remains active on the       terminal server. After the specified number of minutes have elapsed, the session is terminated.</td>
</tr>
<tr>
<td><strong>TsMaxConnectionTime</strong></td>
<td>Maximum duration, in minutes, of the Terminal Services session. After the specified number of minutes have       elapsed, the session can be disconnected or terminated.</td>
</tr>
<tr>
<td><strong>TsMaxIdleTime</strong></td>
<td>Maximum amount of time, in minutes, that the Terminal Services session can remain idle. After the specified       number of minutes have elapsed, the session can be disconnected or terminated.</td>
</tr>
<tr>
<td><strong>TsReconnectionAction</strong></td>
<td>Value that specifies whether to allow reconnection to a disconnected Terminal Services session from any       client computer. The value is 1 if reconnection is allowed from the original client computer only, and 0 if       reconnection from any client computer is allowed.</p>
<p class="note"><strong>Note</strong> This property currently is not used by Windows Server Terminal Services.</p>
</td>
</tr>
<tr>
<td><strong>TsBrokenConnectionAction</strong></td>
<td>Value that specifies the action to take when a Terminal Services session limit is reached. The value is 1 if       the client session should be terminated, and 0 if the client session should be disconnected.</td>
</tr>
<tr>
<td><strong>TsConnectClientDrivesAtLogon</strong></td>
<td>Value that specifies whether to reconnect to mapped client drives at logon. The value is 1 if reconnection       is enabled, and 0 if reconnection is disabled.</p>
<p class="note"><strong>Note</strong> This property currently is not used by Windows Server Terminal Services.</p>
</td>
</tr>
<tr>
<td><strong>TsConnectClientPrintersAtLogon</strong></td>
<td>Value that specifies whether to reconnect to mapped client printers at logon. The value is 1 if reconnection       is enabled, and 0 if reconnection is disabled.</td>
</tr>
<tr>
<td><strong>TsDefaultToMainPrinter</strong></td>
<td>Value that specifies whether to print automatically to the client&#8217;s default printer. The value is 1 if       printing to the client&#8217;s default printer is enabled, and 0 if it is disabled.</td>
</tr>
<tr>
<td><strong>TsWorkDirectory</strong></td>
<td>Working directory path for the user.To set an initial application to start when the user logs       on to the terminal server, you must first set the <strong>TsInitialProgram</strong> property, and then set this property.</td>
</tr>
<tr>
<td><strong>TsInitialProgram</strong></td>
<td>Path and file name of the application that the user wants to start automatically when the user logs on to the       terminal server.To set an initial application to start when the user logs on, you must first set this property and then set       the <strong>TsWorkDirectory</strong> property. If you set only the       <strong>TsInitialProgram</strong> property, the application starts in the user&#8217;s       session in the default user directory.</td>
</tr>
</tbody>
</table>
<p><span class="technoratitag">Tags: <a title="Link to Technorati Tag category for AD" rel="tag" href="http://www.technorati.com/tag/AD" target="_blank">AD</a>, <a title="Link to Technorati Tag category for AD cmdlets" rel="tag" href="http://www.technorati.com/tag/AD+cmdlets" target="_blank">AD cmdlets</a>, <a title="Link to Technorati Tag category for Active Directory" rel="tag" href="http://www.technorati.com/tag/Active+Directory" target="_blank">Active Directory</a>, <a title="Link to Technorati Tag category for Examples" rel="tag" href="http://www.technorati.com/tag/Examples" target="_blank">Examples</a>, <a title="Link to Technorati Tag category for cmdlets" rel="tag" href="http://www.technorati.com/tag/cmdlets" target="_blank">cmdlets</a>, <a title="Link to Technorati Tag category for one-liner" rel="tag" href="http://www.technorati.com/tag/one-liner" target="_blank">one-liner</a>, <a title="Link to Technorati Tag category for oneliner" rel="tag" href="http://www.technorati.com/tag/oneliner" target="_blank">oneliner</a></span><br />
<span class="sociallinks">Add to: | <a href="http://technorati.com/faves?add=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F" target="_blank">Technorati</a> |  <a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F" target="_blank">Digg</a> |  <a href="http://del.icio.us/post?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F;title=Managing%20Terminal%20Services%20attributes%20with%20PowerShell" target="_blank">del.icio.us</a> |  <a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=Managing%20Terminal%20Services%20attributes%20with%20PowerShell&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F" target="_blank">Yahoo</a> |  <a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F&amp;Title=Managing%20Terminal%20Services%20attributes%20with%20PowerShell" target="_blank">BlinkList</a> |  <a href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F&amp;title=Managing%20Terminal%20Services%20attributes%20with%20PowerShell" target="_blank">Spurl</a> |  <a href="http://reddit.com/submit?url=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F&amp;title=Managing%20Terminal%20Services%20attributes%20with%20PowerShell" target="_blank">reddit</a> |   <a href="http://www.furl.net/storeIt.jsp?t=Managing%20Terminal%20Services%20attributes%20with%20PowerShell&amp;u=http%3A%2F%2Fdmitrysotnikov%2Ewordpress%2Ecom%2F2008%2F02%2F13%2Fmanaging%2Dterminal%2Dservices%2Dattributes%2Dwith%2Dpowershell%2F" target="_blank">Furl</a> | </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmitrysotnikov.wordpress.com/320/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmitrysotnikov.wordpress.com/320/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmitrysotnikov.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmitrysotnikov.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmitrysotnikov.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmitrysotnikov.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmitrysotnikov.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmitrysotnikov.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmitrysotnikov.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmitrysotnikov.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmitrysotnikov.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmitrysotnikov.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmitrysotnikov.wordpress.com&blog=867377&post=320&subd=dmitrysotnikov&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmitrysotnikov.wordpress.com/2008/02/13/managing-terminal-services-attributes-with-powershell/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ecc57e2c1be48013620bf85fb983dbf?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmitrysotnikov</media:title>
		</media:content>
	</item>
	</channel>
</rss>