Setup - Mix of Windows 2003, 2008 and 2012
Servers are in workgroup (DMZ)
Need to create user A, user B and User C whereas i will input a text file with the servernames
-----------------------
Found this on other forum
$username = "admin"
$password = "password001"
$computers = Get-Content "C:\Scripts\Create local admin accounts\serverlist.txt"
# OR $computers = Import-CSV c:\serverlist.csv | select Server
Foreach ($computer in $computers) {
$users = $null
$computer = [ADSI]WinNT://$computer
Try {
$users = $computer.psbase.children | select -expand name
if ($users -like $username) {
Write-Host "$username already exists"
} Else {
$user_obj = $computer.Create(user, $username)
$user_obj.SetPassword($password)
$user_obj.SetInfo()
$user_obj.Put(description, $username)
$user_obj.SetInfo()
$user_obj.psbase.invokeset(AccountDisabled, False)
$user_obj.SetInfo()
$users = $computer.psbase.children | select -expand name
if ($users -like $username) {
Write-Host "$username has been created on $($computer.name)"
} Else {
Write-Host "$username has not been created on $($computer.name)"
}
}
} Catch {
Write-Host "Error creating $username on $($computer.path): $($Error[0].Exception.Message)"
}
}
Error is -
-------------------
PS C:\Scripts\Create local admin accounts> .\createuser.ps1Error creating admin on WinNT://10.157.33.51: The following exception occurred while retrieving member "name": "Not imp
lemented
"
How i am running the script
-----------------------------------
Got a client running with Windows 7, i have set the local administrator password same as running on servers in the input file, have logged on locally to windows 7 with administrator account and running powershell with administrator.