<?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 - HackBuddies</title>
	<atom:link href="https://www.hackbuddies.com/category/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.hackbuddies.com/category/active-directory/</link>
	<description>Solutions and optimizations for your daily IT issues and work</description>
	<lastBuildDate>Sat, 17 Oct 2020 15:07:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.hackbuddies.com/wp-content/uploads/2019/07/cropped-apple-icon-152x152-150x150.png</url>
	<title>Active Directory Archives - HackBuddies</title>
	<link>https://www.hackbuddies.com/category/active-directory/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Generate ACL Report of File Share with PowerShell to CSV</title>
		<link>https://www.hackbuddies.com/generate-acl-report-of-file-share-with-powershell-to-csv/</link>
					<comments>https://www.hackbuddies.com/generate-acl-report-of-file-share-with-powershell-to-csv/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 12 Jun 2020 09:48:55 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=775</guid>

					<description><![CDATA[<p>I think all of you who are administrating file servers, file shares and their permissions, maybe also together with colleagues, will know this situation. Especially at large and complex structures, there are some permissions for users directly granted at the folder and not via the Active Directory / LDAP group. Maybe there are also some [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/generate-acl-report-of-file-share-with-powershell-to-csv/">Generate ACL Report of File Share with PowerShell to CSV</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I think all of you who are administrating file servers, file shares and their permissions, maybe also together with colleagues, will know this situation. Especially at large and complex structures, there are some permissions for users directly granted at the folder and not via the Active Directory / LDAP group. Maybe there are also some wrong AD groups set or inheritance is broken. I want to show you how you can recursively generate an Access Control List Report (NTFS permissions), which is a good basis to clean up your file share permissions. You can Generate ACL Report FileShare with PowerShell.</p>
<p>Basically it is a very simple script, but I will quickly go through it. Of course you need to define the UNC path to the file share or folder. Then you will loop through all the existing directories with a Foreach. At each folder you will get the permissions with <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-acl?view=powershell-7" target="_blank" rel="noopener noreferrer">Get-ACL</a>. Then you need another Foreach to get through all the granted permissions which are inherited or directly set. Then you will add each line to your report and finally export it as a CSV file for further processing. That&#8217;s it!</p>
<pre>$FolderPath = dir -Directory -Path "\\fileserver\fileshare"
$Report = @()
Foreach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
foreach ($Access in $acl.Access)
{
$Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
Group or
User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Report += New-Object -TypeName PSObject -Property $Properties
}
}
$Report | Export-Csv -path "C:\scripts\FolderPermissions.csv"</pre>
<p>You can extend this script by sending the report as email message directly via PowerShell, <a href="https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/">look here</a>. You can also create a scheduled task / cronjob for this script to Generate ACL Report FileShare periodically.</p>
<p>The post <a href="https://www.hackbuddies.com/generate-acl-report-of-file-share-with-powershell-to-csv/">Generate ACL Report of File Share with PowerShell to CSV</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/generate-acl-report-of-file-share-with-powershell-to-csv/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Get Inactive Computers In Active Directory From Specific Organizational Unit With PowerShell</title>
		<link>https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/</link>
					<comments>https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 18 Apr 2020 15:22:55 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=647</guid>

					<description><![CDATA[<p>From time to time you might want to clean up your Active Directory by moving or removing inactive Computer Objects. But why should you do this? On the one hand, you do not keep unnecessary inactive objects in your Active Directory. On the other hand, you can also save licenses if you also delete these [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/">Get Inactive Computers In Active Directory From Specific Organizational Unit With PowerShell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>From time to time you might want to clean up your Active Directory by moving or removing inactive Computer Objects. But why should you do this? On the one hand, you do not keep unnecessary inactive objects in your Active Directory. On the other hand, you can also save licenses if you also delete these inactive computers. Let&#8217;s say you are also using System Center Configuration Manager (SCCM), which can also be cleaned in this action.</p>
<p>This can be fulfilled easily by using a very short but effective PowerShell Inactive Computers script. Simply define the Organizational Unit (OU) you want to use as a SearchBase, specfiy the days of inactivity and that&#8217;s it!<br />
The script will automatically subtract the amount of inactive days from the current date/time and will search the defined OU with the Get-ADComputer command. It will use the attribute <strong>LastLogonTimeStamp</strong> which you can also check in the Attribute Editor of the GUI.</p>
<pre>$TargetOU = "OU=&lt;SubUnit&gt;,OU=&lt;MainUnit&gt;,DC=&lt;domainName&gt;,DC=com"
$DaysInactive = 90
$time = (Get-Date).Adddays(-($DaysInactive))
Get-ADComputer -SearchBase $TargetOU -Filter {LastLogonTimeStamp -lt $time} | Select-Object Name</pre>
<p>Of course you could improve this simple PowerShell Inactive Computers script by adapting the output to a CSV file. Or by selecting more attributes. I would recommend you to create a scheduled task for the script and extend it by <a href="https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/">sending a HTML email/report</a>, so you do not forget to clean up your inactive clients.</p>
<p>You can check out all options of the Get-ADComputer command at <a href="https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-adcomputer?view=win10-ps" target="_blank" rel="noopener noreferrer">Microsoft Docs</a></p>
<p>The post <a href="https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/">Get Inactive Computers In Active Directory From Specific Organizational Unit With PowerShell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Export Active Directory Groups and their Members from a specific Organizational Unit as CSV with PowerShell</title>
		<link>https://www.hackbuddies.com/export-active-directory-groups-and-their-members-from-a-specific-organizational-unit-as-csv-with-powershell/</link>
					<comments>https://www.hackbuddies.com/export-active-directory-groups-and-their-members-from-a-specific-organizational-unit-as-csv-with-powershell/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 16 Feb 2020 10:40:31 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=620</guid>

					<description><![CDATA[<p>I wanted to share a simple but effective PowerShell script with you. It is especially useful, if there are a lot of groups distributed in different Organizational Units. They may manage the access to file shares on your file servers and you used only Global Security groups in Active Directory for this purpose. So, we [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/export-active-directory-groups-and-their-members-from-a-specific-organizational-unit-as-csv-with-powershell/">Export Active Directory Groups and their Members from a specific Organizational Unit as CSV with PowerShell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I wanted to share a simple but effective PowerShell script with you. It is especially useful, if there are a lot of groups distributed in different Organizational Units. They may manage the access to file shares on your file servers and you used only Global Security groups in Active Directory for this purpose. So, we want to export all these Global Security groups in the specific OU, but also all of their members to create a huge table or matrix. You can send this table afterwards to the corresponding manager for example, so he can review the currently set permissions to the file shares.</p>
<p>Feel free to adapt the script or write some interesting ideas how to extend it in the comments 🙂</p>
<pre># Define date, output file and OU
$DateTime = Get-Date -f "yyyy-MM-dd_hh-mm" 
$OutputFile = "C:\scripts\" + $DateTime + "-ADGroupsAndMembers.csv"
$TargetOU = "OU=&lt;SubUnit&gt;,OU=&lt;MainUnit&gt;,DC=&lt;domainName&gt;,DC=com"

# Check OU and set filter for Global Security Groups
$Groups = Get-ADGroup -SearchBase $TargetOU -filter {GroupCategory -eq "Security" -and GroupScope -ne "DomainLocal"}

$Table = @()

$Record = @{
"Group Name" = ""
"Name" = ""
"Username" = ""
}

Foreach ($Group in $Groups) {
    $Arrayofmembers = Get-ADGroupMember -identity $Group -recursive | Select-Object name,samaccountname
        foreach ($Member in $Arrayofmembers) {
            $Record."Group Name" = $Group
            $Record."Name" = $Member.name
            $Record."UserName" = $Member.samaccountname
            $objRecord = New-Object PSObject -property $Record
            $Table += $objrecord
     }
}

$Table | Sort-Object Name | Export-Csv $OutputFile -NoTypeInformation -Encoding UTF8</pre>
<p>The post <a href="https://www.hackbuddies.com/export-active-directory-groups-and-their-members-from-a-specific-organizational-unit-as-csv-with-powershell/">Export Active Directory Groups and their Members from a specific Organizational Unit as CSV with PowerShell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/export-active-directory-groups-and-their-members-from-a-specific-organizational-unit-as-csv-with-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Move Computers From .TXT File To Different OU In Active Directory With PowerShell</title>
		<link>https://www.hackbuddies.com/move-computer-accounts-from-txt-file-to-different-ou-in-active-directory-with-powershell/</link>
					<comments>https://www.hackbuddies.com/move-computer-accounts-from-txt-file-to-different-ou-in-active-directory-with-powershell/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 12 Sep 2019 07:50:57 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=466</guid>

					<description><![CDATA[<p>Imagine the following situation: You want to bulk move Computers to different OU. You already use a tool to check your Active Directory for inactive devices (e.g. Last Logon Date 100 days before). This tool offers the possibility to export these old computers to a .TXT file. Before deleting them completely, you may want to [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/move-computer-accounts-from-txt-file-to-different-ou-in-active-directory-with-powershell/">Move Computers From .TXT File To Different OU In Active Directory With PowerShell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">

Imagine the following situation: You want to bulk move Computers to different OU.
You already use a tool to check your Active Directory for inactive devices (e.g. Last Logon Date 100 days before). This tool offers the possibility to export these old computers to a .TXT file. Before deleting them completely, you may want to move them to a different Organizational Unit (OU) to keep them for a few more days. Instead of moving them manually, use this simple PowerShell script which accepts a .TXT file as input, reads the computer names line by line and loops through them.
<pre># Specify path to the text file with the computer account names.
$computers = Get-Content \\PathToScript\ComputersToDelete.txt

# Specify path to the OU where computers will be moved.
$TargetOU = "OU=Users,OU=&lt;SubUnit&gt;,OU=&lt;MainUnit&gt;,DC=&lt;domainName&gt;,DC=com"

# Move Computers to the new OU
ForEach($computer in $computers){
    Get-ADComputer $computer | Move-ADObject -TargetPath $TargetOU
}</pre>
</div>
Of course you could combine that with the following script: <a href="https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/">Get Inactive Computers</a>

If you are interested in the full possibilites of Get-ADComputer, you can check <a href="https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-adcomputer?view=win10-ps" target="_blank" rel="noopener noreferrer">Microsoft Docs </a>to Move Computers to different OU

<!-- /wp:post-content --><p>The post <a href="https://www.hackbuddies.com/move-computer-accounts-from-txt-file-to-different-ou-in-active-directory-with-powershell/">Move Computers From .TXT File To Different OU In Active Directory With PowerShell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/move-computer-accounts-from-txt-file-to-different-ou-in-active-directory-with-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sending HTML Email with AD User Groups</title>
		<link>https://www.hackbuddies.com/sending-html-email-with-ad-user-groups/</link>
					<comments>https://www.hackbuddies.com/sending-html-email-with-ad-user-groups/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 22 Jul 2019 05:08:32 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=293</guid>

					<description><![CDATA[<p>An inquiry, which occurs very often in daily business: &#8220;What permissions does a specific user have?&#8221; What about sending a HTML Email with AD User Groups to the requestor?In most cases the Active Directory groups represent file access, system access and many more. So, exporting these groups would be a good way. Due to the [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/sending-html-email-with-ad-user-groups/">Sending HTML Email with AD User Groups</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">
<p>An inquiry, which occurs very often in daily business: &#8220;What permissions does a specific user have?&#8221; What about sending a HTML Email with AD User Groups to the requestor?<br />In most cases the Active Directory groups represent file access, system access and many more. So, exporting these groups would be a good way. Due to the fact that I did not want to start up my PowerShell for a CSV export which is then manually sent to the user every time, the following idea came up:</p>
<p>What about writing a PowerShell script, which just asks for the username and the email address of the superior who wants to see and check the permissions? After feeding the script with these two inputs, the Active Directory groups are queried and automatically sent to the superior in a HTML-formatted email. Very simple and time-saving!<br />After that I had the idea to extend the script with the &#8220;Description&#8221; field of the Active Directory groups. Thus, not just the group name but also the corresponding description gets exported and sent.</p>
<h2>PowerShell Script</h2>
<pre>$UserName = (Read-Host "Username")<br />$EmailSuperior = (Read-Host "Email address of superior")<br /><br />$style = "&lt;style&gt;BODY{font-family: Arial; font-size: 10pt;}"<br />$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"<br />$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"<br />$style = $style + "TD{border: 1px solid black; padding: 5px; }"<br />$style = $style + "&lt;/style&gt;"<br /><br /># Get group memberships from reference user, sort them alphabetically and export to TXT file<br /># Define parameters for mailing and send mail to IT-responsible person to review permissions<br />$Permissions = Get-ADPrincipalGroupMembership -Identity $UserName| Get-ADGroup -Properties * | Select name, description | Sort-Object -Property name | ConvertTo-Html -Head $style<br />$SmtpServer = 'smtp.yourdomain.com'<br />$SmtpPort = 587<br />$FromSender = 'admin@yourdomain.com'<br />$Subject = 'User permission check: ' + $UserName<br /><br /># Email Body Set Here, Note You can use HTML, including Images.<br />$Body ="<br />Hello,&lt;br&gt;<br />&lt;br&gt;<br />The permissions of user &lt;B&gt;$UserName&lt;/B&gt; are set as below. Please check and review them.&lt;br&gt;<br />&lt;hr&gt;<br />&lt;br&gt;<br />&lt;B&gt;Permissions:&lt;/B&gt;&lt;br&gt;<br />$Permissions<br />&lt;br&gt;<br />"<br /><br />Send-MailMessage -SmtpServer $SmtpServer -Port $SmtpPort -From $FromSender -To $EmailSuperior -Bcc $FromSender -Subject $Subject -Encoding "UTF8" -Body $Body -BodyAsHtml</pre>
<p>This script will generate the following email message. Please note that I removed the original permissions and username and replaced it with placeholders 🙂</p>
<p>So that&#8217;s how you are sending HTML Email with AD User Groups. Please check up details regarding the Send-MailMessage command directly at <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7" target="_blank" rel="noopener noreferrer">Microsoft Docs</a></p>
<p>Let me know your thoughts in the comment section. Of course you can use this HTML email part in other scripts too, for example to send inactive computer list to the responsible person like <a href="https://www.hackbuddies.com/get-inactive-computers-in-active-directory-from-specific-organizational-unit-with-powershell/">here</a></p>
<h2>Output of the Script</h2>
<hr />
<p><em>Hello,</em></p>
<p><em>The permissions of user <strong>&lt;USERNAME&gt;</strong> are set as below. Please check and review them.<br /></em></p>
<p><em><strong>Permissions:</strong></em></p>
<table>
<tbody>
<tr>
<td>
<p><em><strong>name</strong></em></p>
</td>
<td>
<p><em><strong>description</strong></em></p>
</td>
</tr>
<tr>
<td>
<p><em>Permission1</em></p>
</td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td>
<p><em>Permission2</em></p>
</td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td>
<p><em>Permission3</em></p>
</td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td>
<p><em>Permission4</em></p>
</td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td>
<p><em>Permission5</em></p>
</td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission6</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission7</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission8</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission9</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission10</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
<tr>
<td><em>Permission</em></td>
<td>
<p><em>Description from AD here</em></p>
</td>
</tr>
</tbody>
</table>
</div>

<p>&nbsp;</p>
<p>The post <a href="https://www.hackbuddies.com/sending-html-email-with-ad-user-groups/">Sending HTML Email with AD User Groups</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/sending-html-email-with-ad-user-groups/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Analyze why an user gets locked out in Active Directory</title>
		<link>https://www.hackbuddies.com/analyze-why-an-user-gets-locked-out-in-active-directory/</link>
					<comments>https://www.hackbuddies.com/analyze-why-an-user-gets-locked-out-in-active-directory/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 19 Jul 2019 12:36:10 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=315</guid>

					<description><![CDATA[<p>Recently I wanted to connect to a machine with my admin user but then I realized that this user had been locked out in Active Directory. The counter for bad passwords is relatively high and gets resetted frequently, like every 15 minutes. So what could cause this issue? There must be some wrong configuration. I [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/analyze-why-an-user-gets-locked-out-in-active-directory/">Analyze why an user gets locked out in Active Directory</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">
<p>Recently I wanted to connect to a machine with my admin user but then I realized that this user had been locked out in Active Directory. The counter for bad passwords is relatively high and gets resetted frequently, like every 15 minutes. So what could cause this issue? There must be some wrong configuration. I started to investigate. Analyze User Lockout AD</p>
<p>Imagine a setup with multiple Domain Controllers. Firstly, you have to find out which DC causes the lockout. Microsoft offers an amazing toolbox called &#8220;Account Lockout and Management Tools&#8221;. They are available at the following URL:<br /><a href="https://www.microsoft.com/en-us/download/details.aspx?id=18465">https://www.microsoft.com/en-us/download/details.aspx?id=18465</a></p>
<h2>LockoutStatus.exe</h2>
<p>Simply start the LockoutStatus.exe with a Domain Admin or at least with sufficient permissions and enter the target admin user who had been locked out. The tool will determine all Domain Controllers and show you a list of &#8220;Last Bad Password&#8221;, &#8220;Bad Password Counter&#8221; , &#8220;Last Password Change Date&#8221; and so on. Now you should know the involved Domain Controller.</p>
<h2>Check Event Log on DC to analyze User Lockout AD</h2>
<p>Secondly, you will connect via Remote Desktop Connection (RDP) to the mentioned Domain Controller and start the Event Viewer there. Navigate to System -&gt; Security:<br /><a href="https://www.hackbuddies.com/wp-content/uploads/2019/07/EventViewerSecurity.png"><img decoding="async" class=" td-modal-image alignnone wp-image-318 size-full" src="https://www.hackbuddies.com/wp-content/uploads/2019/07/EventViewerSecurity.png" alt="" width="196" height="196" srcset="https://www.hackbuddies.com/wp-content/uploads/2019/07/EventViewerSecurity.png 196w, https://www.hackbuddies.com/wp-content/uploads/2019/07/EventViewerSecurity-150x150.png 150w" sizes="(max-width: 196px) 100vw, 196px" /></a></p>
<p>Now filter the current log for the event ID: 4625<br /><a href="https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog.png"><img fetchpriority="high" decoding="async" class=" td-modal-image alignnone wp-image-319 size-full" src="https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog.png" alt="" width="899" height="553" srcset="https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog.png 899w, https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog-300x185.png 300w, https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog-768x472.png 768w, https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog-696x428.png 696w, https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog-683x420.png 683w, https://www.hackbuddies.com/wp-content/uploads/2019/07/FilterCurrentLog-356x220.png 356w" sizes="(max-width: 899px) 100vw, 899px" /></a></p>
<p>After that you should be able to see the corresponding log entries. Search for the affected user to get the right entry. The important part here is the <strong>Caller Machine Name</strong>. This name will tell you the server which is causing the bad logins. Another crucial detail is the value of the logon type. With this value you can localize the cause. The possible values are listed here:<br /><a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4625">https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4625</a></p>
<p>Finally, it should be relatively easy to solve. The possible sources of the bad logins are for example:</p>
<ul>
<li>Scheduled tasks</li>
<li>Services</li>
<li>Stored credentials</li>
<li>File share access</li>
<li>&#8230;</li>
</ul>
<p>Thus, you can check now the local client of the user in order to find the root cause, for example in Credential Manager and delete the stored credentials, re-map the network drive or adapt the scheduled task. Analyze User Lockout AD</p>
</div>
<!-- /wp:post-content --><p>The post <a href="https://www.hackbuddies.com/analyze-why-an-user-gets-locked-out-in-active-directory/">Analyze why an user gets locked out in Active Directory</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/analyze-why-an-user-gets-locked-out-in-active-directory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Find users where Outlook Web Access (OWA) is disabled with Exchange Management Shell</title>
		<link>https://www.hackbuddies.com/find-users-where-outlook-web-access-owa-is-disabled-with-exchange-management-shell/</link>
					<comments>https://www.hackbuddies.com/find-users-where-outlook-web-access-owa-is-disabled-with-exchange-management-shell/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 06 Jul 2019 09:08:03 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Featured]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=295</guid>

					<description><![CDATA[<p>By default all users are allowed to use Outlook Web Access, also called OWA. It is possible to disable access to OWA and the users can still access their mailbox via email clients like Outlook or Thunderbird. Manually checking the status or disabling it can be very time-consuming. So we will simply use the Exchange [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/find-users-where-outlook-web-access-owa-is-disabled-with-exchange-management-shell/">Find users where Outlook Web Access (OWA) is disabled with Exchange Management Shell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">
<p>By default all users are allowed to use Outlook Web Access, also called OWA. It is possible to disable access to OWA and the users can still access their mailbox via email clients like Outlook or Thunderbird.</p>
<p>Manually checking the status or disabling it can be very time-consuming. So we will simply use the Exchange Management Shell to do so.</p>
<p>If you want to see all users where Outlook Web Access is disabled, use this command:</p>
<pre>Get-CASMailbox -ResultSize Unlimited | where{$_.OWAEnabled -like "False"}</pre>
<p>Of course it is also possible to enable it with nearly the same command, but with the Set-CASMailbox command like that:</p>
<pre>Get-CASMailbox -ResultSize Unlimited | where{$_.OWAEnabled -like "False"} | Set-CASMailbox -OWAEnabled $true</pre>
<p>Filtering for one specific user works with the &#8220;Identity&#8221; parameter:</p>
<p><code data-author-content="Set-CasMailbox -Identity &quot;Yan Li&quot; -OWAEnabled $false
">Set-CasMailbox -Identity "Test User" -OWAEnabled $false<br>
</code></p>
<p>Another convenient and very useful way to use this command is by filtering for an organizational unit (OU).</p>
<pre class="has-inner-focus focus-visible" tabindex="0" data-focus-visible-added=""><code data-author-content="$NAFinance = Get-Mailbox -OrganizationalUnit &quot;OU=Marketing,OU=North America,DC=contoso,DC=com&quot; -Filter {RecipientTypeDetails -eq 'UserMailbox'} -ResultSize Unlimited; $NAFinance | foreach  {Set-CasMailbox  $_.Identity -OWAEnabled $false}
">$NAFinance = Get-Mailbox -OrganizationalUnit "OU=myBranch,OU=myCountry,DC=mydomain,DC=com" -Filter {RecipientTypeDetails -eq 'UserMailbox'} -ResultSize Unlimited; $NAFinance | foreach  {Set-CasMailbox  $_.Identity -OWAEnabled $false}
</code></pre>
</div>


<p></p>
<p>The post <a href="https://www.hackbuddies.com/find-users-where-outlook-web-access-owa-is-disabled-with-exchange-management-shell/">Find users where Outlook Web Access (OWA) is disabled with Exchange Management Shell</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/find-users-where-outlook-web-access-owa-is-disabled-with-exchange-management-shell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sending an email within a PowerShell script</title>
		<link>https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/</link>
					<comments>https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 14 Jun 2019 17:10:20 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=276</guid>

					<description><![CDATA[<p>Imagine you need to inform an user about something which had already been automated in a PowerShell script. You do not want to start a manual task (e.g. sending an email) every time the script is executed. Especially if you need it multiple times per day. So I decided to extend the script with the [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/">Sending an email within a PowerShell script</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">
<p>Imagine you need to inform an user about something which had already been automated in a PowerShell script. You do not want to start a manual task (e.g. sending an email) every time the script is executed. Especially if you need it multiple times per day. So I decided to extend the script with the email-sending function. Just a few lines of code are necessary and you can adapt it to your needs. Mail Subject and Mail Body can be modified and even attachments can be added. Sending Email with PowerShell</p>
<p>To show you the possibilities, the following script reads the assigned groups of an Active Directory user and exports them to a .txt file. Then, the email data gets specified and afterwards the email will be sent to the recipient.</p>
<pre>$Permissions = Get-ADPrincipalGroupMembership -Identity $Username | Select name | Sort-Object name | Out-File -FilePath C:\temp\AssignedGroups.txt<br />$SmtpServer = 'myServer.myDomain.com'<br />$SmtpPort = 587<br />$FromSender = 'mySender@myDomain.com'<br />$Recipient = 'myRecipient@myDomain.com'<br />$Subject = 'Assigned groups from : ' + $UserName<br />$PermissionsFilePath = "C:\temp\AssignedGroups.txt"<br />$Body = Get-Content -Path $PermissionsFilePath | Out-String <br />Send-MailMessage -SmtpServer $SmtpServer -Port $SmtpPort -From $FromSender -To $Recipient -Subject $Subject -Body $Body -Attachments $PermissionsFilePath</pre>
</div>

<p>I would definitely recommend you to check out the <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7" target="_blank" rel="noopener noreferrer">Microsoft Docs</a> about the Send-MailMessage command in order to properly adapt it to your needs and requirements. You can also combine that script with other ones. For example, you can <a href="https://www.hackbuddies.com/export-active-directory-groups-and-their-members-from-a-specific-organizational-unit-as-csv-with-powershell/">export Active Directory Groups and their members from a specific organizational unit as CSV</a> and send an automated email message within a scheduled task &#8211; there are no limitations.<br />Sending Email with PowerShell</p>
<p>The post <a href="https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/">Sending an email within a PowerShell script</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/sending-an-email-within-a-powershell-script/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Export user data from Active Directory</title>
		<link>https://www.hackbuddies.com/export-user-data-from-active-directory/</link>
					<comments>https://www.hackbuddies.com/export-user-data-from-active-directory/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 31 May 2019 12:47:24 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=227</guid>

					<description><![CDATA[<p>It will happen again and again. Your customers or colleagues will ask you to export specific user data from Active Directory. The easiest way to do this is with the command &#8220;Get-ADUser&#8221;. Simply select the specific objects like DisplayName, Username,.. and export the result to a CSV file with the specified encoding and delimiter. Import-Module [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/export-user-data-from-active-directory/">Export user data from Active Directory</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">
<p>It will happen again and again. Your customers or colleagues will ask you to export specific user data from Active Directory. The easiest way to do this is with the command &#8220;Get-ADUser&#8221;. Simply select the specific objects like DisplayName, Username,.. and export the result to a CSV file with the specified encoding and delimiter.</p>
<pre>Import-Module ActiveDirectory<br>Get-ADUser -Filter * -properties * | select-object DisplayName,sAMAccountName,telephoneNumber,mobile,mail,Department,Description | export-csv c:\temp\UserDataExport.csv -Encoding utf8 -notype -Delimiter ";"</pre>
<p>Most of the time not all users are necessary, so there are more options to filter of course.</p>
<h2>Export only specific Organizational Unit (OU)</h2>
<p>You can filter for an Organizational Unit by using the -SearchBase option:</p>
<pre>Import-Module ActiveDirectory<br>Get-ADUser -SearchBase "OU=Users,OU=&lt;SubUnit&gt;,OU=&lt;MainUnit&gt;,DC=&lt;domainName&gt;,DC=com" -Filter * -properties * | select-object DisplayName,sAMAccountName,telephoneNumber,mobile,mail,Department,Description | export-csv c:\temp\UserDataExport.csv -Encoding utf8 -notype -Delimiter ";"</pre>
<h2>Export group members</h2>
<p>Another useful command is to export the members of a security group:</p>
<pre>Import-Module ActiveDirectory<br>Get-ADGroupMember -Identity '&lt;GroupName&gt;' | Select-Object name, samaccountname | export-csv c:\temp\exportGroupMembers.csv -Encoding utf8 -NoType -Delimiter ";"</pre>
</div>


<p></p>
<p>The post <a href="https://www.hackbuddies.com/export-user-data-from-active-directory/">Export user data from Active Directory</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/export-user-data-from-active-directory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Copy Active Directory groups from one user to another</title>
		<link>https://www.hackbuddies.com/copy-ad-groups-from-one-user-to-another/</link>
					<comments>https://www.hackbuddies.com/copy-ad-groups-from-one-user-to-another/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 31 May 2019 11:22:05 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://www.hackbuddies.com/?p=169</guid>

					<description><![CDATA[<p>Last time I had the situation that an employee switched from one department to another, thus all security groups need to get updated. If this is the case, you can simply copy the Active Directory groups from another user of the new department.Although this is just a very simple one-liner, it is still a very [&#8230;]</p>
<p>The post <a href="https://www.hackbuddies.com/copy-ad-groups-from-one-user-to-another/">Copy Active Directory groups from one user to another</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="td-paragraph-padding-1">
<p>Last time I had the situation that an employee switched from one department to another, thus all security groups need to get updated. If this is the case, you can simply copy the Active Directory groups from another user of the new department.<br>Although this is just a very simple one-liner, it is still a very useful command and can save a lot of time.</p>
<pre>Import-Module ActiveDirectory<br>Get-ADUser -Identity &lt;copyFromUser&gt; -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members &lt;updateThisUser&gt;</pre>
</div>
<div>&nbsp;</div>
<div>&nbsp;</div>


<p></p>
<p>The post <a href="https://www.hackbuddies.com/copy-ad-groups-from-one-user-to-another/">Copy Active Directory groups from one user to another</a> appeared first on <a href="https://www.hackbuddies.com">HackBuddies</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hackbuddies.com/copy-ad-groups-from-one-user-to-another/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
