电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

在NT移植期间改变用户帐户的属性


发布日期:2023/8/15
 

在NT移植期间改变用户帐户的属性

在把用户从NT的备份域控制器向Windows 移植的过程中我们需要改变用户的资料档案的路径这个脚本是由其它的代码的片断以及一些巧妙的方法综合而成的这使得修改其它用户的属性变得相当容易

===================================================

Name:moduservbs

Description:Modify profile path of user accounts

Only those with a current roaming profile are udpated

Original: Jun

=================================================

Set objConnection = CreateObject(ADODBConnection)

objConnectionOpen Provider=ADsDSOObject;

Set objCommand = CreateObject(ADODBCommand) objCommandActiveConnection = objConnection

WScriptStdOutWriteLine Enter search criteria

Wildcards can be used

strUserName = WScriptStdInReadLine

WScriptEcho

objCommandCommandText = _

<LDAP://dc=dc=>;

& _(&(objectCategory=user)(sAMAccountName= & strUserName & )); & _

sAMAccountNameprofilePathADsPath;subtree

Set objRecordSet = objCommandExecute

If objRecordsetEOF Then

WscriptEcho No user account(s) found with the specified criteria

Else

WscriptEcho User account(s) with the specified criteria:

While Not objRecordsetEOF

WscriptEcho objRecordsetFields(sAMAccountName) & : & _

objRecordsetFields(profilePath)

objRecordsetMoveNext

WEnd

End If

WScriptEcho

strNewProfPath =

While strNewProfPath =

WScriptStdOutWriteLine Enter new profile server and share:

StrNewProfPath = WScriptStdInReadLine WEnd WScriptEcho

Refresh record set to apply new path

Set objRecordSet = objCommandExecute

While Not objRecordsetEOF

If IsNull(objRecordSetFields(profilePath)) Then

WScriptEcho objRecordSetFields(sAMAccountName) & has no roaming profile

WScriptEcho

Else

strADsPath = objRecordSetFields(ADsPath)

Set objUser = GetObject(strADsPath)

objUserPut profilePath strNewProfPath & & _

objRecordsetFields(sAMAccountName) & USR

objUserSetInfo

End If

objRecordsetMoveNext

WEnd

Refresh record set to view new profile path

Set objRecordSet = objCommandExecute

WScriptEcho User account(s) with the new target data:

While Not objRecordsetEOF

WScriptEcho objRecordSetFields(profilePath)

If objRecordSetFields(profilePath) <> Then

WscriptEcho objRecordsetFields(sAMAccountName) & : & _

objRecordsetFields(profilePath)

End If

objRecordsetMoveNext

WEnd

objConnectionClose

上一篇:WindowsServer2008之ServerCore攻略

下一篇:Exchange Server2003 故障诊断