<br />
<b>Warning</b>:  Constant FORCE_SSL_ADMIN already defined, this will be an error in PHP 9 in <b>/var/www/schmidtpetersen.dk/public_html/wp-config.php</b> on line <b>181</b><br />
<?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>User Adminstration &#8211; Mortens Website</title>
	<atom:link href="https://schmidtpetersen.dk/tag/user-adminstration/feed/" rel="self" type="application/rss+xml" />
	<link>https://schmidtpetersen.dk</link>
	<description>Blog, guides, food and drink recipes and everything in between</description>
	<lastBuildDate>Sat, 16 Jan 2021 00:11:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>
	<item>
		<title>Get all users from specific Organizational Unit in an Active Directory</title>
		<link>https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/</link>
					<comments>https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/#respond</comments>
		
		<dc:creator><![CDATA[Morten]]></dc:creator>
		<pubDate>Sat, 16 Jan 2021 00:10:28 +0000</pubDate>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Organizational Unit]]></category>
		<category><![CDATA[OU]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[User Adminstration]]></category>
		<category><![CDATA[User Export]]></category>
		<category><![CDATA[User Properties]]></category>
		<guid isPermaLink="false">https://schmidtpetersen.dk/?p=127</guid>

					<description><![CDATA[Ever found yourself in need of collection all users in a specific OU, filter for a given set of properties and export the list to a file? If yes, this script is for you! The script will search in domain.domain.tld\Parent-OU\Sub-OU and will select all users in this sub-OU. Here, it will collect the properties SamAccountName, &#8230; <a href="https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/" class="more-link">Continue reading<span class="screen-reader-text"> "Get all users from specific Organizational Unit in an Active Directory"</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Ever found yourself in need of collection all users in a specific OU, filter for a given set of properties and export the list to a file? If yes, this script is for you!</p>



<pre class="wp-block-code"><code>$Users = Get-ADUser -SearchBase "OU=Sub-OU,OU=Parent-OU,DC=domain,DC=tld" -Filter * -Properties * | Select-Object SamAccountName,DisplayName,GivenName,Surname,whenCreated,Enabled,accountExpires,lastLogonTimestamp,LockedOut
$OUUsers = @()
$OUUsers += "SamAccountName,DisplayName,GivenName,Surname,whenCreated,Enabled,accountExpires,lastLogonTimestamp,LockedOut"
foreach ($User in $Users) {
    if ($User.accountExpires  -eq "9223372036854775807") {
        $OUUsers += "$($User.SamAccountName),$($User.DisplayName),$($User.GivenName),$($User.Surname),$(($User.whenCreated).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.Enabled),$("Never"),$(&#91;datetime]::FromFileTime($User.lastLogonTimestamp).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.LockedOut)"
    }
    if (-not($User.accountExpires  -eq "9223372036854775807")) {
        $OUUsers += "$($User.SamAccountName),$($User.DisplayName),$($User.GivenName),$($User.Surname),$(($User.whenCreated).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.Enabled),$(&#91;datetime]::FromFileTime($User.accountExpires).ToString('yyyy-MM-ddZhh-mm-ss')),$(&#91;datetime]::FromFileTime($User.lastLogonTimestamp).ToString('yyyy-MM-ddZhh-mm-ss')),$($User.LockedOut)"
    }
}
$OUUsers | Out-File C:\tmp\OUUser-Report.csv</code></pre>



<p class="wp-block-paragraph">The script will search in domain.domain.tld\Parent-OU\Sub-OU and will select all users in this sub-OU. Here, it will collect the properties <em>SamAccountName, DisplayName, GivenName, SurName, whenCreated, Enabled, accountExpires, lastLogonTimestamp</em> and <em>LockedOut</em>. These properties will then be exported to the file <em>OUUser-Report.csv</em> which will be stored in <em>C:\tmp</em>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://schmidtpetersen.dk/2021/01/get-all-users-from-specific-organizational-unit-in-an-active-directory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
