熱點推薦:
您现在的位置: 電腦知識網 >> 操作系統 >> Windows服務器 >> 正文

在NT移植期間改變用戶帳戶的屬性

2022-06-13   來源: Windows服務器 

  在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
From:http://tw.wingwit.com/Article/os/fwq/201311/29822.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.