<?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#"
	>

<channel>
	<title>ADAC &#8211; Trent Steenholdt&#039;s Blog</title>
	<atom:link href="https://blog.cortanadesign.com.au/tag/adac/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.cortanadesign.com.au</link>
	<description>A simple blog detailing all my findings, interests and work in the Information Technology industry. </description>
	<lastBuildDate>Fri, 08 May 2015 12:10:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.1</generator>
<site xmlns="com-wordpress:feed-additions:1">67701496</site>	<item>
		<title>Remove disabled users from AD groups</title>
		<link>https://blog.cortanadesign.com.au/2014/03/08/remove-disabled-users-from-ad-groups/</link>
		
		<dc:creator><![CDATA[Trent Steenholdt]]></dc:creator>
		<pubDate>Sat, 08 Mar 2014 02:50:03 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[ADAC]]></category>
		<category><![CDATA[ADUC]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<guid isPermaLink="false">https://blog.cortanadesign.com.au/?p=107</guid>

					<description><![CDATA[I had an interesting request from a client today in so far they wanted AD to be cleaned out completely&#8230; Hrrm?&#160;Okay? So what do you mean by cleaned? *Insert joke about dcpromo demoting the domain*.&#160; The response I got was &#8211;&#160;&#160;&#34;We want you to delete all the disabled AD accounts&#34;. While I thought okay,&#160;that&#39;s possible &#8230; <a href="https://blog.cortanadesign.com.au/2014/03/08/remove-disabled-users-from-ad-groups/" class="more-link">Continue reading <span class="screen-reader-text">Remove disabled users from AD groups</span></a>]]></description>
										<content:encoded><![CDATA[<p>
	I had an interesting request from a client today in so far they wanted AD to be cleaned out completely&#8230; Hrrm?&nbsp;Okay? So what do you mean by cleaned? *Insert joke about dcpromo demoting the domain*.&nbsp;
</p>
<p>
	The response I got was &#8211;&nbsp;<em><strong>&nbsp;&quot;We want you to delete all the disabled AD accounts&quot;.</strong></em>
</p>
<p>
	While I thought okay,&nbsp;that&#39;s possible I still had my questions. Why? What are these disabled accounts hurting? Why do&nbsp;they need to vanish off the face of the earth?&nbsp;
</p>
<p>
	It&#39;s an interesting topic to discuss around the industry as I&#39;m personally not one to delete users ever! Though I have worked with others who insist on deleting and even moving disabled AD users in another OU. The latter being simply&nbsp;administrative overhead and something that is easily averted by using an LDAP query that doesn&#39;t show them.&nbsp;Plus if another administrator later on&nbsp;enables them again and forgets to move them back to the appropriate OU then that account&nbsp;could be getting the right the right Group Policy settings!
</p>
<p>
	Accounts that have been disabled for well beyond&nbsp;10+ years I believe&nbsp;still have a place in your AD. Why?&nbsp;Well that person could still one day could&nbsp;return at any time. Why not give them their old account again rather than worry about provision a new one. Sure&nbsp;you can delete their mailbox which is consuming space and maybe delete the contents of their home share (not the actual folder thouht) but that account still belongs to someone&#8230; It still has an idenity and a face that needs to be kept for historical and future purporses.
</p>
<p>
	To give you an example, I had another client have&nbsp;the same user&nbsp;leave&nbsp;and return&nbsp;three times in as many weeks! Yike right! Well no problem, I didn&#39;t have to go repeating the account provisioning process over and over.
</p>
<p>
	Another reason not to go blowing your accounts away to&nbsp;hell is how indenity management is making massive inroads in our industry. For&nbsp;one example&nbsp;Office 365 with one way provisiong (DirSync or the coming WAAD) use your AD as the authoritive source. When you start deleting accounts you&#39;re disjoining those objects in the synchronisation metaverse. Not a problem when you delete, but when a new account with the same old UPN comes back, it can be quite a pain.&nbsp;
</p>
<p>
	So after a bit of coming and going with the client&nbsp;they finally came back to me with their reasoning&#8230;. <strong>&quot;I don&#39;t like seeing all the disabled members in ADUC/ ADAC when I&#39;m modifying group memberhship.&quot;</strong>
</p>
<p>
	This particular client allows their in-line managers to manage group memebership for their files shares and some distribution groups. This was possible thanks to some nifty AD delegation I set up for them a few months earlier.
</p>
<p>
	So no worries&nbsp;I now know what they want me to do. They don&#39;t want the accounts to dissappear, but they do want them to be isolated from all their old security groups. I supported this request as it&#39;s always good practice for any business to review users group&nbsp;memberships and there is no better time to do that then when the new user or a user returns&#8230;. &quot;Okay Jimmy, what access do you actually need&quot;.
</p>
<p>
	So rather than go around and delete the same 100 account or so from 500 different security groups I got onto PowerShell again. Scripting is seriously good for things like this!&nbsp;
</p>
<p>
	<span style="line-height: 20.7999992370605px; white-space: pre-wrap;"><strong>WARNING:</strong> Do not use this script if you has placed all your users and groups so to speak in the original &quot;Users&quot; container (not OU) in a domain. Many Microsoft services etc. can leverage disabled accounts in group membership for delgation etc. and running this script over those groups will pull them out. This script also doesn&#39;y log very well as it justs spits the output to the console&#8230; So it will be difficult to go add all the accounts back in, especially if dealing with a lot of users or groups.</span>
</p>
<pre>
Import-Module ActiveDirectory
foreach ($group in (Get-ADObject -Filter { (ObjectClass -eq &quot;group&quot;) -and (mailNickname -like &quot;*&quot;) } -SearchBase &quot;ou=groups,ou=staff,ou=contoso,dc=contoso,dc=com&quot;)) {
&nbsp; Write-Host $group.Name -Foreground &quot;green&quot;;
&nbsp; foreach ($member in (Get-ADGroupMember -Identity $group)) {
&nbsp; &nbsp; if ($member.objectClass -eq &quot;user&quot; -and ($member.distinguishedName.ToLower().Contains(&quot;ou=users,ou=staff&quot;))) {
&nbsp; &nbsp; &nbsp; $user = Get-ADUser -Identity $member.distinguishedName
&nbsp; &nbsp; &nbsp; if ($user.enabled -eq $false) {
&nbsp; &nbsp; &nbsp; &nbsp; Write-Host $user.Name
&nbsp; &nbsp; &nbsp; &nbsp; Remove-ADGroupMember -Identity $group -Members $user -Confirm:$false
&nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; }
&nbsp; }
}
</pre>
<p>
	There are some important aspects of this groups you should take note of. These are:
</p>
<ol>
<li>
		The &#8211;<strong>SearchBase</strong>&nbsp;parameter&nbsp;is where your AD groups you wish to clean are.
	</li>
<li>
		The&nbsp;<strong><span style="line-height: 20.7999992370605px; white-space: pre-wrap;">$member.distinguishedName.ToLower().Contains </span></strong><span style="line-height: 20.7999992370605px; white-space: pre-wrap;">is where you store your AD users.</span>
	</li>
<li>
		<span style="line-height: 20.7999992370605px; white-space: pre-wrap;">The <strong><span style="line-height: 20.7999992370605px;">if ($user.enabled -eq $false)</span></strong><span style="line-height: 20.7999992370605px;">&nbsp;is what makes sure the account is Disabled. You could change this if statement for example if you wanted to remove all users with a particular office location, phone number or event last name! </span></span>
	</li>
</ol>
<p>
	That&#39;s it for now, next blog post will be whenever I feel a need to put something up!&nbsp;</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">107</post-id>	</item>
	</channel>
</rss>
