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

<channel>
	<title>vmweaver.com &#187; AD</title>
	<atom:link href="http://vmweaver.com/index.php/tag/ad/feed/" rel="self" type="application/rss+xml" />
	<link>http://vmweaver.com</link>
	<description>Mindless ramblings of a geek...</description>
	<lastBuildDate>Thu, 06 Oct 2011 20:42:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Powershell and AD Object Recovery (Prologue)</title>
		<link>http://vmweaver.com/index.php/2010/02/powershell-ad-recovery-prologue/</link>
		<comments>http://vmweaver.com/index.php/2010/02/powershell-ad-recovery-prologue/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 02:11:46 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[Recovery]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=229</guid>
		<description><![CDATA[I have been toying with an idea for a while since I have been diving deeper into Active Directory stuff with Powershell. The idea is to develop a full Active Directory object backup and recovery tool. There are several excellent tools available commercially that do this, but with IT staffs and budgets shrinking it is [...]]]></description>
			<content:encoded><![CDATA[<p>I have been toying with an idea for a while since I have been diving deeper into Active Directory stuff with Powershell.</p>
<p>The idea is to develop a full Active Directory object backup and recovery tool.  There are several excellent tools available commercially that do this, but with IT staffs and budgets shrinking it is often difficult to justify the cost.  </p>
<p>I am sure others have thought about it, maybe dabbled with it, but it seems to me that all of tools and components are available to do this, just that nobody (that I know of) has kind of glued them all together in an easy-to-use interface.</p>
<p>I know many of you may say &#8220;Hey, doesn&#8217;t Microsoft have an AD Recycle Bin now?&#8221;.  Well yes, they do&#8230;BUT many folks, I believe, are probably still running 2003 AD instances.  Regardless of all of that, though, this sounds like a good exercise to at least explore doing a larger-scale &#8220;application&#8221; using Powershell.</p>
<p>This will also be my first major dive in the Powershell V2.0, so I hope to be discovering new and interesting ways to put these tools together.</p>
<p>From my perspective, I see several main components that will need development:<br />
1. A user Interface.  While I have done some of this with &#8220;visual&#8221; languages and a touch with Powershell, I haven&#8217;t done anything very extensive.<br />
2. Interfacing with some type of database solution (probably SQL Server)<br />
3. Access to AD objects without 3rd party utilities. I think this will be fairly straightforward but  may end up using the Quest tools.<br />
4. Access to the &#8220;delete objects&#8221; container in the directory and a means to reanimate those objects.  (<a href="http://www.sdmsoftware.com/freeware.php">SDM Software Grou</a>p has some great cmdlets for doing this which I will probably look at using).<br />
5. General functions for manipulating AD objects (again&#8230;pretty easy)</p>
<p>One question keeps coming to mind, though is whether something like this would be useful?  I am not entirely sure, but I hope so!  To that end, I think the journey may be more worthwhile than the outcome.</p>
<p>Anyway, I hope to be spending more time with (when I *HAVE* spare time) and I hope to chronicle this &#8220;journey&#8221; here as I go.</p>
<p>If anyone has an opinion on this undertaking or has advice, please let me know.</p>
<p>Stay tuned for updates.  Right now I am standing up a small infrastructure at home to support this development effort.</p>
<p>Thanks and Happy Scripting!</p>
<p> &#8212; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2010/02/powershell-ad-recovery-prologue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell and FSMO Roles</title>
		<link>http://vmweaver.com/index.php/2009/11/powershell-and-fsmo-roles/</link>
		<comments>http://vmweaver.com/index.php/2009/11/powershell-and-fsmo-roles/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 16:37:38 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[FSMO]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=218</guid>
		<description><![CDATA[Okay, this will be a quick and dirty post due to lack of time right now. This one is kind of a tip, rather than a full-blown script or topic. Basically I was looking to grab which system was the PDC Emulator for my current domain (or NOT my current domain) and so I did [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, this will be a quick and dirty post due to lack of time right now.<br />
This one is kind of a tip, rather than a full-blown script or topic.  Basically I was looking to grab which system was the PDC Emulator for my current domain (or NOT my current domain) and so I did some google-ing and finally ended up with these little functions.   </p>
<p>All I need to do is pass in the DomainName and it spits out the info.  For the FSMO roles, it will return an object and for the DomainMode, just the text is returned.</p>
<p>Hopefully you will find them useful.<br />
That&#8217;s it for now&#8230;<br />
Happy Scripting..<br />
 &#8211; Mark</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">Function</span> get<span style="color: pink;">-</span>PDCERole <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #008000;">## Return the PDC Emulator Role Owner for the specified Domain</span>
   <span style="color: #800080;">$DomainContext</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.ActiveDirectory.DirectoryContext<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Domain&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$Domain</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.DirectoryServices.ActiveDirectory.Domain<span style="color: #000000;">&#93;</span>::GetDomain<span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainContext</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$PDCE</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Domain</span>.PDCRoleOwner
&nbsp;
   <span style="color: #0000FF;">Return</span> <span style="color: #800080;">$PDCE</span>  
  <span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">Function</span> get<span style="color: pink;">-</span>RIDMasterRole <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #008000;">## Return the RID Master Role Owner for the specified Domain</span>
   <span style="color: #800080;">$DomainContext</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.ActiveDirectory.DirectoryContext<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Domain&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$Domain</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.DirectoryServices.ActiveDirectory.Domain<span style="color: #000000;">&#93;</span>::GetDomain<span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainContext</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$RIDMaster</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Domain</span>.RIDRoleOwner
&nbsp;
   <span style="color: #0000FF;">Return</span> <span style="color: #800080;">$RIDMaster</span>
  <span style="color: #000000;">&#125;</span> 
&nbsp;
<span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>InfMasterRole <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #008000;">## Return the Infrastucture Master role owner for the specified Domain</span>
   <span style="color: #800080;">$DomainContext</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.ActiveDirectory.DirectoryContext<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Domain&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$Domain</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.DirectoryServices.ActiveDirectory.Domain<span style="color: #000000;">&#93;</span>::GetDomain<span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainContext</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$InfMaster</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Domain</span>.InfrastructureRoleOwner
&nbsp;
   <span style="color: #0000FF;">Return</span> <span style="color: #800080;">$InfMaster</span>
 <span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>DomainMode <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #008000;">## Return the Domain Mode for the specified Domain</span>
   <span style="color: #800080;">$DomainContext</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.ActiveDirectory.DirectoryContext<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Domain&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$DomainName</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$Domain</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.DirectoryServices.ActiveDirectory.Domain<span style="color: #000000;">&#93;</span>::GetDomain<span style="color: #000000;">&#40;</span><span style="color: #800080;">$DomainContext</span><span style="color: #000000;">&#41;</span>
   <span style="color: #800080;">$DomainMode</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Domain</span>.DomainMode
&nbsp;
   <span style="color: #0000FF;">Return</span> <span style="color: #800080;">$DomainMode</span>
&nbsp;
  <span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2009/11/powershell-and-fsmo-roles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell and Unknown User SIDs</title>
		<link>http://vmweaver.com/index.php/2009/10/powershell-and-unknown-user-sids/</link>
		<comments>http://vmweaver.com/index.php/2009/10/powershell-and-unknown-user-sids/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 18:01:19 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[User Management]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=204</guid>
		<description><![CDATA[Once again, my apologies for my lack of posting.. Anyway&#8230; An interesting thing came up at work the other day when one of my fellow administrators asked me if I could resolve an unknown SID he was seeing in some logs to see what the heck it belonged to. Since I had been telling him [...]]]></description>
			<content:encoded><![CDATA[<p>Once again, my apologies for my lack of posting..</p>
<p>Anyway&#8230;</p>
<p>An interesting thing came up at work the other day when one of my fellow administrators asked me if I could resolve an unknown SID he was seeing in some logs to see what the heck it belonged to.</p>
<p>Since I had been telling him that Powershell could do ANYTHING (slight exaggeration, I know)&#8230; that it should be able to do this.</p>
<p>Well, it certainly is an interesting notion.</p>
<p>I know that I have run into this in the past where you have file system ACLs set and there are a bunch of SIDs sitting in there that nobody seems to know who they belong to.</p>
<p>While it isn&#8217;t THAT important to resolve them since the user account is most likely no longer around, it IS an interesting thought exercise.</p>
<p>After perusing the web looking for others who have done something similar, I feel I had enough to throw something together..</p>
<p>Basically when an Active Directory object (like a user) is &#8220;deleted&#8221;, it is really just Tombstoned for a period of time and is moved to the hidden container &#8220;Deleted Objects&#8221; and then removed after like 90 days or so.</p>
<p>Here is my solution to &#8220;finding&#8221; those objects.</p>
<p>First you will have to know what Domain you want to look at for this object AND you have know the SID you are looking for.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">function</span> Resolve<span style="color: pink;">-</span>DeletedUserSID<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Domain</span><span style="color: pink;">,</span> <span style="color: #800080;">$UserSID</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;">## This is kind of a mashup of a few different scripts I found online in some forums.</span>
	<span style="color: #008000;">## Unfortunately I don't remember who did them.  If it was you, point me to your post and I will</span>
	<span style="color: #008000;">## give you the credit for your piece.</span>
	<span style="color: #008000;">## </span>
	<span style="color: #008000;">## Returns User information for deleted account with the specified SID and User Domain</span>
&nbsp;
	<span style="color: #800080;">$DomainRoot</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LDAP://&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Domain</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$DomainDN</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>adsi<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#40;</span> <span style="color: #800080;">$DomainRoot</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.DistinguishedName
	<span style="color: #800080;">$adspath</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LDAP://&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$DomainDN</span>
	<span style="color: #800080;">$root</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.Directoryentry<span style="color: #000000;">&#93;</span> <span style="color: #800080;">$Adspath</span>
	<span style="color: #800080;">$root</span>.psbase.AuthenticationType <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.authenticationtypes<span style="color: #000000;">&#93;</span>::Fastbind
	<span style="color: #008000;">## We will be looking in the &quot;Deleted Objects&quot; container which is normally hidden, etc.</span>
	<span style="color: #008000;">## You will need to execute this with an account that has DomainAdmin rights to the domain you are</span>
	<span style="color: #008000;">## querying.</span>
	<span style="color: #800080;">$root</span>.psbase.path <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LDAP://cn=Deleted Objects,&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$DomainDN</span>
	<span style="color: #800080;">$search</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.directorysearcher<span style="color: #000000;">&#93;</span> <span style="color: #800080;">$root</span>
	<span style="color: #800080;">$search</span>.<span style="color: #0000FF;">filter</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;(&amp;(isDeleted=TRUE)(!(objectClass=computer))(objectclass=user))&quot;</span>
	<span style="color: #800080;">$search</span>.Tombstone <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
&nbsp;
	<span style="color: #008000;"># If you have more than 1000 users, you must NOT define SizeLimit (we haven't)</span>
	<span style="color: #008000;"># and PageSize must be less than the default value (of 1000). </span>
	<span style="color: #008000;"># I found this a bit strange...but as long as we understand it, I guess it is okay</span>
	<span style="color: #800080;">$Search</span>.PageSize <span style="color: pink;">=</span> <span style="color: #804000;">500</span>
&nbsp;
	<span style="color: #008000;"># Only look in the top level of the Deleted Objects container.</span>
	<span style="color: #800080;">$search</span>.SearchScope <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.searchscope<span style="color: #000000;">&#93;</span>::OneLevel
	<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: #800080;">$search</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;"># If the SID isn't found, you will get nothing returned.</span>
	<span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-Object</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Name&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Name&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `
	<span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;SAMAccountName&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;SAMAccountName&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `
	<span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;SID&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Security.Principal.SecurityIdentifier<span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;ObjectSID&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `
	<span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;WhenChanged&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;WhenChanged&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span> `
	<span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">where-Object</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.SID <span style="color: #FF0000;">-ieq</span> <span style="color: #800080;">$UserSid</span>.Trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>As always&#8230;</p>
<p>Happy Scripting!!!! and let me know if you have questions or problems.</p>
<p>&#8211; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2009/10/powershell-and-unknown-user-sids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

