<?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>AD Archives - SuperUserTips</title>
	<atom:link href="https://superusertips.com/tag/ad/feed/" rel="self" type="application/rss+xml" />
	<link>https://superusertips.com/tag/ad/</link>
	<description>an endpoint admin&#039;s journal</description>
	<lastBuildDate>Mon, 30 Oct 2023 06:29:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://superusertips.com/wp-content/uploads/2023/10/cropped-Favicon_2023_512x512-150x150.jpg</url>
	<title>AD Archives - SuperUserTips</title>
	<link>https://superusertips.com/tag/ad/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Powershell : Find disabled users and computers in AD</title>
		<link>https://superusertips.com/2023/10/powershell-find-disabled-users-and-computers-in-ad/</link>
					<comments>https://superusertips.com/2023/10/powershell-find-disabled-users-and-computers-in-ad/#respond</comments>
		
		<dc:creator><![CDATA[mando]]></dc:creator>
		<pubDate>Mon, 23 Oct 2023 19:55:54 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[AD]]></category>
		<guid isPermaLink="false">https://blog.kahlontech.com/?p=147</guid>

					<description><![CDATA[<p>This post explains how to use Powershell to find disabled uer and computers in Active Directory. Launch&#160;Windows Powershell&#160;console from&#160;Accessories&#160;and&#160;right-click&#160;and&#160;Run as Administrator: Once launched, use the commands below to collect information&#46;&#46;&#46;</p>
<p>The post <a href="https://superusertips.com/2023/10/powershell-find-disabled-users-and-computers-in-ad/">Powershell : Find disabled users and computers in AD</a> appeared first on <a href="https://superusertips.com">SuperUserTips</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This post explains how to use Powershell to find disabled uer and computers in Active Directory.</p>



<span id="more-147"></span>



<p>Launch&nbsp;<strong><em>Windows Powershell</em>&nbsp;</strong>console from&nbsp;<em>Accessories</em>&nbsp;and&nbsp;<em>right-click</em>&nbsp;and&nbsp;<em>Run as Administrator</em>:</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="377" height="480" src="https://superusertips.com/wp-content/uploads/2023/10/image-3.png" alt="" class="wp-image-155" srcset="https://superusertips.com/wp-content/uploads/2023/10/image-3.png 377w, https://superusertips.com/wp-content/uploads/2023/10/image-3-236x300.png 236w" sizes="(max-width: 377px) 100vw, 377px" /></figure>



<p>Once launched, use the commands below to collect information</p>



<h3 class="wp-block-heading"><strong>Export Disabled Computer Accounts Information using Powershell cmdlets</strong></h3>



<p>Type in the command below to get AD Computers that have the&nbsp;<em>“Enabled”</em>&nbsp;property set to&nbsp;<em><code>$False</code></em>, which indicates that the computer is disabled. Then, export the results to a CSV file called&nbsp;<code>disabledcomputers.csv</code>&nbsp;under <code>C:\Temp</code> folder. You can change the location as you wish.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#ededed;color:#8198a3">PowerShell</span><span role="button" tabindex="0" data-code="Get-ADComputer -Filter {(Enabled -eq $False)} -ResultPageSize 2000 -ResultSetSize $null -Server &lt;AnyDomainController&gt; -Properties Name, OperatingSystem | Export-CSV “C:\Temp\disabledcomputers.CSV” -NoTypeInformation" style="color:#90A4AE;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki material-theme-lighter" style="background-color: #FAFAFA" tabindex="0"><code><span class="line"><span style="color: #6182B8">Get-ADComputer</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">Filter </span><span style="color: #39ADB5">{(</span><span style="color: #90A4AE">Enabled </span><span style="color: #39ADB5">-eq</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">$False)}</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">ResultPageSize </span><span style="color: #F76D47">2000</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">ResultSetSize </span><span style="color: #39ADB5">$null</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">Server </span><span style="color: #39ADB5">&lt;</span><span style="color: #90A4AE">AnyDomainController</span><span style="color: #39ADB5">&gt;</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">Properties Name</span><span style="color: #39ADB5">,</span><span style="color: #90A4AE"> OperatingSystem </span><span style="color: #39ADB5">|</span><span style="color: #90A4AE"> </span><span style="color: #6182B8">Export-CSV</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">“</span><span style="color: #91B859">C:\Temp\disabledcomputers.CSV</span><span style="color: #39ADB5">”</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">NoTypeInformation</span></span></code></pre></div>



<h3 class="wp-block-heading">&nbsp;<strong>Export Disabled User Accounts Information using Powershell cmdlets</strong></h3>



<p>Now, we’ll use similar commands to check and export list of all disabled user accounts in AD</p>



<p>Note that&nbsp;<code>Search-ADAccount</code>&nbsp;supports the&nbsp;<em>“-AccountDisabled”</em>&nbsp;parameter. By using the “-AccountDisabled” parameter, you are instructing&nbsp;<code>Search-ADAccount</code>&nbsp;to look only for disabled user or computer accounts. <code>Export-CSV</code> command will export CSV list of all disabled users</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#ededed;color:#8198a3">PowerShell</span><span role="button" tabindex="0" data-code="Search-ADAccount –AccountDisabled –UsersOnly –ResultPageSize 2000 –ResultSetSize $null | Select-Object SamAccountName, DistinguishedName | Export-CSV “C:\Temp\DisabledUsers.CSV” -NoTypeInformation" style="color:#90A4AE;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki material-theme-lighter" style="background-color: #FAFAFA" tabindex="0"><code><span class="line"><span style="color: #6182B8">Search-ADAccount</span><span style="color: #90A4AE"> –AccountDisabled –UsersOnly –ResultPageSize </span><span style="color: #F76D47">2000</span><span style="color: #90A4AE"> –ResultSetSize </span><span style="color: #39ADB5">$null</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">|</span><span style="color: #90A4AE"> </span><span style="color: #6182B8">Select-Object</span><span style="color: #90A4AE"> SamAccountName</span><span style="color: #39ADB5">,</span><span style="color: #90A4AE"> DistinguishedName </span><span style="color: #39ADB5">|</span><span style="color: #90A4AE"> </span><span style="color: #6182B8">Export-CSV</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">“</span><span style="color: #91B859">C:\Temp\DisabledUsers.CSV</span><span style="color: #39ADB5">”</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">-</span><span style="color: #90A4AE">NoTypeInformation</span></span></code></pre></div>



<h3 class="wp-block-heading">&nbsp;<strong>Export Inactive/Expired Users list using Powershell Cmdlets</strong></h3>



<p>Again, a very similar cmdlet to export Inactive users whose accounts are expired as they haven’t changed the password for more than 90 days</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#ededed;color:#8198a3">PowerShell</span><span role="button" tabindex="0" data-code="Search-ADAccount –AccountInActive –TimeSpan 90:00:00:00 –ResultPageSize 2000 –ResultSetSize $null | ?{$_.Enabled –eq $True} | Select-Object Name, SamAccountName, DistinguishedName | Export-CSV “C:\Temp\inactiveusers.CSV” –NoTypeInformation" style="color:#90A4AE;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki material-theme-lighter" style="background-color: #FAFAFA" tabindex="0"><code><span class="line"><span style="color: #6182B8">Search-ADAccount</span><span style="color: #90A4AE"> –AccountInActive –TimeSpan </span><span style="color: #F76D47">90</span><span style="color: #90A4AE">:</span><span style="color: #F76D47">00</span><span style="color: #90A4AE">:</span><span style="color: #F76D47">00</span><span style="color: #90A4AE">:</span><span style="color: #F76D47">00</span><span style="color: #90A4AE"> –ResultPageSize </span><span style="color: #F76D47">2000</span><span style="color: #90A4AE"> –ResultSetSize </span><span style="color: #39ADB5">$null</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">|</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5; font-style: italic">?</span><span style="color: #39ADB5">{$</span><span style="color: #90A4AE">_.Enabled –eq </span><span style="color: #39ADB5">$True}</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">|</span><span style="color: #90A4AE"> </span><span style="color: #6182B8">Select-Object</span><span style="color: #90A4AE"> Name</span><span style="color: #39ADB5">,</span><span style="color: #90A4AE"> SamAccountName</span><span style="color: #39ADB5">,</span><span style="color: #90A4AE"> DistinguishedName </span><span style="color: #39ADB5">|</span><span style="color: #90A4AE"> </span><span style="color: #6182B8">Export-CSV</span><span style="color: #90A4AE"> </span><span style="color: #39ADB5">“</span><span style="color: #91B859">C:\Temp\inactiveusers.CSV</span><span style="color: #39ADB5">”</span><span style="color: #90A4AE"> –NoTypeInformation</span></span></code></pre></div>



<p>The above command uses the&nbsp;<em>–TimeSpan</em>&nbsp;parameter to find user accounts that have been inactive for the last 90 days. The output is exported to the <code>C:\Temp\inactiveusers.csv</code> file.</p>
<p>The post <a href="https://superusertips.com/2023/10/powershell-find-disabled-users-and-computers-in-ad/">Powershell : Find disabled users and computers in AD</a> appeared first on <a href="https://superusertips.com">SuperUserTips</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://superusertips.com/2023/10/powershell-find-disabled-users-and-computers-in-ad/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
