저는 VB에서 매우 새롭기 때문에이 스크립트에 대한 도움을 받고 싶습니다.CSV를 구문 분석하고 데이터를 가져오고 AD 객체를 이동하는 VBS 스크립트
기본적으로 내 현재 컴퓨터 이름을 가져올 스크립트가 필요하며 csv 파일을 조사하여 새 관련 컴퓨터 이름을 얻은 다음 해당 새 이름을 사용하여 광고의 해당 계정을 새 OU로 이동합니다.
나는 현재 컴퓨터 이름을 얻는 방법을 이미 알고 있으며 개체를 새 OU로 이동하는 방법을 알고 있습니다.이 작업은 이미 수행 한 작업이지만 csv를 구문 분석하여 내 컴퓨터 이름을 기반으로 새 컴퓨터 이름을 찾는 것에 대해서는 자신이 없습니다. 현재 하나.
새 이름은 csv 파일의 현재 이름 바로 뒤에 오는 값입니다. 혼수 상태에 불과했다. 1
편집 난 당신의 솔루션을 시도했지만 의견에 명시된 바와 같이 나는하지 않는 몇 가지가 있다고 생각합니다. 레코드 세트를 오용하거나 정보를 검색하는 방법을 모를 수 있습니다. 여기 내 전체 스크립트가있어서 내가하는 일을 볼 수 있습니다.
'Get the old/current computername
Set wshShell = WScript.CreateObject("WScript.Shell")
OldComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
'Parse the xml file to get the related new computername
Dim CONNECTION : Set CONNECTION = CreateObject("ADODB.CONNECTION")
Dim RECORDSET : Set RECORDSET = CreateObject("ADODB.RECORDSET")
CONNECTION.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\;Extended Properties=""text;HDR=YES;FMT=Delimited"""
RECORDSET.Open "SELECT NewComputerName FROM ComputerList.csv WHERE ComputerName = '& OldComputerName'", CONNECTION, 3, 3
'Move the new computername in the target AD to a new OU
Dim NewComputerName
Dim OldLocation
NewComputerName = RECORDSET
OldLocation = "LDAP://CN=" & NewComputerName & ",OU=Staging,OU=Workstations,DC=contoso,DC=lab"
Set objNewOU = GetObject("LDAP://OU=Migration,OU=Workstations,DC=contoso,DC=lab")
Set objMoveComputer = objNewOU.MoveHere(OldLocation, vbNullString)
' It does not work as it said Error: Wrong number of arguments or invalid property assignment pour la ligne:
' OldLocation = "LDAP://CN=" & NewComputerName & ",OU=Staging,OU=Workstations,DC=contoso,DC=lab"
감사합니다. :)
가 얼마나 큰이 CSV 파일이 될 것입니다? 몇 개 이상의 기록이 있습니까? –