Local User Account yaratmak ve Gruba eklemek (Script-2)

13 Ekim 2010 Çarşamba

Bu script, ilk script ile aynı işi yapıyor. Yani yeni bir local account yaratıp ilgili gruba ekliyor. Farklı olan ise “password never expires” yerine “user must change password at next logon” ayarını set ediyor olması.  Ayrıca farklı bir fonksiyon  kullanıyor.

“user must change password at next logon” sayesinde, yaratılan local accou@���Xturum açan kişiyi yeni password belirlemeye zorlamış oluyoruz.

Script’i asağıdaki gibi çalıştırabilirsiniz;

‘ name of user to be created
sNewUser = “mini-strator”

‘ name of the group the user is to be added to
sGroupname = “Administrators”

‘ get computer name
Set oWshNet = CreateObject(“WScript.Network”)
sComputerName = oWshNet.ComputerName

‘ connect to the Winnt provider
Set oComputer = GetObject(“WinNT://” & sComputerName)

‘ create the user
Set oUser = oComputer.Create(“user”, sNewUser)

oUser.SetPassword “123test”

On Error Resume Next
‘ save the user
oUser.Setinfo

‘ If user exists already or password restrictions
‘ are not fulfilled, we get an error
If Err.Number = 0 Then

‘ configure the user
On Error Goto 0

‘ Enable “User Must Change Password at Next Logon”
oUser.Put “PasswordExpired”, 1
oUser.Setinfo
End If
On Error Goto 0

‘ Add the user to the group
Set oGroup = GetObject(“WinNT://” & sComputerName & “/” & sGroupname)

‘ Use error handling in case he is a member already
On Error Resume Next
oGroup.Add(oUser.ADsPath)
On Error Goto 0


Share/Bookmark

0 comments :