Create a user with Windows PowerShell

Windows PowerShell is a new feature which comes with Windows 2008 server. It need to have the .Net Framework installed and can also be installed on Windows 2003 Server, Windows XP-Vista.

Create a textfile “NewUser.ps1” with following content:
$objOU=[ADSI]LDAP://OU=Users,DC=test,DC=com

$objUser = $objOU.Create("user", "CN=Test1 User")
$objUser.Put("sAMAccountName", "Test1.User")
$objUser.SetInfo()

$objUser = $objOU.Create("user", "CN=Test2 User")
$objUser.Put("sAMAccountName", "Test2.User")
$objUser.SetInfo()

Important: To run this scripts in PowerShell you need to first active it:
set-executionpolicy remotesigned

Go into the directory where the script is located and run it like this:
./NewUser.ps1

Get users samid:
dsquery user -name "*User" | dsget user -samid

admin on June 5th 2009 in Windows Server

No Comments »

Trackback URI | Comments RSS

Leave a Reply

*




Check out new movies online website. Download and buy movies now.
1