> Can I set user password on remote computer with WMI ?
Hi
As far as I know, no. But you can use the WinNT object for this:
sNewPwd = "testpassword"
sUser = "some user name here"
sComputer = "some computer name or IP address here"
Set oUser = GetObject("WinNT://" & sComputer & "/" & sUser & ",user")
oUser.SetPassword sNewPwd
oUser.SetInfo
' to change password:
'sOldPwd = "the oldpwd"
'sNewPwd = "the newpwd"
'oUser.ChangePassword(sOldPwd, sNewPwd)
'oUser.Setinfo
If you need to use explicit credentials
' Insert code to securely retrieve the username and password (sUsername,
sPassword)
Const ADS_SECURE_AUTHENTICATION = 1
sComputer = "some computer name or IP address here"
Set oDSO = GetObject("WinNT:")
Set oComputer = oDSO.OpenDSObject _
("WinNT://" & sComputer, sUsername, sPassword, ADS_SECURE_AUTHENTICATION)
IADsOpenDSObject::OpenDSObject
http://msdn.microsoft.com/library/en-us/adsi/adsi/iadsopendsobject_opendsobject.asp
(note that the constant ADS_SECURE_AUTHENTICATION mentioned in the link above
needs to be explicit defined to 1 in a VBScript)
INFO: User Authentication Issues with ADSI WinNT Provider
http://support.microsoft.com/default.aspx?scid=KB;en-us;218497
An example on how to use OpenDSObject:
Modifying User Cannot Change Password (WinNT Provider)
http://msdn.microsoft.com/library/en-us/adsi/adsi/modifying_user_cannot_change_password_winnt_provider.asp
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter