<?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>Active Directory Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/active-directory/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Tue, 03 Oct 2023 01:30:46 +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>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>Find Empty Groups in Active Directory using PowerShell</title>
		<link>https://thesysadminchannel.com/find-empty-groups-in-active-directory-using-powershell/</link>
					<comments>https://thesysadminchannel.com/find-empty-groups-in-active-directory-using-powershell/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Tue, 03 Oct 2023 01:30:46 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Find Empty Groups]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=4912</guid>

					<description><![CDATA[<p>Whether it&#8217;s time for spring cleaning or you&#8217;re just doing some general cleanup, it&#8217;s important to maintain a proper lifecycle around Active Directory groups. Many organizations love creating groups however, some (most?), don&#8217;t really like to do cleanup because they&#8217;re&#8230; <a href="https://thesysadminchannel.com/find-empty-groups-in-active-directory-using-powershell/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/find-empty-groups-in-active-directory-using-powershell/">Find Empty Groups in Active Directory using PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Whether it&#8217;s time for spring cleaning or you&#8217;re just doing some general cleanup, it&#8217;s important to maintain a proper lifecycle around Active Directory groups. Many organizations love creating groups however, some (most?), don&#8217;t really like to do cleanup because they&#8217;re scared it might break something.  While this is true, it&#8217;s still a good thing to keep a tight ship and have some automation around cleanup.  Today we&#8217;re going to go over the query to find empty groups in Active Directory using PowerShell.<br />
&nbsp;</p>
<p>I previously wrote a post about using the ActiveDirectory module with Get-ADUser.  The idea was to <a href="https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/" rel="noopener" target="_blank">find AD users using PowerShell</a> and went over several advanced topics.  Feel free to check that to get familiar with the overall commands since Get-ADGroup is going to use something similar.<br />
&nbsp;</p>
<p>Here, the Get-ADGroup cmdlet is going to be used to filter all groups that have no members and move them to a separate OU for further processing.  Since we are a little cautious when it comes to making bulk changes like this, I would suggest moving them to a staging OU where they can be left there for 30-60 days.  Since these groups are empty, chances are no one is going to be missing them but it&#8217;s a good idea to separate them first, then move forward with deleting.<br />
&nbsp;</p>
<p>Before we delete anything, I would strongly recommend you <a href="https://techcommunity.microsoft.com/t5/ask-the-directory-services-team/the-ad-recycle-bin-understanding-implementing-best-practices-and/ba-p/396944" rel="noopener" target="_blank">enable the AD recycle bin</a> so you can recover objects without hesitation.<br />
&nbsp;</p>
<h2>Find Empty Groups in Active Directory using PowerShell</h2>
<pre class="brush: powershell; title: ; notranslate">
#Get All empty groups in the entire domain. Be careful with Exchange and other built-in groups.
$AllEmptyGroupList = Get-ADGroup -Filter {Members -notlike &quot;*&quot; } -Properties Members, WhenChanged, WhenCreated

#Get all empty groups that have not been touched in longer than 6 months. Be careful with Exchange and other built-in groups.
$CutOffDate = (Get-Date).AddMonths(-6)
$SixMonthEmptyGroupList = Get-ADGroup -Filter {Members -notlike &quot;*&quot; -and WhenChanged -lt $CutOffDate} -Properties Members, WhenChanged, WhenCreated

#Get all stale groups from a specific OU (Preferred)
$EmptyGroupList = Get-ADGroup -Filter {Members -notlike &quot;*&quot; -and WhenChanged -lt $CutOffDate} -Properties Members, WhenChanged, WhenCreated -SearchBase 'OU=My Groups,DC=contoso,DC=com'
</pre>
<p>&nbsp;</p>
<p>Hopefully, you were able to understand how to find empty groups in Active Directory using PowerShell to better manage your group lifecycle.  If a group is empty and hasn&#8217;t been modified in over 6 months, it&#8217;s a pretty good sign that it is no longer needed and can be purged.<br />
&nbsp;</p>
<p>Again, I would highly recommend you enable the recycle bin but with this you should be able to start off slowly and decommissioning in whatever approach you feel necessary.</p>
<p>The post <a href="https://thesysadminchannel.com/find-empty-groups-in-active-directory-using-powershell/">Find Empty Groups in Active Directory using PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/find-empty-groups-in-active-directory-using-powershell/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4912</post-id>	</item>
		<item>
		<title>How To Change UserPrincipalName with PowerShell</title>
		<link>https://thesysadminchannel.com/change-userprincipalname-with-powershell/</link>
					<comments>https://thesysadminchannel.com/change-userprincipalname-with-powershell/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Tue, 09 Nov 2021 21:48:29 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[change upn with csv file]]></category>
		<category><![CDATA[change UserPrincipalName with Powershell]]></category>
		<category><![CDATA[set a UPN suffix in Active Directory]]></category>
		<category><![CDATA[set upn suffix bulk users]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=3511</guid>

					<description><![CDATA[<p>Imagine a scenario where you work for an organization that has just changed it name to something more user friendly. One of things that are asked of the SysAdmins is that they want to be able to change all UserPrincipalNames&#8230; <a href="https://thesysadminchannel.com/change-userprincipalname-with-powershell/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/change-userprincipalname-with-powershell/">How To Change UserPrincipalName with PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Imagine a scenario where you work for an organization that has just changed it name to something more user friendly.  One of things that are asked of the SysAdmins is that they want to be able to change all UserPrincipalNames from the previous UPN Domain Suffix to the New UPN Suffix.  This article will focus on how to change UserPrincipalName with PowerShell.</p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#Requirements">Requirements</a></li>
<li><a href="#UPNSuffix">Add A New UPN Suffix to Active Directory</a></li>
<ul>
<li><a href="#DomainSuffix">Get Domain Suffixes Currently In AD</a></li>
</ul>
<li><a href="#SetUPN">Change UserPrincipalName with PowerShell</a></li>
<ul>
<li><a href="#SetUPNSingleUser">Set The UPN Suffix For A Single User</a></li>
<li><a href="#SetUPNBulkUser">Change The UserPrincipalName For Bulk Users</a></li>
<li><a href="#SetUPNFromCsv">Use PowerShell to Change UPN Suffix from Csv File</a></li>
</ul>
<li><a href="#Conclusion">Conclusion</a></li>
</ul>
</div>
<div id="Requirements" style="scroll-margin-top: 15px;"></div>
<h2>Requirements</h2>
<p>If you&#8217;re wanting to change the UPN suffix for your users there are a couple of things needed to make that happen.  Let&#8217;s list that down now.</p>
<ul>
<li>Permissions to modify AD Accounts</li>
<li>The UPN Suffix is added to your Domain</li>
</ul>
<div id="UPNSuffix" style="scroll-margin-top: 15px;"></div>
<h2>Add A New UPN Suffix to Active Directory</h2>
<p>As mentioned in one of the requirements, you&#8217;ll need to add the UPN suffix to be able to set it correctly.  Seems pretty obvious right! We&#8217;ll walk through how to do that.</p>
<ul>
<li>Open <strong>Active Directory Domain and Trusts</strong> console</li>
<li>Right click <strong>Active Directory Domain and Trusts</strong> -> <strong>Properties</strong></li>
<li><strong>Add the domain</strong> you would like to use</li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/Domain-and-Trust-Properties-Update.png" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/Domain-and-Trust-Properties-Update.png" alt="Domain and Trust Properties" width="921" height="612" class="aligncenter size-full wp-image-3658" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/Domain-and-Trust-Properties-Update.png?v=1636051214 921w, https://thesysadminchannel.com/wp-content/uploads/2021/11/Domain-and-Trust-Properties-Update-768x510.png?v=1636051214 768w" sizes="(max-width: 921px) 100vw, 921px" /></a></p>
<p>&nbsp;</p>
<p>As you can see from the screenshot above, I added the domain thesysadminchannel.com since this is what I want my users to login as. However, before we get to changing the UPN for our users, let&#8217;s first validate that the domain suffix is available and correctly added to Active Directory.</p>
<div id="DomainSuffix" style="scroll-margin-top: 15px;"></div>
<h3>Get Domain Suffixes Currently In AD</h3>
<p>As ironic as it seems, the Domains and Trust console is where we can confirm if the domain is added.  Nonetheless, we&#8217;ll take it a step further and verify this action dynamically using PowerShell.  This way if you want to automate your account creation, this will help get you started on the right track. Spoiler alert: This uses the <code>Get-ADForest</code> cmdlet.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get UPN Suffix using Powershell
Get-ADForest | select UPNSuffixes
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/Get-ADForest-UPNSuffixes.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/Get-ADForest-UPNSuffixes.png" alt="Get-ADForest UPNSuffixes" width="900" height="300" class="aligncenter size-full wp-image-3660" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/Get-ADForest-UPNSuffixes.png?v=1636052183 900w, https://thesysadminchannel.com/wp-content/uploads/2021/11/Get-ADForest-UPNSuffixes-768x256.png?v=1636052183 768w" sizes="(max-width: 900px) 100vw, 900px" /></a></p>
<p>&nbsp;</p>
<div id="SetUPN" style="scroll-margin-top: 15px;"></div>
<h2>Change UserPrincipalName with PowerShell</h2>
<p>Now for the bread and butter where we cover exactly how to change UserPrincipalName with PowerShell. We&#8217;ll go over multiple ways of setting the UPN suffix for a single user, multiple users in bulk or through a csv file that you can run the script against.  Seems to pretty awesome right?!?!</p>
<p>&nbsp;</p>
<div id="blockquote1">
<strong>Note:</strong> If you&#8217;re a Hybrid shop using Azure AD Connect, you&#8217;ll need to make sure your UPN Suffixes are using publicly routable domain names. Using a &#8220;.local&#8221; domain will use the tenant&#8217;s onmicrosoft.com domain as the UPN when it syncs to Azure Active Directory.
</div>
<p>&nbsp;</p>
<div id="SetUPNSingleUser" style="scroll-margin-top: 15px;"></div>
<h3>Set The UPN Suffix For A Single User</h3>
<p>In order to get an idea of how the change the UserPrincipalName, let&#8217;s run through an example of changing a single user that way you&#8217;re not overwhelmed right out of the gate. This article is primarily focused on doing it the &#8220;PowerShell&#8221; way, but sometimes it&#8217;s honestly a lot quicker to do it using the GUI if it&#8217;s just a one time thing.  No need to spend extra cycles. </p>
<ul>
<li>Open <strong>Active Directory Users and Computers</strong> (ADUC)</li>
<li><strong>Search the user</strong> and open <strong>properties</strong></li>
<li>Click on the <strong>Account tab</strong></li>
<li>Under <strong>User Logon Name</strong>, click the drop down to <strong>specify the UPN suffix</strong></li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/ADUC-Account-Properties-UPN-Suffix.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/ADUC-Account-Properties-UPN-Suffix.png" alt="ADUC Account Properties UPN Suffix - change UserPrincipalName with Powershell" width="850" height="510" class="aligncenter size-full wp-image-3667" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/ADUC-Account-Properties-UPN-Suffix.png?v=1636074812 850w, https://thesysadminchannel.com/wp-content/uploads/2021/11/ADUC-Account-Properties-UPN-Suffix-125x75.png?v=1636074812 125w, https://thesysadminchannel.com/wp-content/uploads/2021/11/ADUC-Account-Properties-UPN-Suffix-768x461.png?v=1636074812 768w" sizes="(max-width: 850px) 100vw, 850px" /></a></p>
<p>&nbsp;</p>
<p>Ok now that we got that out of the way, let&#8217;s set ourselves up for success and essentially do the same thing using Powershell.</p>
<pre class="brush: powershell; title: ; notranslate">
#Change UPN for a single user using Powershell
$Domain = 'thesysadminchannel.com'
$User = 'ajolie'
Get-ADUser $User | select Name, UserPrincipalName

Name           UserPrincipalName
----           -----------------
Angelina Jolie ajolie@ad.thesysadminchannel.com


Get-ADUser $User | Set-ADUser -UserPrincipalName &quot;$user@$domain&quot;
Get-ADUser $User | select Name, UserPrincipalName

Name           UserPrincipalName
----           -----------------
Angelina Jolie ajolie@thesysadminchannel.com
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-for-single-user-Powershell.png" target="_bank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-for-single-user-Powershell.png" alt="change UserPrincipalName with Powershell for single user" width="850" height="402" class="aligncenter size-full wp-image-3670" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-for-single-user-Powershell.png?v=1636416057 850w, https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-for-single-user-Powershell-768x363.png?v=1636416057 768w" sizes="(max-width: 850px) 100vw, 850px" /></a></p>
<p>&nbsp;</p>
<div id="SetUPNBulkUser" style="scroll-margin-top: 15px;"></div>
<h3>Change The UserPrincipalName For Bulk Users</h3>
<p>Needing to be able to change a single user is great and all, however, what if we needed to change 1,000 users? 10,000 users in bulk?  As an exercise, we&#8217;ll change the UPN for all users in a specific OU.  This will allow us to see how to dynamically query AD users and modify their UPN without too much effort.</p>
<p>&nbsp;</p>
<p>As a reference point, we&#8217;ll use <a href="https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/#SearchBaseParameter" rel="noopener" target="_blank">Get-ADUser and filter by Organizational Unit</a> so we can scope the target base. Just for good measure, it&#8217;s always a good to take an export (backup) of the user&#8217;s current settings.  The <em>UserPrincipalName</em> is a primary attribute in Active Directory so at the very least, practice on a few test users or even a test Domain so you know exactly what the outcome is going to be.  Let&#8217;s get started.</p>
<pre class="brush: powershell; title: ; notranslate">
#Specify UPN Domain
$Domain = 'thesysadminchannel.com'

#Get list of samaccountnames in our targeted OU
$UserList = Get-ADUser -Filter * -SearchBase 'OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com' | `
select -ExpandProperty SamAccountName

#Change UPN Suffix from sub domain to primary domain
foreach ($User in $UserList) {
    Get-ADUser $User | Set-ADUser -UserPrincipalName &quot;$User@$Domain&quot;
}

Get-ADUser -Filter * -SearchBase 'OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com' | select Name, UserPrincipalName

Name               UserPrincipalName
----               -----------------
Isabella Contreras icontreras@thesysadminchannel.com
Director of IT     director1@thesysadminchannel.com
Arya Stark         astark@thesysadminchannel.com
Angelina Jolie     ajolie@thesysadminchannel.com
Melissa Zuniga     mzuniga@thesysadminchannel.com

</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-for-bulk-users.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-for-bulk-users.png" alt="change UserPrincipalName with Powershell for bulk users" width="1111" height="489" class="aligncenter size-full wp-image-3675" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-for-bulk-users.png?v=1636418746 1111w, https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-for-bulk-users-1024x451.png?v=1636418746 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-for-bulk-users-768x338.png?v=1636418746 768w" sizes="(max-width: 1111px) 100vw, 1111px" /></a></p>
<p>&nbsp;</p>
<div id="SetUPNFromCsv" style="scroll-margin-top: 15px;"></div>
<h3>Use PowerShell to Change UPN Suffix from Csv File</h3>
<p>An alternative method to changing users in bulk is to use a csv.  You can format the csv anyway you want to but essentially we&#8217;re looking to import it and change the users based off of that. Let&#8217;s create  sample csv.  </p>
<p>The headers will be samaccountname,userprincipalname,name,enabled but we&#8217;ll mainly be relying on the samaccountname for out input.</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/csvfile.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/csvfile.png" alt="csvfile" width="857" height="288" class="aligncenter size-full wp-image-3679" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/csvfile.png?v=1636477808 857w, https://thesysadminchannel.com/wp-content/uploads/2021/11/csvfile-768x258.png?v=1636477808 768w" sizes="(max-width: 857px) 100vw, 857px" /></a></p>
<p>&nbsp;</p>
<p>Here is the code to be able update that as we did in our previous steps.</p>
<pre class="brush: powershell; title: ; notranslate">
#Specify UPN Domain
$Domain = 'thesysadminchannel.com'

#Import csv to a csvList variable.
$csvList = Import-Csv 'C:\Users\pcontreras\csvList.csv'

#Change UPN Suffix from sub domain to primary domain using the csv file
foreach ($User in $csvList.samaccountname) {
    Get-ADUser $User | Set-ADUser -UserPrincipalName &quot;$User@$Domain&quot;
}
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-from-csv-file.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-from-csv-file.png" alt="Set UPN Suffix from csv file" width="949" height="500" class="aligncenter size-full wp-image-3681" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-from-csv-file.png?v=1636479154 949w, https://thesysadminchannel.com/wp-content/uploads/2021/11/Set-UPN-Suffix-from-csv-file-768x405.png?v=1636479154 768w" sizes="(max-width: 949px) 100vw, 949px" /></a></p>
<p>&nbsp;</p>
<div id="Conclusion" style="scroll-margin-top: 15px;"></div>
<h2>Conclusion</h2>
<p>So hopefully this article was able to give you a pretty idea for being able to change UserPrincipalName with Powershell.  The ability to change a UPN suffix in Active Directory will definitely come in handy if you&#8217;re making changes to your org. </p>
<p>&nbsp;</p>
<p>As always, be sure to check out our other content full of Powershell Wizardry.  Articles such as <a href="https://thesysadminchannel.com/get-account-lock-out-source-powershell/" rel="noopener" target="_blank">Get Active Directory Account Lockout Source Using Powershell</a> or even our <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener" target="_blank">Youtube Channel</a> for amazing video content</p>
<p>The post <a href="https://thesysadminchannel.com/change-userprincipalname-with-powershell/">How To Change UserPrincipalName with PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/change-userprincipalname-with-powershell/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3511</post-id>	</item>
		<item>
		<title>Get-ADUser: Find AD Users Using PowerShell Ultimate Deep Dive</title>
		<link>https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/</link>
					<comments>https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Sat, 30 Oct 2021 01:54:18 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[get ad user properties]]></category>
		<category><![CDATA[get aduser filter]]></category>
		<category><![CDATA[get-aduser]]></category>
		<category><![CDATA[powershell get ad user]]></category>
		<category><![CDATA[powershell get ad user attributes]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=3508</guid>

					<description><![CDATA[<p>Get-ADUser, Arguably one of the most used cmdlets I use on a day to day basis. I&#8217;m sure the same goes for other sysadmins around the world if they&#8217;re managing a Windows environment. Today we&#8217;re going to do a deep&#8230; <a href="https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/">Get-ADUser: Find AD Users Using PowerShell Ultimate Deep Dive</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Get-ADUser</strong>, Arguably one of the most used cmdlets I use on a day to day basis.  I&#8217;m sure the same goes for other sysadmins around the world if they&#8217;re managing a Windows environment.  Today we&#8217;re going to do a deep dive on Get-ADUser and the multiple ways to find Active Directory users using Powershell.  As always, let&#8217;s touch on the requirements needed to use Get-ADUser.<br />
&nbsp;</p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#Requirements">Requirements</a></li>
<li><a href="#Examples">Get-ADUser Examples and Parameter Overview</a></li>
<ul>
<li><a href="#IdentityParameter">Find AD User With Identity Parameter</a></li>
<li><a href="#FilterParameter">Get AD User Using The Filter Parameter</a></li>
<ul>
<li><a href="#FilterByProperty">Filter By Property</a></li>
<li><a href="#FilterByOperator">Filter by Operator</a></li>
<li><a href="#FilterWithLDAP">How To Use LDAP Filters</a></li>
<li><a href="#FilterANR">Filter Using Ambiguous Name Resolution (ANR)</a></li>
</ul>
<li><a href="#PropertyParameter">Display All Of The Properties For A Specified User</a></li>
<li><a href="#SearchBaseParameter">Query Active Directory Users By Organizational Unit</a></li>
<ul>
<li><a href="#SearchScopeParameter">Specify The OU Depth Of A Search</a></li>
</ul>
<li><a href="#ServerParameter">Target The Domain Controller Of Your Choice</a></li>
<li><a href="#CredentialParameter">Passing Alternate Credentials</a></li>
</ul>
<li><a href="#QueryAlternateDomain">Get-ADUser From A Different Domain</a></li>
<li><a href="#Conclusion">Conclusion</a></li>
</ul>
</div>
<div id="Requirements" style="scroll-margin-top: 15px;"></div>
<h2>Requirements</h2>
<p>Using the Active Directory Module has a few requirements that we&#8217;ll need to make sure are up and running in order for your queries to run successfully.</p>
<ul>
<li>An Active Directory Domain must be setup</li>
<li>The Domain Controller you&#8217;re querying must have Active Directory Web Services Service running</li>
<li>Remote Server Administration Tools (RSAT)</li>
<ul>
<li>For Windows 10 1903 and later, <a href="https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/" rel="noopener" target="_blank">view setup guide</a></li>
<li>Active Directory Light-Weight Directory Tools Windows Feature (RSAT-AD-Tools) if running on a Windows Server</li>
</ul>
</ul>
<div id="Examples" style="scroll-margin-top: 15px;"></div>
<h2>Get-ADUser Examples and Parameter Overview</h2>
<p>In this article we&#8217;ll cover several of the parameters used in the cmdlet along with examples and screenshots so you can see exactly how to utilize these to your benefit. </p>
<div id="IdentityParameter" style="scroll-margin-top: 15px;"></div>
<h2>Find ADUser With Identity Parameter</h2>
<p>Get-ADUser using the -Identity Parameter is typically the most commonly used parameter when people want to query a specific user.  This is because the -Identity parameter is positioned as the first parameter so it can be omitted when running the actual query.</p>
<p> Example: <code>Get-ADUser -Identity aryastark</code> will produce the exact same results as <code>Get-ADUser aryastark</code><br />
<a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Identity-Parameter.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Identity-Parameter.png" alt="Get AD User -Identity Parameter" width="1099" height="632" class="aligncenter size-full wp-image-3547" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Identity-Parameter.png?v=1635202532 1099w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Identity-Parameter-1024x589.png?v=1635202532 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Identity-Parameter-768x442.png?v=1635202532 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<p>&nbsp;<br />
There are 4 attributes that are allowed when using Identity parameter. Let&#8217;s list them here along with an example of what it typically looks like.</p>
<ul>
<li>Distinguished Name</li>
<ul>
<li>CN=Arya Stark,OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com</li>
</ul>
</ul>
<ul>
<li>ObjectGuid</li>
<ul>
<li>643d7cb4-9682-4835-908d-d696ed476649</li>
</ul>
</ul>
<ul>
<li>Security Identifier (SID)</li>
<ul>
<li>S-1-5-21-3946430794-117524452-1540306727-8620</li>
</ul>
</ul>
<ul>
<li>sAMAccountName (username)</li>
<ul>
<li>aryastark</li>
</ul>
</ul>
<div id="attachment_3549" style="width: 888px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-AD-User-Powershell-Identity-Parameter.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3549" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-AD-User-Powershell-Identity-Parameter.png" alt="Get AD User Powershell Identity Parameter" width="878" height="277" class="size-full wp-image-3549" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-AD-User-Powershell-Identity-Parameter.png?v=1635203039 878w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-AD-User-Powershell-Identity-Parameter-768x242.png?v=1635203039 768w" sizes="(max-width: 878px) 100vw, 878px" /></a><p id="caption-attachment-3549" class="wp-caption-text">Example of the 4 attributes that are accepted</p></div>
<div id="FilterParameter" style="scroll-margin-top: 15px;"></div>
<h2>Get-ADUser Using The Filter Parameter</h2>
<p>The -Filter parameter in the Get-ADUser cmdlet is definitely also another fan favorite.  The phrase &#8220;Filter Left, Format right&#8221;  definitely applies here in getting the data you need in a reduced amount of time.  This is one of those fundamental Powershell concepts that everyone should learn early on.</p>
<p>&nbsp;</p>
<div id="blockquote1">
<strong>Pro-Top</strong>: Replace Where-Object with Filter.  Anytime a filter parameter is available use that instead of Where-Object for faster results.
</div>
<p>&nbsp;</p>
<div id="FilterByProperty" style="scroll-margin-top: 15px;"></div>
<h3>Get AD User Properties</h3>
<p>Let&#8217;s take a look at get ad user properties in action.  Say we wanted to get everyone with the GivenName (firstname) of &#8216;Arya&#8217; &#8211; What exactly would that query look like?</p>
<pre class="brush: powershell; title: ; notranslate">
#Get All Active Directory users that have a first name of Arya
Get-ADUser -Filter &quot;GivenName -eq 'Arya'&quot; | select Name, UserPrincipalName, Enabled

Name       UserPrincipalName                Enabled
----       -----------------                -------
Arya Stark aryastark@thesysadminchannel.com    True
Arya Cruz  aryacruz@thesysadminchannel.com     True
Arya Jolie aryajolie@thesysadminchannel.com    True
</pre>
<div id="attachment_3591" style="width: 928px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Parameter-GivenName.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3591" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Parameter-GivenName.png" alt="Get-ADUser -Filter Parameter GivenName" width="918" height="258" class="size-full wp-image-3591" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Parameter-GivenName.png?v=1635320307 918w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Parameter-GivenName-768x216.png?v=1635320307 768w" sizes="(max-width: 918px) 100vw, 918px" /></a><p id="caption-attachment-3591" class="wp-caption-text">Select object was added to condense output</p></div>
<p>You can find other filterable attributes by choosing any one of the attributes when running <code>-Properties *</code>.  Commonly used filters are <em>UserPrincipalName</em>, <em>Surname</em>, <em>Mail</em> and even <em>Name</em> or <em>DisplayName</em>.  </p>
<div id="FilterByOperator" style="scroll-margin-top: 15px;"></div>
<h3>Filter With Operators</h3>
<p>Regarding operators, there are several choices such as equal, like, less than and even greater than that&#8217;s convenient for us to use.  </p>
<p>When using the <code>-eq</code> operator, the filter has to match the property exactly so make sure you specify the text exactly as it&#8217;s shown in AD.  As noted in the above example, we searched for all users with the first name &#8216;Arya.&#8217;  Say we wanted to only filter for the Name &#8216;Arya Stark&#8217;.  </p>
<pre class="brush: powershell; title: ; notranslate">
#Get the AD user whos name is Arya Stark
Get-ADUser -Filter &quot;Name -eq 'Arya Stark'&quot; | select Name, UserPrincipalName, Enabled


Name       UserPrincipalName                Enabled
----       -----------------                -------
Arya Stark aryastark@thesysadminchannel.com    True
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Name-eq-Arya.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Name-eq-Arya.png" alt="Get-ADUser -Filter Name eq Arya" width="875" height="231" class="aligncenter size-full wp-image-3607" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Name-eq-Arya.png?v=1635381251 875w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Name-eq-Arya-768x203.png?v=1635381251 768w" sizes="(max-width: 875px) 100vw, 875px" /></a><br />
&nbsp;</p>
<p>Let&#8217;s now dive into the <code>-like</code> operator and how to specifically use it for filters.  A great example I&#8217;ve used in the past is to see who are all the people that have the word Remote in their AD Office Attribute.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get all users who are remote 
Get-ADUser -Filter &quot;Office -like 'Remote*'&quot; -Properties Office | select UserPrincipalName, Name, Office

UserPrincipalName                Name       Office
-----------------                ----       ------
aryacruz@thesysadminchannel.com  Arya Cruz  Remote - California
aryastark@thesysadminchannel.com Arya Stark Remote - Winterfell


#Get all users who are in California
Get-ADUser -Filter &quot;Office -like '*California*'&quot; -Properties Office | select UserPrincipalName, Name, Office

UserPrincipalName                Name       Office
-----------------                ----       ------
aryacruz@thesysadminchannel.com  Arya Cruz  Remote - California
aryajolie@thesysadminchannel.com Arya Jolie Palo Alto - California
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Office-like-Operator.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Office-like-Operator.png" alt="Get-ADUser -Filter Office like Operator" width="1099" height="386" class="aligncenter size-full wp-image-3611" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Office-like-Operator.png?v=1635382216 1099w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Office-like-Operator-1024x360.png?v=1635382216 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-Office-like-Operator-768x270.png?v=1635382216 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a><br />
&nbsp;</p>
<p>With regard to auditing, I&#8217;ve always found <a href="https://thesysadminchannel.com/get-last-logon-date-for-all-users-in-your-domain/" rel="noopener" target="_blank">filtering accounts by LastLogonDate</a> has always been extremely helpful. For an in-depth write-up check out the link above.  Otherwise, let&#8217;s go over a quick example to get the gist of what&#8217;s happening.  We&#8217;ll also couple it with the <code>-and</code> operator to string multiple queries together and narrow down your filter.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get Remote Users who have not logged in, in over 90 days
$CutoffDate = (Get-Date).AddDays(-90)
Get-ADUser -Filter &quot;LastLogonDate -lt '$CutoffDate' -and Office -like '*Remote*'&quot; -Properties LastLogonDate `
 | select UserPrincipalName, Name, LastLogonDate

UserPrincipalName                Name       LastLogonDate
-----------------                ----       -------------
aryastark@thesysadminchannel.com Arya Stark 3/17/2021 5:29:46 PM
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-LastLogonDate.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-LastLogonDate.png" alt="Get-ADUser -Filter LastLogonDate" width="1099" height="250" class="aligncenter size-full wp-image-3613" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-LastLogonDate.png?v=1635383598 1099w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-LastLogonDate-1024x233.png?v=1635383598 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-LastLogonDate-768x175.png?v=1635383598 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<p>&nbsp;</p>
<div id="FilterWithLDAP" style="scroll-margin-top: 15px;"></div>
<h3>How To Use LDAP Filters</h3>
<p>To be perfectly honest, I can probably count the number of times on one hand that I&#8217;ve used an LDAP filter.  The methods mentioned above have been ingrained into my brain since that&#8217;s how I learned.  The reason being is that the syntax is a bit more complex and the standard operators like -and/-or don&#8217;t really come into play here.  </p>
<p>If you&#8217;re great with VBScript then it might be up your alley.  In any event, here we go.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get AD user using an LDAP filter query
Get-ADUser -LdapFilter &quot;(&amp;(objectClass=user)(Name=Arya Stark))&quot; | select Name, UserPrincipalName, Enabled

Name       UserPrincipalName                Enabled
----       -----------------                -------
Arya Stark aryastark@thesysadminchannel.com    True
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-LDAPFilter.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-LDAPFilter.png" alt="Get Active Directory User -LDAPFilter" width="1028" height="217" class="aligncenter size-full wp-image-3623" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-LDAPFilter.png?v=1635542661 1028w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-LDAPFilter-1024x216.png?v=1635542661 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-LDAPFilter-768x162.png?v=1635542661 768w" sizes="(max-width: 1028px) 100vw, 1028px" /></a></p>
<p>&nbsp;</p>
<div id="FilterANR" style="scroll-margin-top: 15px;"></div>
<h3>Filter Using Ambiguous Name Resolution (ANR)</h3>
<p>Ambiguous Name Resolution, aka ANR, allows multiple objects to be resolved on a single query. Think of it like a built-in -like operator that queries against GivenName, Surname, DisplayName, SamAccountName, physicalDeliveryOfficeName and even the Exchange MailNickName without any added effort.  </p>
<p>ANR is especially useful in larger organizations where people share a similar display name.  It just helps to truncate multiple -and/-or queries into a single function to ease your searches. Let&#8217;s cover an example of using ambiguous name resolution in an actual filter (using Arya Stark as our example).</p>
<pre class="brush: powershell; title: ; notranslate">
#Get all users who have Arya in their name
Get-ADUser -Filter &quot;Anr -eq 'Arya'&quot; | select UserPrincipalName, Name, Enabled

UserPrincipalName                Name       Enabled
-----------------                ----       -------
aryastark@thesysadminchannel.com Arya Stark    True
aryacruz@thesysadminchannel.com  Arya Cruz     True
aryajolie@thesysadminchannel.com Arya Jolie    True


#Get all users who have Stark in their name
Get-ADUser -Filter &quot;Anr -eq 'Stark'&quot; | select UserPrincipalName, Name, Enabled

UserPrincipalName                Name       Enabled
-----------------                ----       -------
aryastark@thesysadminchannel.com Arya Stark    True

</pre>
<div id="attachment_3629" style="width: 859px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-ANR.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3629" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-ANR.png" alt="Get-ADUser -Filter ANR" width="849" height="397" class="size-full wp-image-3629" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-ANR.png?v=1635546852 849w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-ANR-768x359.png?v=1635546852 768w" sizes="(max-width: 849px) 100vw, 849px" /></a><p id="caption-attachment-3629" class="wp-caption-text">Notice we didn&#8217;t need to specify GivenName, Surname or even use the -Like Operator.</p></div>
<p>&nbsp;</p>
<div id="PropertyParameter" style="scroll-margin-top: 15px;"></div>
<h2>Display All Of The Properties For A Specified User</h2>
<p>All Active Directory users have the same core attributes populated but they&#8217;re not displayed by default.  If you notice in the examples above, I had to specify <code>-Property</code> in order for Powershell to know to check those AD properties.  If you omit the property parameter, the filter won&#8217;t find it even though the attribute is there on the user&#8217;s account.</p>
<p>A good thing is this allows a wildcard (*) so you can see what&#8217;s available.  I would also recommend to explicitly specify your properties when querying many users so you&#8217;re not putting to much stress on the remote Domain Controller. </p>
<pre class="brush: powershell; title: ; notranslate">
#Get all properties for a user.
Get-ADUser aryastark -Properties * 

</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Property-All.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Property-All.png" alt="Get Active Directory User -Property All" width="1099" height="632" class="aligncenter size-full wp-image-3626" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Property-All.png?v=1635544819 1099w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Property-All-1024x589.png?v=1635544819 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Property-All-768x442.png?v=1635544819 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<div id="SearchBaseParameter" style="scroll-margin-top: 15px;"></div>
<h2>Query Active Directory Users By Organizational Unit</h2>
<p>The ability to query users by an Organizational Unit is an excellent method to ensure you&#8217;re getting the most out of your Active Directory OU structure.  A great, real world example for this would be if you have your AD Org units structured by regional location and you&#8217;re looking to get all users in that location.</p>
<p>SearchBase uses the DistinguishedName as the parameter input.  You can grab the DN by one of 2 ways.  </p>
<ul>
<li>Query a user in that OU and select the DN property. Extract OU DN from there</li>
<li>Use Get-ADOrganizationalUnit and filter by name</li>
</ul>
<pre class="brush: powershell; title: ; notranslate">
#Query a user in the OU and select the DN property to get the OU syntax.
Get-ADUser aryastark 

DistinguishedName
-----------------
CN=Arya Stark,OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com


#Use Get-ADOrganizationalUnit and filter by name
Get-ADOrganizationalUnit -Filter &quot;Name -like '*Excluded*'&quot; | select DistinguishedName

DistinguishedName
-----------------
OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-SearchBase.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-SearchBase.png" alt="Get Active Directory User -SearchBase" width="872" height="346" class="aligncenter size-full wp-image-3633" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-SearchBase.png?v=1635549335 872w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-SearchBase-768x305.png?v=1635549335 768w" sizes="(max-width: 872px) 100vw, 872px" /></a></p>
<p>&nbsp;</p>
<p>Now that we have the Organizational Unit&#8217;s DistinguishedName, we can use that as the input parameter.  This coupled with the -Filter parameter will help narrow your search by Org Unit.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get All users under the Excluded OU.  Use a custom label to show Organizational Unit
Get-ADUser -Filter * -SearchBase &quot;OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com&quot; | select Name, `
@{Name = 'OrganizationalUnit'; `
Expression = {$Length = ($_.DistinguishedName).IndexOf(&quot;,OU&quot;); $_.DistinguishedName.Substring($Length + 1) }} | `
Sort-Object OrganizationalUnit

Name               OrganizationalUnit
----               ------------------
Arya Jolie         OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Isabella Contreras OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Arya Cruz          OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Director of IT     OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Arya Stark         OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Test1              OU=Test,OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Test2              OU=Test,OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com

</pre>
<div id="attachment_3636" style="width: 1074px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-OU.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3636" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-OU.png" alt="Get-ADUser Filter All -SearchBase OU" width="1064" height="390" class="size-full wp-image-3636" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-OU.png?v=1635552095 1064w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-OU-1024x375.png?v=1635552095 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-OU-768x282.png?v=1635552095 768w" sizes="(max-width: 1064px) 100vw, 1064px" /></a><p id="caption-attachment-3636" class="wp-caption-text">Wildcards are also allowed to use with Filter to search for All</p></div>
<div id="SearchScopeParameter" style="scroll-margin-top: 15px;"></div>
<h3>Specify The OU Depth Of A Search</h3>
<p>Building off of the SearchBase parameter from above, you might have noticed that the search was recursive.  Meaning that it drilled down to all Sub OU&#8217;s without having the need to specify them.  The question however, is what if we don&#8217;t want to drill down.  What if we only want <em>that</em> explicit OU? </p>
<p>This is where the SearchScope parameter comes into play. Using the same query above, let&#8217;s exclude the two test accounts in the Test OU.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get Users in the Excluded OU and Exclude the Test OU Users
Get-ADUser -Filter * -SearchBase &quot;OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com&quot; -SearchScope OneLevel | `
select Name, `
@{Name = 'OrganizationalUnit'; `
Expression = {$Length = ($_.DistinguishedName).IndexOf(&quot;,OU&quot;); $_.DistinguishedName.Substring($Length + 1) }}

Name               OrganizationalUnit
----               ------------------
Arya Cruz          OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Arya Jolie         OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Arya Stark         OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Director of IT     OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com
Isabella Contreras OU=Excluded,DC=ad,DC=thesysadminchannel,DC=com

</pre>
<div id="attachment_3639" style="width: 1062px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-SearchScope-OU.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3639" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-SearchScope-OU.png" alt="Get-ADUser Filter All -SearchBase SearchScope OU" width="1052" height="359" class="size-full wp-image-3639" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-SearchScope-OU.png?v=1635552975 1052w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-SearchScope-OU-1024x349.png?v=1635552975 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Filter-All-SearchBase-SearchScope-OU-768x262.png?v=1635552975 768w" sizes="(max-width: 1052px) 100vw, 1052px" /></a><p id="caption-attachment-3639" class="wp-caption-text">When SearchScope is omitted, it will default to Subtree</p></div>
<p>&nbsp;</p>
<div id="ServerParameter" style="scroll-margin-top: 15px;"></div>
<h2>Target The Domain Controller Of Your Choice</h2>
<p>Anytime you make an Active Directory query, you&#8217;ll most likely always default to a Domain Controller in your site.  This is defined by Active Directory Sites and Services and an easy way to check what Domain Controller you&#8217;re currently authenticating against is to use <code>$env:LogonServer</code>.</p>
<p>&nbsp;</p>
<p>This is great and all, but what if you wanted to query a Domain Controller in another site, perhaps one across the globe?  You would use the <code>-Server</code> parameter to do this.  Specifically for me, I always like to use the Primary Domain Controller, PDC Emulator, as this is the heart of all replication changes.  If you specify this Domain Controller specifically, you can avoid waiting for replication and can move on with your script without adding sleep commands. </p>
<p>You can use Powershell to query, or <a href="https://thesysadminchannel.com/how-to-transfer-fsmo-roles-in-server-2019-using-powershell/" rel="noopener" target="_blank">transfer FSMO Roles to a different Domain Controller</a>.</p>
<p>Let&#8217;s walk through an example for how to use the server parameter to specify the PDC emulator dynamically.</p>
<pre class="brush: powershell; title: ; notranslate">
#Get PDC Emulator dynamically and save it to a variable for later use
$DomainController = Get-ADDomain | select -ExpandProperty PDCEmulator
$DomainController
PAC-DC01.ad.thesysadminchannel.com

Get-ADUser aryastark -Server $DomainController | select UserPrincipalName, Name

UserPrincipalName                Name
-----------------                ----
aryastark@thesysadminchannel.com Arya Stark

</pre>
<div id="attachment_3641" style="width: 859px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Server-Parameter.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3641" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Server-Parameter.png" alt="Get-ADUser Server Parameter" width="849" height="314" class="size-full wp-image-3641" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Server-Parameter.png?v=1635554260 849w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Server-Parameter-768x284.png?v=1635554260 768w" sizes="(max-width: 849px) 100vw, 849px" /></a><p id="caption-attachment-3641" class="wp-caption-text">Using the Server parameter can bypass replication times and it recommended for automation.</p></div>
<p>&nbsp;</p>
<div id="CredentialParameter" style="scroll-margin-top: 15px;"></div>
<h2>Passing Alternate Credentials for Get-ADUser</h2>
<p>Being able to pass a different set of credentials would come in handy for use cases like automation or other use cases like users in a different domain.  Since Active Directory grants read-only access to all users by default, there really isn&#8217;t a need to pass in alternate credentials if you&#8217;re querying something in the same domain.  It should be able to do it with no problem.</p>
<p>&nbsp;</p>
<p>When this comes in handy is if you need to make changes to AD Objects and you need to use different credentials. To make this happen you&#8217;ll use the <code>-Credential</code> parameter and use <code>Get-Credential</code> to securely set the username and password.  Since we&#8217;re so keen on examples, let&#8217;s test it.</p>
<pre class="brush: powershell; title: ; notranslate">
#Save user credentials into a variable using Get-Credential
$Credential = Get-Credential -UserName 'ad\pcontreras' -Message 'Enter in a Password'
PS C:\&gt;
Get-ADUser aryastark -Credential $Credential | select UserPrincipalName, Name

UserPrincipalName                Name
-----------------                ----
aryastark@thesysadminchannel.com Arya Stark

</pre>
<div id="attachment_3644" style="width: 866px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Credential-Parameter.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3644" src="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Credential-Parameter.png" alt="Get AD User Credential Parameter" width="856" height="278" class="size-full wp-image-3644" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Credential-Parameter.png?v=1635555117 856w, https://thesysadminchannel.com/wp-content/uploads/2021/10/Get-ADUser-Credential-Parameter-768x249.png?v=1635555117 768w" sizes="(max-width: 856px) 100vw, 856px" /></a><p id="caption-attachment-3644" class="wp-caption-text">In the sprit of this article, we&#8217;ll pass on credentials for Get-ADUser</p></div>
<p>&nbsp;</p>
<div id="QueryAlternateDomain" style="scroll-margin-top: 15px;"></div>
<h2>Get-ADUser From A Different Domain</h2>
<p>If you happen to have multiple Domains in your forest and you&#8217;re too lazy to Remote Desktop into a Domain Controller on that domain to run the query (guilty of it myself from time to time), it&#8217;s absolutely helpful to be able to run your query from a single machine.  You can do this by combining two of the parameters above.  Those parameters being <code>-Credential</code> as well as <code>-Server</code>.</p>
<p>I don&#8217;t have any other domains in my forest so I won&#8217;t be able to provide a working screenshot. However, one thing to keep in mind is that you&#8217;ll need to provide the Fully Qualified Domain Name (FQDN) for the remote DC.  Overall, the basic syntax should look like this:</p>
<pre class="brush: powershell; title: ; notranslate">
#Save user credentials into a variable using Get-Credential
$Credential = Get-Credential -UserName 'otherdomain\myaccount' -Message 'Enter in a Password'

Get-ADUser myaccount -Server DC01.otherdomain.thesysadminchannel.com -Credential $Credential
</pre>
<p>&nbsp;</p>
<div id="Conclusion" style="scroll-margin-top: 15px;"></div>
<h2>Conclusion</h2>
<p>Hopefully this deep dive on how to use Powershell Get AD User has been incredible helpful for you.  I&#8217;m also hoping you learned a thing or two that you can implement in your environment.  As I mentioned, Get-ADUser is probably one of the most fundamental cmdlets that anyone administrator should have in their arsenal of tools.  </p>
<p>&nbsp;</p>
<p>It can be useful, especially when providing reports on the current state of your environment.  If you liked this article, feel free to browse our other <a href="https://thesysadminchannel.com/active-directory/" rel="noopener" target="_blank">Active Directory</a> as well as our own personal <a href="https://thesysadminchannel.com/powershell/" rel="noopener" target="_blank">Powershell gallery</a> full of useful scripts.  Finally, if you&#8217;re interested in video content, check out our <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener" target="_blank">Youtube Channel</a> for sysadmin videos</p>
<p>The post <a href="https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/">Get-ADUser: Find AD Users Using PowerShell Ultimate Deep Dive</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-aduser-find-active-directory-users-using-powershell-ultimate-deep-dive/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3508</post-id>	</item>
		<item>
		<title>How To Remove News and Interests In Windows 10</title>
		<link>https://thesysadminchannel.com/how-to-remove-news-and-interests-windows-10/</link>
					<comments>https://thesysadminchannel.com/how-to-remove-news-and-interests-windows-10/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Fri, 24 Sep 2021 00:21:57 +0000</pubDate>
				<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Disable News and Interests]]></category>
		<category><![CDATA[remove weather from taskbar]]></category>
		<category><![CDATA[Remove Weather From Taskbar Windows 10]]></category>
		<category><![CDATA[windows 10 disable news and interests registry]]></category>
		<category><![CDATA[windows 10 news and interests disable gpo]]></category>
		<category><![CDATA[Windows 10 News and interests remove]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=3400</guid>

					<description><![CDATA[<p>If you&#8217;ve upgraded or installed Windows 10 20H2 and later, you might have noticed a new item in your taskbar that gets enabled by default. I wasn&#8217;t particularly interested in seeing a huge weather forecast along with current news in&#8230; <a href="https://thesysadminchannel.com/how-to-remove-news-and-interests-windows-10/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/how-to-remove-news-and-interests-windows-10/">How To Remove News and Interests In Windows 10</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you&#8217;ve upgraded or installed Windows 10 20H2 and later, you might have noticed a new item in your taskbar that gets enabled by default.  I wasn&#8217;t particularly interested in seeing a huge weather forecast along with current news in my primary/visible workspace.  It was even more annoying when I would accidently hover over it and a huge popup would show with more nonsense.  To me personally, it was really intrusive so today we&#8217;re going to learn several ways <strong>how to remove News and Interests in Windows 10</strong><br />
&nbsp;</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/09/News-and-Interests1.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/09/News-and-Interests1.png" alt="News and Interests" width="800" height="auto" class="aligncenter size-full wp-image-3434" /></a></p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#LearnMore">Learn More</a></li>
<li><a href="#GroupPolicy">Option 1 &#8211; Remove News and Interests via Group Policy</a></li>
<li><a href="#Registry">Option 2 &#8211; Remove News and Interests via Registry</a></li>
<li><a href="#Powershell">Option 3 &#8211; How To Remove Weather From Taskbar Using Powershell</a></li>
<li><a href="#Manually">Option 4 &#8211; Remove Weather From Taskbar Windows 10</a></li>
<li><a href="#Conclusion">Conclusion</a></li>
</ul>
</div>
<p>&nbsp;</p>
<div id="LearnMore" style="scroll-margin-top: 15px;"></div>
<p>If you&#8217;re interested in learning more and seeing if it&#8217;s for you, here&#8217;s a quick overview of the high-level benefits for keeping it enabled.</p>
<ul>
<li>It allows you to personalize your feed and stay up to date</li>
<li>Get Weather reports for multiple locations throughout the world</li>
</ul>
<p>Here is the <a href="https://support.microsoft.com/en-us/windows/stay-up-to-date-with-news-and-interests-a39baa08-7488-4169-9ed8-577238f46f8f" rel="noopener" target="_blank">Microsoft Doc</a> for more how to&#8217;s with the app.</p>
<div id="GroupPolicy" style="scroll-margin-top: 15px;"></div>
<h2>Remove News and Interests via Group Policy</h2>
<p>Option 1 &#8211; Being able to <strong>disable news and interest via Group Policy</strong> (GPO) would be preferred for those who want to commit this change across a group (or all) users in your environment.  In my lab I&#8217;m running Server 2019 Domain Controllers and the admx template for the settings are not there by default. However,  on my Windows 10 20H2 machine running the RSAT tools, the settings are there so you can get by with using a machine with those tools installed. If you&#8217;re interested, see how to <a href="https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/" rel="noopener" target="_blank">install RSAT for Windows 10 1903 and Later</a><br />
&nbsp;</p>
<p>This is a computer setting so to disable the feature using a GPO, follow these steps as they&#8217;re laid out here.</p>
<ul>
<li>Edit an existing policy or create a new policy and name it: <strong>Disable News and Interest</strong></li>
<li>Navigate to <strong>Computer Configuration</strong> -> <strong>Administrative Templates</strong> -> <strong>Windows Components</strong> -> <strong>News and interests</strong></li>
<li>Open the setting <strong>Enable news and interests on the taskbar</strong> to edit policy</li>
<li>Set the setting to <strong>Disabled</strong> and click OK</li>
<li>Deploy the policy as needed.  You can also use the local gpedit.msc to make this change on a single computer</li>
</ul>
<div id="attachment_3437" style="width: 1135px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Group-Policy.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3437" src="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Group-Policy.png" alt="Remove News and Interests via Group Policy" width="1125" height="721" class="size-full wp-image-3437" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Group-Policy.png?v=1632382777 1125w, https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Group-Policy-1024x656.png?v=1632382777 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Group-Policy-768x492.png?v=1632382777 768w" sizes="(max-width: 1125px) 100vw, 1125px" /></a><p id="caption-attachment-3437" class="wp-caption-text"><em>Disable News and Interests via Group Policy</em></p></div>
<div id="Registry" style="scroll-margin-top: 15px;"></div>
<h2>Remove News and Interests via Registry</h2>
<p>Option 2 &#8211; The next option which is just as prominent is to <strong>disable News and Interest via Registry</strong>. </p>
<ul>
<li>Go to <strong>Start</strong> -> type <strong>Regedit</strong> to open the local registry edit</li>
<li>Navigate to <strong>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Feeds</strong></li>
<li>Open <strong>ShellFeedsTaskbarViewMode</strong> to edit the setting</li>
<li><strong>Set the value to 2</strong> to remove News and Interests</li>
</ul>
<div id="attachment_3439" style="width: 767px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Registry.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3439" src="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Registry.png" alt="Disable News and Interests via Registry" width="757" height="468" class="size-full wp-image-3439" /></a><p id="caption-attachment-3439" class="wp-caption-text"><em>Disable News and Interests via Registry</em></p></div>
<p>There are 3 options for that we can set when using the registry.</p>
<ul>
<li>0 – Shows icon and text</li>
<li>1 – Show only icon</li>
<li>2 – Hide News and Interests</li>
</ul>
<div id="Powershell" style="scroll-margin-top: 15px;"></div>
<h2>How To Remove Weather From Taskbar Using Powershell</h2>
<p>Option 3 &#8211; Building on top of our regedit option,  here&#8217;s a quick snippet to <strong>remove News and Interest using Powershell</strong>. </p>
<pre class="brush: powershell; title: ; notranslate">
#Get Current Setting before change
Get-ItemProperty -Path &quot;HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds&quot; | select ShellFeedsTaskbarViewMode

#Remove News and Interest Using Powershell
Set-ItemProperty -Path &quot;HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds&quot; -Name &quot;ShellFeedsTaskbarViewMode&quot; -Value 2

#Get Current Setting after change
Get-ItemProperty -Path &quot;HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds&quot; | select ShellFeedsTaskbarViewMode
</pre>
<div id="attachment_3445" style="width: 1216px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-using-Powershell.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3445" src="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-using-Powershell.png" alt="Block News and Interests using Powershell" width="1206" height="494" class="size-full wp-image-3445" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-using-Powershell.png?v=1632386049 1206w, https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-using-Powershell-1024x419.png?v=1632386049 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-using-Powershell-768x315.png?v=1632386049 768w" sizes="(max-width: 1206px) 100vw, 1206px" /></a><p id="caption-attachment-3445" class="wp-caption-text"><em>Disable News and Interests using Powershell</em></p></div>
<div id="Manually" style="scroll-margin-top: 15px;"></div>
<h2>Remove Weather From Taskbar Windows 10</h2>
<p>Option 4 &#8211; Our last option is probably the one that might be the quickest and easiest on a per user basis, but definitely not something that can be scaled across the environment.  If you&#8217;re wanting to make this change across the environment, the other options would definitely be better suited for this.  It does however offer the quickest solution to the problem so that works too.</p>
<ul>
<li>Right click the taskbar</li>
<li>Hover over <strong>News and Interest</strong></li>
<li>Select <strong>Turn off</strong></li>
</ul>
<div id="attachment_3447" style="width: 810px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Taskbar.png" target="_blank" rel="noopener"><img decoding="async" aria-describedby="caption-attachment-3447" src="https://thesysadminchannel.com/wp-content/uploads/2021/09/Disable-News-and-Interests-via-Taskbar.png" alt="Remove Weather From Taskbar Windows 10" width="800" height="auto" class="size-full wp-image-3447" /></a><p id="caption-attachment-3447" class="wp-caption-text"><em>Remove Weather From Taskbar Windows 10</em></p></div>
<div id="Conclusion" style="scroll-margin-top: 15px;"></div>
<h2>Conclusion</h2>
<p>Hopefully this article was able to inform you on the multiple ways for how to remove News and Interests a.k.a remove weather from taskbar in Windows 10.  I know for some it can be incredibly annoying and in my opinion I think it&#8217;s a little too intrusive for a Enterprise environment.  </p>
<p>The post <a href="https://thesysadminchannel.com/how-to-remove-news-and-interests-windows-10/">How To Remove News and Interests In Windows 10</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/how-to-remove-news-and-interests-windows-10/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3400</post-id>	</item>
		<item>
		<title>[Solved] SYSVOL and NETLOGON Shares Missing on New DC</title>
		<link>https://thesysadminchannel.com/solved-sysvol-and-netlogon-shares-missing-2016-2019-domain-controller/</link>
					<comments>https://thesysadminchannel.com/solved-sysvol-and-netlogon-shares-missing-2016-2019-domain-controller/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Tue, 23 Jun 2020 06:13:06 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[missing sysvol and netlogon shares]]></category>
		<category><![CDATA[netlogon and sysvol shares are missing]]></category>
		<category><![CDATA[netlogon share missing]]></category>
		<category><![CDATA[NETLOGON shares missing Server 2016]]></category>
		<category><![CDATA[sysvol and netlogon missing server 2016]]></category>
		<category><![CDATA[SYSVOL and NETLOGON Shares Missing]]></category>
		<category><![CDATA[sysvol missing on new domain controller]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1964</guid>

					<description><![CDATA[<p>I recently had an issue where SYSVOL and NETLOGON shares missing on my newly promoted domain controller. It turns out the domain was in pretty bad shape so I had to fix domain controller replication, then proceed to figure out&#8230; <a href="https://thesysadminchannel.com/solved-sysvol-and-netlogon-shares-missing-2016-2019-domain-controller/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/solved-sysvol-and-netlogon-shares-missing-2016-2019-domain-controller/">[Solved] SYSVOL and NETLOGON Shares Missing on New DC</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I recently had an issue where <strong>SYSVOL and NETLOGON shares missing</strong> on my newly promoted domain controller.  It turns out the domain was in pretty bad shape so I had to <a href="https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/" rel="noopener noreferrer" target="_blank">fix domain controller replication</a>, then proceed to figure out why my SYSVOL and NETLOGON shares were not appearing by default.</p>
<h2>SYSVOL and NETLOGON Shares Missing on New DC Fix</h2>
<p>After a bit of searching around I was able to figure out the reason why.  This newly promoted domain controller was running on Server 2019 so I thought it was a bit odd that it was behaving this way. It turns out the fix works from 2012 R2 and newer.</p>
<p>With that being said lets go over the steps to resolve the <strong>missing Sysvol and Netlogon shares</strong> for your DC.</p>
<ul>
<li>Login to your Domain Controller that&#8217;s having the issue</li>
<li>Open <strong>Regedit</strong></li>
<li>Browse to: <strong>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters</strong></li>
<li>Set <strong>SysVolReady</strong> from 0 to <strong>1</strong></li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/09/Sysvol-Regedit.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/09/Sysvol-Regedit.png" alt="Sysvol Regedit missing sysvol and netlogon shares" width="896" height="497" class="aligncenter size-full wp-image-2374" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/09/Sysvol-Regedit.png?v=1600840182 896w, https://thesysadminchannel.com/wp-content/uploads/2020/09/Sysvol-Regedit-768x426.png?v=1600840182 768w" sizes="(max-width: 896px) 100vw, 896px" /></a><br />
&nbsp;</p>
<p>Once you&#8217;ve set the above registry key, the SYSVOL folder should be created so you can type in \\DC\Sysvol and it should work.  However, I noticed that this specific registry key didn&#8217;t fix my NETLOGON folder so in order to fix that issue here is what I did.</p>
<ul>
<li>While logged in to my domain controller</li>
<li>Navigate to C:\Windows\SYSVOL\domain</li>
<li>Create a new folder and name it scripts</li>
<li>Restart the netlogon service (or reboot the machine)</li>
</ul>
<p>&nbsp;</p>
<p>By now you the issue of your sysvol missing on new domain controller should be fixed as well as your netlogon shares missing on your server.  This article is pretty short and sweet but if you&#8217;re still having issues with domain controller replication, I&#8217;ve created a <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener noreferrer" target="_blank">video on Youtube</a> that I&#8217;ll link here as well.</p>
<p><iframe title="Fix SYSVOL and Domain Controller Replication | Active Directory DFSR Issues Resolved" width="640" height="360" src="https://www.youtube.com/embed/UWF-pVr1JHg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<p>The post <a href="https://thesysadminchannel.com/solved-sysvol-and-netlogon-shares-missing-2016-2019-domain-controller/">[Solved] SYSVOL and NETLOGON Shares Missing on New DC</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/solved-sysvol-and-netlogon-shares-missing-2016-2019-domain-controller/feed/</wfw:commentRss>
			<slash:comments>34</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1964</post-id>	</item>
		<item>
		<title>[Solved] SYSVOL Folders Not Replicating Across Domain Controllers</title>
		<link>https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/</link>
					<comments>https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Fri, 03 Apr 2020 06:56:15 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[check sysvol replication]]></category>
		<category><![CDATA[check sysvol replication status powershell]]></category>
		<category><![CDATA[force sysvol replication]]></category>
		<category><![CDATA[missing sysvol and netlogon shares 2016]]></category>
		<category><![CDATA[ntfrs sysvol not replicating]]></category>
		<category><![CDATA[policy definitions folder not replicating]]></category>
		<category><![CDATA[sysvol folder not replicating]]></category>
		<category><![CDATA[sysvol not replicating 2016]]></category>
		<category><![CDATA[sysvol not replicating 2019]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1963</guid>

					<description><![CDATA[<p>If you have ever had issues with NETLOGON or SYSVOL folders not replicating across domain controllers you know that it can be a huge pain in the butt. Whether it be your policy definitions folder not replicating or group policy&#8230; <a href="https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/">[Solved] SYSVOL Folders Not Replicating Across Domain Controllers</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you have ever had issues with NETLOGON or SYSVOL folders not replicating across domain controllers you know that it can be a huge pain in the butt.  Whether it be your policy definitions folder not replicating or group policy is just out of sync with the rest of your DCs.  It&#8217;s an issue that many sysadmins over time have had to overcome however, luckily for me, I was fortunate enough to have had it happen in my lab.  My issue was sysvol was not replicating on my 2019 domain controllers so not only did I need to be able to force sysvol replication, I needed to get to the root of the issue to figure out why.  Today we&#8217;re going to <strong>fix sysvol folders not replicating across domain controllers</strong>.</p>
<p><em>I have also posted a video of how to fix domain controller replication at the end of this post for those who prefer to watch the demo</em> 🙂</p>
<p>After checking the event viewer I am across several logs that seemed a bit concerning to me.</p>
<pre class="brush: plain; light: true; title: ; notranslate">
Log Name: DFS Replication
Source: DFSR
Date: 3/25/2020 1:04:30 PM
Event ID: 4612
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: PAC-DC02.ad.thesysadminchannel.com

Description:
The DFS Replication service initialized SYSVOL at local path C:\Windows\SYSVOL\domain and is waiting to perform initial replication. 
The replicated folder will remain in the initial synchronization state until it has replicated with its partner PAC-DC01.ad.thesysadminchannel.com. 
If the server was in the process of being promoted to a domain controller, the domain controller will not advertise and function as a domain controller until this issue is resolved. 
This can occur if the specified partner is also in the initial synchronization state, or if sharing violations are encountered on this server or the sync partner. 
If this event occurred during the migration of SYSVOL from File Replication service (FRS) to DFS Replication, changes will not replicate out until this issue is resolved. 
This can cause the SYSVOL folder on this server to become out of sync with other domain controllers. 
 
Additional Information: 
Replicated Folder Name: SYSVOL Share 
Replicated Folder ID: 33B02C74-D5A3-41A7-A1EB-7D526AA4A243 
Replication Group Name: Domain System Volume 
Replication Group ID: 3CA9F092-C1B4-4F46-B276-7FD034A8E03C 
Member ID: 2AED3E8C-B864-4939-8969-BC747CD672C5 
Read-Only: 0



Log Name: DFS Replication
Source: DFSR
Date: 3/25/2020 1:04:30 PM
Event ID: 5002
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: PAC-DC02.ad.thesysadminchannel.com
Description:
The DFS Replication service encountered an error communicating with partner PAC-DC01 for replication group Domain System Volume. 
 
Partner DNS address: PAC-DC01.ad.thesysadminchannel.com 
 
Optional data if available: 
Partner WINS Address: PAC-DC01 
Partner IP Address: 172.16.10.101 
 
The service will retry the connection periodically. 
 
Additional Information: 
Error: 1753 (There are no more endpoints available from the endpoint mapper.) 
Connection ID: 3CA9F092-C1B4-4F46-B276-7FD034A8E03C 
Replication Group ID: FD8F1538-9B92-4EF9-9E8E-E74512BC2149
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-4612-DFSR-Failure.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-4612-DFSR-Failure.png" alt="EventID-4612-DFSR-Failure" width="1283" height="482" class="aligncenter size-full wp-image-2124" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-4612-DFSR-Failure.png?v=1597892800 1283w, https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-4612-DFSR-Failure-1024x385.png?v=1597892800 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-4612-DFSR-Failure-768x289.png?v=1597892800 768w" sizes="(max-width: 1283px) 100vw, 1283px" /></a></p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-5002-DFSR-Failure.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-5002-DFSR-Failure.png" alt="EventID-5002-DFSR-Failure" width="1124" height="478" class="aligncenter size-full wp-image-2123" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-5002-DFSR-Failure.png?v=1597892797 1124w, https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-5002-DFSR-Failure-1024x435.png?v=1597892797 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/EventID-5002-DFSR-Failure-768x327.png?v=1597892797 768w" sizes="(max-width: 1124px) 100vw, 1124px" /></a></p>
<p>First things first, we need to determine which domain controller is going to act as the master server.  This needs to be the most updated DC in terms of policies because this will overwrite anything and everything that doesn&#8217;t match.</p>
<p>An example of this is if you create the policies on DC01, and those policies never replicate to DC02. DC01 is more up to date than DC02 so DC01 should be your master.</p>
<p>Once you have that all set, you can follow the steps in the video.</p>
<h2>Fix SYSVOL Folders Not Replicating Across Domain Controllers</h2>
<p><iframe title="Fix SYSVOL and Domain Controller Replication | Active Directory DFSR Issues Resolved" width="640" height="360" src="https://www.youtube.com/embed/UWF-pVr1JHg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<p>&nbsp;</p>
<p>Hopefully you found that very useful and now your sysvol replication is working as expected.  If you still have doubts, you can check out <a href="https://support.microsoft.com/en-us/help/2218556/how-to-force-an-authoritative-and-non-authoritative-synchronization-fo" rel="noopener noreferrer" target="_blank">Microsoft&#8217;s Documentation</a> for the official page.</p>
<p>The post <a href="https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/">[Solved] SYSVOL Folders Not Replicating Across Domain Controllers</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/solved-sysvol-folders-not-replicating-across-domain-controllers/feed/</wfw:commentRss>
			<slash:comments>27</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1963</post-id>	</item>
		<item>
		<title>Get Password Expiration Date Using Powershell</title>
		<link>https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory/</link>
					<comments>https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Mon, 02 Mar 2020 07:42:00 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[active directory expired password query]]></category>
		<category><![CDATA[get password expiration date powershell]]></category>
		<category><![CDATA[Get Password Expiration Date Using Powershell]]></category>
		<category><![CDATA[how to check when password expires in active directory powershell]]></category>
		<category><![CDATA[msds-userpasswordexpirytimecomputed]]></category>
		<category><![CDATA[powershell - get account expiration date]]></category>
		<category><![CDATA[powershell password expiration report]]></category>
		<category><![CDATA[powershell password expires in 7 days]]></category>
		<category><![CDATA[powershell script to get password expiration date]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=2075</guid>

					<description><![CDATA[<p>A while back I posted a Powershell script to check password expiration&#8217;s in your domain. It worked and it got the job done but as I got better with Powershell I decided to take another look at it and refine&#8230; <a href="https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory/">Get Password Expiration Date Using Powershell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A while back I posted a Powershell script to <a href="https://thesysadminchannel.com/powershell-script-check-password-expirations-in-active-directory/" rel="noopener noreferrer" target="_blank">check password expiration&#8217;s in your domain</a>.  It worked and it got the job done but as I got better with Powershell I decided to take another look at it and refine it. This time around I&#8217;ve turned it into a function with the ability to set specific days you want to filter from as well as explicitly adding the send email option.  I&#8217;ve also added a parameter so you can check specific users to see when the next time they&#8217;ll need to change their password.  Feel free to comment on the new script to <strong>Get Password Expiration Date Using Powershell</strong></p>
<h2>Get Password Expiration Date Using Powershell</h2>
<p>The only requirement is that you&#8217;ll need the Active Directory Powershell module to be able to query that the information stored in AD. Also, if you plan on using the send email parameter you&#8217;ll need to modify lines 88-92 so you can send it out of your own smtp server.</p>
<pre class="brush: powershell; title: ; notranslate">

Function Get-PasswordExpirationDate {
#requires -Module ActiveDirectory

&lt;#
.SYNOPSIS
    Checks to see if the account is X days within password expiration.
    For updated help and examples refer to -Online version.

.NOTES
    Name: Get-PasswordExpirationDate
    Version: 2.0
    Author: theSysadminChannel
    DateCreated: 2019-Dec-15

.LINK
    https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory -



.PARAMETER DaysWithinExpiration
    Set the number of days you want to check until the password is expired.  Valid options are 1 - 365.

.PARAMETER SendEmail
    Send an email to each user that has the EmailAddress populated to notify them that their password is nearning expiration.

.PARAMETER SamAccountName
    Specify the user accounts you want to check.  This option does not support the SendEmail or DaysWithinExpiration parameters.

.EXAMPLE
    Get-PasswordExpirationDate 15

.EXAMPLE
    Get-PasswordExpirationDate -DaysWithinExpiration 10 -SendEmail

.EXAMPLE
    Get-PasswordExpirationDate -SamAccountName Username1, username2

#&gt;

    [CmdletBinding(DefaultParameterSetName=&quot;AllAccounts&quot;)]
    param(
        [Parameter(
            Position = 0,
            Mandatory = $false,
            ParameterSetName = &quot;AllAccounts&quot;
        )]
        [ValidateRange(1,365)]
        [int]       $DaysWithinExpiration = 10,


        [Parameter(
            Mandatory = $false,
            ParameterSetName = &quot;AllAccounts&quot;
        )]
        [switch]    $SendEmail,


        [Parameter(
            Mandatory = $false,
            ParameterSetName = &quot;SpecificAccounts&quot;,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true
            )]
        [string[]]  $SamAccountName
    )

    BEGIN {}

    PROCESS {
        #Calculating the expired date from the domain's default password policy. -- Do Not Modify --
        $MaxPwdAge   = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.Days
        $expiredDate = (Get-Date).addDays(-$MaxPwdAge)

        #Calculating the number of days until you would like to begin notifying the users. -- Do Not Modify --
        $emailDate = (Get-Date).addDays(-($MaxPwdAge - $DaysWithinExpiration))

        #Since specific accounts were specified we'll output their password expiration dates regardless if they are within the expiration date
        #Use msDS-UserPasswordExpiryTimeComputed to calculate expiration date in case a fine grain password policy is used
        if ($PSBoundParameters.ContainsKey(&quot;SamAccountName&quot;)) {
            foreach ($User in $SamAccountName) {
                try {
                    $ADObject = Get-ADUser $User -Properties PasswordNeverExpires, PasswordLastSet, EmailAddress, msDS-UserPasswordExpiryTimeComputed
                    if ($ADObject.PasswordNeverExpires -eq $true) {
                        $DaysUntilExpired = &quot;NeverExpire&quot;
                      } else {
                        $ExpirationDate = Get-Date ([datetime]::FromFileTime($ADObject.'msDS-UserPasswordExpiryTimeComputed'))
                        $DaysUntilExpired = $ExpirationDate - (Get-Date) | select -ExpandProperty Days
                    }
                    [PSCustomObject]@{
                        SamAccountName   = $ADObject.samaccountname.toLower()
                        PasswordLastSet  = $ADObject.PasswordLastSet
                        ExpirationDate   = $ExpirationDate
                        DaysUntilExpired = $DaysUntilExpired
                        EmailAddress     = $ADObject.EmailAddress
                    } 
               } catch {
                    Write-Error $_.Exception.Message
                }
            }
        } else {
            $ExpiredAccounts = Get-ADUser -Filter {(PasswordLastSet -lt $EmailDate) -and (PasswordLastSet -gt $ExpiredDate) -and (PasswordNeverExpires -eq $false) -and (Enabled -eq $true)} -Properties PasswordNeverExpires, PasswordLastSet, EmailAddress
            foreach ($ADObject in $ExpiredAccounts) {
                try {
                    $DaysUntilExpired = $ADObject.PasswordLastSet - $ExpiredDate | select -ExpandProperty Days
                    if ($PSBoundParameters.ContainsKey(&quot;SendEmail&quot;) -and $null -ne $ADObject.EmailAddress) {
                        #Setting up email parameters to send a notification email to the user
                        $From       = &quot;example@thesysadminchannel.com&quot;
                        $Subject    = &quot;Your Password Will Expire in &quot; + $DaysUntilExpired + &quot; days&quot;
                        $Body       = &quot;Hello,`n`nThis email is to notify you that your password will expire in &quot; + $DaysUntilExpired + &quot; days.`n`nPlease consider changing it to avoid any service interruptions.`n`nThank you,`nThe I.T. Department.&quot;
                        $smtpServer = &quot;mail.thesysadminchannel.com&quot;
                        #$CC        =  &quot;cc1@thesysadminchannel.com&quot;, &quot;cc2@thesysadminchannel.com&quot;

                        Send-MailMessage -To $($ADObject.EmailAddress) -From $From -Subject $Subject -BodyAsHtml $Body -SmtpServer $SmtpServer #-Priority High -Cc $CC
                    }
                    [PSCustomObject]@{
                        SamAccountName   = $ADObject.samaccountname.toLower()
                        PasswordLastSet  = $ADObject.PasswordLastSet
                        DaysUntilExpired = $DaysUntilExpired
                        EmailAddress     = $ADObject.EmailAddress
                    }
                } catch {
                    Write-Error $_.Exception.Message
                }
            }
        }
    }

    END {}

}

</pre>
<p>&nbsp;</p>
<p>Once you call the function here&#8217;s an example of what the output would look like.<br />
<a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-DaysWithinExpiration-10-SendEmail.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-DaysWithinExpiration-10-SendEmail.png" alt="Get-PasswordExpirationDate-DaysWithinExpiration-10-SendEmail" width="1219" height="692" class="aligncenter size-full wp-image-2079" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-DaysWithinExpiration-10-SendEmail.png?v=1597602731 1219w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-DaysWithinExpiration-10-SendEmail-1024x581.png?v=1597602731 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-DaysWithinExpiration-10-SendEmail-768x436.png?v=1597602731 768w" sizes="(max-width: 1219px) 100vw, 1219px" /></a></p>
<p><div id="attachment_2081" style="width: 949px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/PasswordNotificationEmail.png" target="_blank" rel="noopener noreferrer"><img decoding="async" aria-describedby="caption-attachment-2081" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/PasswordNotificationEmail.png" alt="PasswordNotificationEmail" width="939" height="462" class="size-full wp-image-2081" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/PasswordNotificationEmail.png?v=1597603934 939w, https://thesysadminchannel.com/wp-content/uploads/2020/08/PasswordNotificationEmail-768x378.png?v=1597603934 768w" sizes="(max-width: 939px) 100vw, 939px" /></a><p id="caption-attachment-2081" class="wp-caption-text">You can customize the email to send as high priority or add CC if you like when you specify the -SendEmail parameter</p></div><br />
&nbsp;</p>
<p>Here&#8217;s an example if you wanted to specify users.  If the password is set to not expire it will display NeverExpire.  It will also error out if a user is not found in Active Directory.<br />
<a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-SamAccountName.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-SamAccountName.png" alt="Get-PasswordExpirationDate-SamAccountName" width="1219" height="380" class="aligncenter size-full wp-image-2083" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-SamAccountName.png?v=1597605461 1219w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-SamAccountName-1024x319.png?v=1597605461 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-PasswordExpirationDate-SamAccountName-768x239.png?v=1597605461 768w" sizes="(max-width: 1219px) 100vw, 1219px" /></a></p>
<p>So now that we&#8217;ve got a working Powershell script to query Active Directory for expired passwords,  we can also use this as a Powershell password expiration report which is really nice.</p>
<p>All in all I wanted to say thanks a lot for taking the time to visit and hopefully you can make use of the <strong>get password expiration date Powershell</strong> script in your environment.  If you like these kinds of posts, feel free to check out our <a href="https://thesysadminchannel.com/powershell/" rel="noopener noreferrer" target="_blank">gallery full of useful real-world scripts</a>.  Don&#8217;t forget to check out our <a href="https://www.youtube.com/c/TheSysadminChannel" rel="noopener noreferrer" target="_blank">Youtube Page for sysadmin video content</a>.</p>
<p>The post <a href="https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory/">Get Password Expiration Date Using Powershell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-password-expiration-date-using-powershell-active-directory/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2075</post-id>	</item>
		<item>
		<title>Install RSAT for Windows 10 Version 1809, 1903 and Later</title>
		<link>https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/</link>
					<comments>https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Tue, 04 Feb 2020 06:52:35 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[active directory users and computers windows 10 1809]]></category>
		<category><![CDATA[enable rsat windows 10 1903 powershell]]></category>
		<category><![CDATA[how to install rsat]]></category>
		<category><![CDATA[install rsat windows 10 1809]]></category>
		<category><![CDATA[rsat 1809]]></category>
		<category><![CDATA[rsat not showing in windows 10 features]]></category>
		<category><![CDATA[rsat windows 10 1809]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1875</guid>

					<description><![CDATA[<p>In the previous versions of Windows, you always had to download and install the Remote Server Administration Tools aka RSAT from Microsoft&#8217;s page. Many people complained about the fact that every time you would upgrade to a later build, it&#8230; <a href="https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/">Install RSAT for Windows 10 Version 1809, 1903 and Later</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the previous versions of Windows, you always had to download and install the Remote Server Administration Tools aka RSAT from Microsoft&#8217;s page.  Many people complained about the fact that every time you would upgrade to a later build, it would wipe out the tools and you would have to reinstall them. With more recent builds of Windows 10, the remote server administration tools are now part of the build as a Feature and can by accessed by enabling the Feature on Demand.   Let&#8217;s take a look and install RSAT for Windows 10 Version 1809, 1903 and later using the GUI method as well as using the Powershell method.</p>
<h2>Install RSAT for Windows 10 Version 1809, 1903 and Later in the GUI</h2>
<p>Although I much prefer the Powershell method, we&#8217;ll start off with the GUI method.</p>
<ul>
<li>Open Settings -> Apps -> Optional Features</li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-1.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-1.png" alt="Apps Settings 1" width="1279" height="642" class="aligncenter size-full wp-image-2010" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-1.png?v=1597013336 1279w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-1-1024x514.png?v=1597013336 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-1-768x386.png?v=1597013336 768w" sizes="(max-width: 1279px) 100vw, 1279px" /></a></p>
<p>&nbsp;</p>
<ul>
<li>Select the tools you want to install and click install</li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-2.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-2.png" alt="Apps Settings 2" width="1279" height="763" class="aligncenter size-full wp-image-2011" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-2.png?v=1597013415 1279w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-2-125x75.png?v=1597013415 125w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-2-1024x611.png?v=1597013415 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-2-768x458.png?v=1597013415 768w" sizes="(max-width: 1279px) 100vw, 1279px" /></a><br />
&nbsp;</p>
<h2>Install RSAT for Windows 10 Version 1809, 1903 and Later in Powershell</h2>
<ul>
<li>Open <strong>Powershell</strong> as <strong>Administrator</strong></li>
<li>Type: <strong>Get-WindowsCapability -Name RSAT* -Online</strong></li>
</ul>
<div id="attachment_2015" style="width: 1349px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-WindowsCapability-Name-RSAT.png" target="_blank" rel="noopener noreferrer"><img decoding="async" aria-describedby="caption-attachment-2015" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-WindowsCapability-Name-RSAT.png" alt="Get-WindowsCapability -Name RSAT" width="1339" height="752" class="size-full wp-image-2015" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-WindowsCapability-Name-RSAT.png?v=1597111236 1339w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-WindowsCapability-Name-RSAT-1024x575.png?v=1597111236 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-WindowsCapability-Name-RSAT-768x431.png?v=1597111236 768w" sizes="(max-width: 1339px) 100vw, 1339px" /></a><p id="caption-attachment-2015" class="wp-caption-text">Take note of the name and status</p></div>
<ul>
<li>To install the feature, you can either pipe the command to Add-WindowsCapability -or-</li>
<li><strong>Add-WindowsCapability -Name <em>Name-of-Feature</em> -Online</strong></li>
</ul>
<div id="attachment_2018" style="width: 1349px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Add-WindowsCapability-Name-RSAT.png" target="_blank" rel="noopener noreferrer"><img decoding="async" aria-describedby="caption-attachment-2018" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Add-WindowsCapability-Name-RSAT.png" alt="Add-WindowsCapability -Name RSAT" width="1339" height="752" class="size-full wp-image-2018" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Add-WindowsCapability-Name-RSAT.png?v=1597111788 1339w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Add-WindowsCapability-Name-RSAT-1024x575.png?v=1597111788 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Add-WindowsCapability-Name-RSAT-768x431.png?v=1597111788 768w" sizes="(max-width: 1339px) 100vw, 1339px" /></a><p id="caption-attachment-2018" class="wp-caption-text">In this example, I&#8217;m installing the RSAT: Active Directory Domain Services and Lightweight Directory Services Tools</p></div>
<ul>
<li>The items should now be in the <strong>Start Menu</strong> -> <strong>Windows Administrative Tools</strong></li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-3.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-3.png" alt="Apps Settings 3" width="1024" height="628" class="aligncenter size-full wp-image-2012" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-3.png?v=1597013424 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Apps-Settings-3-768x471.png?v=1597013424 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>I&#8217;d love to hear your feedback and I hope you can now add RSAT easily using the Features on Demand.  As always be sure to check out our Youbtube Channel <a href="https://www.youtube.com/c/TheSysadminChannel" rel="noopener noreferrer" target="_blank">https://www.youtube.com/c/theSysadminChannel</a> or if you want more Server Administration content, check out our <a href="https://thesysadminchannel.com/server-administration/" rel="noopener noreferrer" target="_blank">Server Administration Category</a>.  There is a lot of useful information on both links.</p>
<p>The post <a href="https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/">Install RSAT for Windows 10 Version 1809, 1903 and Later</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/install-rsat-for-windows-10-version-1809-1903-and-later/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1875</post-id>	</item>
		<item>
		<title>Get Direct Reports in Active Directory Using Powershell (Recursive)</title>
		<link>https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/</link>
					<comments>https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Wed, 29 Jan 2020 07:39:03 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[get aduser reports]]></category>
		<category><![CDATA[Get Direct Reports in Active Directory Using Powershell (Recursive)]]></category>
		<category><![CDATA[get-aduser recursive manager]]></category>
		<category><![CDATA[powershell export direct reports to csv]]></category>
		<category><![CDATA[powershell get aduser direct reports recursive]]></category>
		<category><![CDATA[powershell get aduser subordinates]]></category>
		<category><![CDATA[powershell get all reports]]></category>
		<category><![CDATA[powershell get all users under a manager]]></category>
		<category><![CDATA[powershell get direct reports recursive]]></category>
		<category><![CDATA[powershell get org chart from active directory]]></category>
		<category><![CDATA[powershell list users with direct reports]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1960</guid>

					<description><![CDATA[<p>It might come in handy from time to time to drill down on a manager&#8217;s direct reports in Active Directory. A good use case is if a director or VP wants to send an email to all of their direct&#8230; <a href="https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/">Get Direct Reports in Active Directory Using Powershell (Recursive)</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It might come in handy from time to time to drill down on a manager&#8217;s direct reports in Active Directory.  A good use case is if a director or VP wants to send an email to all of their direct reports, and the direct reports of those direct reports.  Another use case would be if you were doing an audit comparing your HR system to what is in Active Directory.  What ever the reason might be,  you can use this script to get direct reports in active directory using Powershell. Pretty neat!! </p>
<p><em>If you have any questions regarding the script, feel free to leave me a comment and I&#8217;ll do my best to get back to you.</em></p>
<h2>Get Direct Reports in Active Directory Using Powershell</h2>
<pre class="brush: powershell; title: ; notranslate">

Function Get-DirectReport {
#requires -Module ActiveDirectory

&lt;#
.SYNOPSIS
    This script will get a user's direct reports recursively from ActiveDirectory unless specified with the NoRecurse parameter.
    It also uses the user's EmployeeID attribute as a way to exclude service accounts and/or non standard accounts that are in the reporting structure.
 
.NOTES
    Name: Get-DirectReport
    Author: theSysadminChannel
    Version: 1.0
    DateCreated: 2020-Jan-28
 
.LINK
    https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive -   
 
.PARAMETER SamAccountName
    Specify the samaccountname (username) to see their direct reports.
 
.PARAMETER NoRecurse
    Using this option will not drill down further than one level.
 
.EXAMPLE
    Get-DirectReport username
 
.EXAMPLE
    Get-DirectReport -SamAccountName username -NoRecurse
 
.EXAMPLE
    &quot;username&quot; | Get-DirectReport
#&gt;

    [CmdletBinding()]
    param(
        [Parameter(
            Mandatory = $false,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true
        )]

        [string]  $SamAccountName,

        [switch]  $NoRecurse
    )

    BEGIN {}

    PROCESS {
        $UserAccount = Get-ADUser $SamAccountName -Properties DirectReports, DisplayName
        $UserAccount | select -ExpandProperty DirectReports | ForEach-Object {
            $User = Get-ADUser $_ -Properties DirectReports, DisplayName, Title, EmployeeID
            if ($null -ne $User.EmployeeID) {
                if (-not $NoRecurse) {
                    Get-DirectReport $User.SamAccountName
                }
                [PSCustomObject]@{
                    SamAccountName     = $User.SamAccountName
                    UserPrincipalName  = $User.UserPrincipalName
                    DisplayName        = $User.DisplayName
                    Manager            = $UserAccount.DisplayName
                }
            }
        }
    }

    END {}

}

</pre>
<p>&nbsp;</p>
<p>Like always I like to test out my scripts to ensure the content that I am publishing is legit for people to use so I created a sample org chart.  This is what that looks like.<br />
<a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart.png" alt="Sample org chart" width="1072" height="315" class="aligncenter size-full wp-image-2005" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart.png 1072w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart-1024x301.png 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart-768x226.png 768w" sizes="(max-width: 1072px) 100vw, 1072px" /></a></p>
<p>&nbsp;<br />
With the above already created in my lab let&#8217;s run <strong>Get-DirectReport -SamAccountName cio | Sort-Object samaccountname</strong> so we can quickly get an org chart for everyone under our CIO.  By default it does run recursively so I&#8217;ll also run the <strong>-NoRecurse parameter</strong> to only get the people that are reporting directly to the CIO.  </p>
<p>This is what the output looks like.</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname.png" alt="Get-DirectReport -samaccountname" width="1099" height="481" class="aligncenter size-full wp-image-1999" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname.png?v=1596953798 1099w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname-1024x448.png?v=1596953798 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname-768x336.png?v=1596953798 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<p>I&#8217;d love to hear your feedback and I hope you can use this in your environment if you ever need a quick org chart using Powershell.  As always be sure to check out our Youbtube Channel <a href="https://www.youtube.com/c/TheSysadminChannel" rel="noopener noreferrer" target="_blank">https://www.youtube.com/c/theSysadminChannel</a> or if you want more Powershell scripts or content, check out our <a href="https://thesysadminchannel.com/powershell/" rel="noopener noreferrer" target="_blank">Powershell Category</a>.  There is a lot of useful information on both links.</p>
<p>The post <a href="https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/">Get Direct Reports in Active Directory Using Powershell (Recursive)</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1960</post-id>	</item>
		<item>
		<title>Demote or Decommission A Domain Controller (Best Practice)</title>
		<link>https://thesysadminchannel.com/demote-or-decommission-a-domain-controller-best-practice/</link>
					<comments>https://thesysadminchannel.com/demote-or-decommission-a-domain-controller-best-practice/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Tue, 29 Oct 2019 05:08:45 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Decommission A Domain Controller]]></category>
		<category><![CDATA[demote domain controller]]></category>
		<category><![CDATA[demote domain controller 2012]]></category>
		<category><![CDATA[demote domain controller 2012 r2 powershell]]></category>
		<category><![CDATA[demote domain controller 2012 r2 remove dns delegation]]></category>
		<category><![CDATA[force demote domain controller 2016]]></category>
		<category><![CDATA[how to remove a domain controller that is no longer available]]></category>
		<category><![CDATA[manually remove domain controller]]></category>
		<category><![CDATA[remove failed domain controller 2012 r2]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1968</guid>

					<description><![CDATA[<p>Throughout a sysadmin&#8217;s career it&#8217;s very common to have demoted or decommissioned a domain controller in your domain. With new versions of Windows Server coming out every couple of years, it&#8217;s always a good idea to be somewhat up to&#8230; <a href="https://thesysadminchannel.com/demote-or-decommission-a-domain-controller-best-practice/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/demote-or-decommission-a-domain-controller-best-practice/">Demote or Decommission A Domain Controller (Best Practice)</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Throughout a sysadmin&#8217;s career it&#8217;s very common to have demoted or decommissioned a domain controller in your domain.  With new versions of Windows Server coming out every couple of years, it&#8217;s always a good idea to be somewhat up to date.  I&#8217;m not saying have the latest and greatest every time all the time, I&#8217;m just saying it&#8217;s a good idea not to be several versions behind.  But what about those up and coming sysadmins that might be new to this?  Or desktop support folks that want to take that extra time to create a home lab and practice on their off time.  This article is going to go step by step on how to <strong>decommission a domain controller</strong> in your environment using best practices. </p>
<p>In Server 2008 R2 it was a little trickier to demote or decommission a domain controller because you had to use DCPromo, but with the addition of Server 2012 R2, it has become a whole lot easier.  As easy as clicking a few buttons.</p>
<p><em>If you have any questions please leave a comment below and I&#8217;ll do my best to get back to you.</em></p>
<h2>Demote or Decommission A Domain Controller</h2>
<p>Follow the steps here to decommission a domain controller</p>
<ul>
<li><a href="https://thesysadminchannel.com/how-to-transfer-fsmo-roles-in-server-2019-using-powershell/" rel="noopener noreferrer" target="_blank">Transfer any FSMO roles</a> to a DC that&#8217;s going to remain online</li>
<li>Remove Active Directory Domain Services role from DC</li>
<li>Demote domain controller to a member server</li>
<li>Clean up references in DNS manager</li>
<li>Remove server from Sites and Services</li>
<li>Update static IP addresses that are pointing to decommissioned domain controller</li>
</ul>
<p>&nbsp;<br />
The process in 2012 R2 and later makes it so much easier to accomplish this task that future generations don&#8217;t have to deal with the struggles of sysadmins in the past.</p>
<h2>Demote A Domain Controller Using Powershell</h2>
<p>Here is the Powershell commands you can use to demote a domain controller.  </p>
<pre class="brush: powershell; title: ; notranslate">

Import-Module ADDSDeployment
Uninstall-ADDSDomainController -DemoteOperationMasterRole: $true -DnsDelegationRemovalCredential (Get-Credential) -RemoveDnsDelegation: $true -Force

</pre>
<p>&nbsp;</p>
<h2>Demote a Domain Controller in Active Directory Demo</h2>
<p><iframe title="How To Decommission a Domain Controller (Best Practice)" width="640" height="360" src="https://www.youtube.com/embed/GRXjBgck2bg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<p>The post <a href="https://thesysadminchannel.com/demote-or-decommission-a-domain-controller-best-practice/">Demote or Decommission A Domain Controller (Best Practice)</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/demote-or-decommission-a-domain-controller-best-practice/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1968</post-id>	</item>
	</channel>
</rss>
