Forum
Arkadaşlar merhaba.
Serhat hocamızın bir scripti var bu konuda ancak yapmak istediğim bir iki dğeişiklik var bilgisi olan arkadaşlar paylaşırsa sevinirim.
Kullanıcı oluşturulduğunda remote desktop grubuna ve users grubuna üye olmalı ve parola her zaman geçerli olmalı seçeneği işaretli olmalı.
Serhat hocamızın scripti aşağıdaki gibi
' specify account to create
strAccount = "Serhat"
strPswd = "12345test"
' get local computer name
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
' check if local account already exists
intExists = 0
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
If objUser.Name = strAccount Then
intExists = 1
End If
Next
If intExists = 0 Then
' create local user
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strAccount)
' set pswd
objUser.SetPassword strPswd
objUser.SetInfo
' set pswd never expires
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",User")
objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
' add to local admins group
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
objGroup.Add(objUser.ADsPath)
End If
Selam,
ADS_UF_DONT_EXPIRE_PASSWD'e sabit değer atayan satır eksik.. Aşağıda düzenlediğim halini bir dene bakalım.
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
' specify account to create
strAccount = "Serhat"
strPswd = "12345test"
' get local computer name
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
' check if local account already exists
intExists = 0
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
If objUser.Name = strAccount Then
intExists = 1
End If
Next
If intExists = 0 Then
' create local user
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strAccount)
' set pswd
objUser.SetPassword strPswd
objUser.SetInfo
' set pswd never expires
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",User")
objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
' add to local admins group
Set objGroup = GetObject("WinNT://" & strComputer & "/Remote Desktop Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
objGroup.Add(objUser.ADsPath)
' add to local admins group
Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
objGroup.Add(objUser.ADsPath)
End If
Teşekkür ederim Serhat Hocam. Tam istediğim gibi.