<?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>Edwin M SarmientoCreating Active Directory Users with Windows PowerShell &#8211; Edwin M Sarmiento</title>
	<atom:link href="https://www.edwinmsarmiento.com/creating-active-directory-users-with-windows-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.edwinmsarmiento.com</link>
	<description>Intentional Excellence</description>
	<lastBuildDate>Mon, 13 Apr 2026 21:00:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">84283043</site>		<item>
		<title>Creating Active Directory Users with Windows PowerShell</title>
		<link>https://www.edwinmsarmiento.com/creating-active-directory-users-with-windows-powershell/</link>
		<comments>https://www.edwinmsarmiento.com/creating-active-directory-users-with-windows-powershell/#respond</comments>
		<pubDate>Fri, 03 Jul 2009 23:52:00 +0000</pubDate>
		<dc:creator>Edwin M Sarmiento</dc:creator>
				<category><![CDATA[Active Directory users]]></category>
		<category><![CDATA[Windows PowerShell]]></category>
		<guid isPermaLink="false">http://bassplayerdoc.wordpress.com/2009/07/03/creating-active-directory-users-with-windows-powershell</guid>

				<description><![CDATA[While it may seem easy to create Active Directory users using the management console, I still prefer doing it using scripts so as to make sure that they are done in a uniform, standard fashion (not to mention as fast as one can possibly do especially if you will be doing it for many users). [&#8230;]]]></description>
					<content:encoded><![CDATA[<p><span style="font-family:arial;">While it may seem easy to create Active Directory users using the management console, I still prefer doing it using scripts so as to make sure that they are done in a uniform, standard fashion (not to mention as fast as one can possibly do especially if you will be doing it for many users). I&#8217;ve referenced the scripts provided at the CodePlex site for <a href="http://www.codeplex.com/PsObject/Wiki/View.aspx?title=ADSI%20and%20AD">ADSI and Active Directory</a> for Windows PowerShell (full credit goes to them) to create users in Active Directory for Windows Server 2008. This also works for Windows Server 2003. While I may be a big fan of automation, it is important to highlight that processes are what makes automation really work. The reason I am saying this is that the CSV file can come from different sources, say, an intranet site where you ask employees to log in and key in their details. Having a process in place to make sure that users who would be entering their details in a standard way would eliminate the need to cleanse the data (I&#8217;m still thinking as a DBA here) in the long run. Plus, having a standard in place as an organization is starting out will make it flexible enough to scale as growth happens.</span></p>
<pre class="brush: powershell; title: ; notranslate">
# define constants
$domainstr = &amp;quot;,dc=domainName,dc=local&amp;quot;
$domainnb = &amp;quot;domainName&amp;quot; # domain netbios name
$domain = &amp;quot;domainName.local&amp;quot;

$ADs_UF_NORMAL_ACCOUNT = 512 # Disables account and sets password required.

# Remember to enable the account before logging in

# Prompt user to enter the default passsword for the users
$defaultPassword = Read-Host &amp;quot;Please enter default Password:&amp;quot; -asSecureString

# Read the list of users from the CSV file
# Include other user properties in the CSV file as necessary

Import-csv users.txt | foreach
{
# Create user name based on FirstName and LastName column in the CSV file
$strUser = $_.firstName + &amp;quot; &amp;quot; + $_.lastName

#Form the LDAP string based on the OU column from the CSV file
$strLDAP = &amp;quot;LDAP://OU=&amp;quot; + $_.OU + &amp;quot;,OU=domainName Domain Users&amp;quot; + $domainstr

$target = &#x5B;ADSI] $strLDAP
$newUser = $target.create(&amp;quot;User&amp;quot;, &amp;quot;cn=&amp;quot; + $strUser)
$newUser.SetInfo()

#Define a naming convention for the login based on your corporate policy
#This one uses the first letter of the firstname and the lastname
$userID = $_.firstName&#x5B;0]+$_.lastName

#Define the other user attributes based on the columns defined in the CSV file
$newUser.sAMAccountName = $userID.ToString()
$newUser.givenName = $_.firstName
$newUser.sn = $_.lastName
$newUser.displayName = $_.firstName + &amp;quot; &amp;quot; + $_.lastName
$newUser.userPrincipalName = $_.firstName&#x5B;0]+$_.lastName + &amp;quot;@&amp;quot; + $domain
$newUser.mail = $_.Email
$newUser.physicalDeliveryOfficeName = $_.Location
$newUser.title = $_.Designation
$newUser.description = $_.Designation
$newUser.SetInfo()

$newUser.SetPassword($defaultPassword.ToString())

#Normal user that requires password &amp;amp; is disabled
$newUser.userAccountControl = $ADs_UF_NORMAL_ACCOUNT

Write-Host &amp;quot;Created Account for: &amp;quot; $newUser.Displayname

}
</pre>
]]></content:encoded>
			

		<wfw:commentRss>https://www.edwinmsarmiento.com/creating-active-directory-users-with-windows-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
				<post-id xmlns="com-wordpress:feed-additions:1">194</post-id>	</item>
	</channel>
</rss>