![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br>
|
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Guest
Posts: n/a
|
Hi,
I'm using get-qaduser to get some of the attributes from AD. The script reads a text filee and extracts some of the attributes and writes to the csv files. The execution takes a long time. I'm querying for only 35 users max it takes around 45sec to 1 min to get the info and write it to csv file. Where as a VBScript hardly takes 10 sec!!!! I have another script which checks wheter the Homemdb attribute exists and writes some of the attributes to the csv files. The execution takes a long time about 1 hours for 17,000 users. I'm running the script on XP mahcine with 512 MB ram. Any suggestion to improve the execution would be appriciated. Regards, Swamy |
||
|
|
|
|
|
|
#2 | ||||||||||||||
|
Guest
Posts: n/a
|
Can you show me the code your using? Are you using a LDAP filter?
"Swamy Channaveera" <SwamyChannaveera@xxxxxx> wrote in message news:41A5C65E-985D-4620-B58D-BF2C06943146@xxxxxx
|
||||||||||||||
|
|||||||||||||||
|
|
#3 | ||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
The script is as follows
get-content user.txt | foreach { get-qaduser $-} | sort altrecipient | select-object displayname, altrecipient | convertto-html list.htm Regards, "Brandon Shell [MVP]" wrote:
|
||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
|
|
#4 | ||||||||||||||
|
Guest
Posts: n/a
|
Swamy Channaveera wrote:
pass along to MS on this for them to look into... Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
||||||||||||||
|
|||||||||||||||
|
|
#5 | ||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
Following is the VBScript that produces the exact result as that of Powershell.
'On Error Resume Next Const ADS_SCOPE_SUBTREE = 2 Const ForReading = 1 mbcount=0 SWcount=0 errcount=0 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = ("ADsDSOObject") objConnection.Open "Active Directory Provider" objCommand.ActiveConnection = objConnection FilePath = "Migration.html" Set objArgs = WScript.Arguments Set objDictionary = CreateObject("Scripting.Dictionary") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile("c:\scripts\sam.txt", ForReading) Set fso = CreateObject("Scripting.FileSystemObject") set wfile = fso.opentextfile(filepath,2,true) i = 0 Do While objTextFile.AtEndOfStream <> True strNextLine = objTextFile.Readline objDictionary.Add i, strNextLine i = i + 1 mbcount = mbcount +1 Loop wfile.writeline("<html>") wfile.writeline("<head>") wfile.writeline("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>") wfile.writeline("<title> MIGRATION SWITCH STATUS Report</title>") wfile.writeline("<style>") wfile.writeline("<!--") wfile.writeline("body, td {font-family:tahoma;font-size:11px;border: border-width:1px; border-style:solid ; color #CCCCCC;}") wfile.writeline("table{border: thin solid #000000;}") wfile.writeline("-->") wfile.writeline("</style>") wfile.writeline("<meta http-equiv='Refresh' content = '10; '>") wfile.writeline("<table width='60%' align='center' cellpadding='3' cellspacing='3' '>") wfile.writeline("<tr bgcolor='#CCCCCC'>") wfile.writeline("<td colspan='3' height='45' align='center'>") wfile.writeline("<font face='tahoma' color='#003399' size='2'><strong> Mailbox Migration Switch Status Report</strong></font>") wfile.writeline("</td>") wfile.writeline("</tr>") wfile.writeline("</table>") wfile.writeline("<tr>") wfile.writeline("<td colspan=5> </td>") wfile.writeline("</tr>") wfile.writeline("<table border='1' width='60%' align='center' cellpadding='3' cellspacing='2' style='border-top: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;'>") wfile.writeline("<tr align='center'>") wfile.writeline("<td bgcolor='#CCCCCC' align='left' valign='top' style='border-bottom: 1px solid #CCCCCC;' width='33%'><div align='center'><strong>UserID</strong></div></td>") wfile.writeline("<td bgcolor='#CCCCCC' align='left' valign='top' style='border-bottom: 1px solid #CCCCCC;' width='33%'><div align='center'><strong>Display Name</strong></div></td>") wfile.writeline("<td bgcolor='#CCCCCC' align='left' valign='top' style='border-bottom: 1px solid #CCCCCC;' width='34%'><div align='center'><strong>Switched (Yes/No)</strong></div></td>") wfile.writeline("</tr>") For Each objItem in objDictionary objCommand.CommandText = "SELECT samAccountName,altrecipient,displayname FROM " & _ "'LDAP://dc=UD1,dc=UTILITY' " & _ "WHERE samAccountName = '" & objDictionary.Item(objItem) & "'" objCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute 'Wscript.Echo objRecordSet.Fields("distinguishedname").Value If objRecordSet.RecordCount = 0 Then Wscript.Echo objDictionary.Item(objItem) & " NOT found" errcount = errcount+1 Else objRecordSet.MoveFirst Do Until objRecordSet.EOF wfile.writeline("<tr>") wfile.writeline("<td>" & objRecordSet.Fields("samaccountname").Value & "</td>") wfile.writeline("<td>" & objRecordSet.Fields("displayname").Value & "</td>") if left(objRecordSet.Fields("altrecipient").Value,8) = "CN=Quest" then ' Wscript.Echo objRecordSet.Fields("displayname").Value & " is not migrated " wfile.writeline("<td align='Center'>No</td>") else ' Wscript.Echo objRecordSet.Fields("displayname").Value & " is migrated " wfile.writeline("<td align='Center'>Yes</td>") swcount = swcount+1 end if ' Wscript.Echo objRecordSet.Fields("displayname").Value & objRecordSet.Fields("altrecipient").Value & " is migrated " objRecordSet.MoveNext Loop End If Next wfile.writeline("<tr></tr>") wfile.writeline("<table border='1' width='60%' align='center' cellpadding='3' cellspacing='0' style='border-top: 1px #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;'>") wfile.writeline("<tr>") wfile.writeline("<td width='33%' align='left'>Last Updated: " & now() & "</td>") wfile.writeline("<td width='67%' align='left'>Total number of mailboxes : " & mbcount & " | Switched : " & SWcount & " | Pending : " & mbcount-errcount-swcount & " | Error : " & errcount & "</td>") wfile.writeline("</tr>") wfile.writeline("</table><p>") ' wfile.writeline("<td width='34%' align='left'> Switched : " & SWcount & " / Pending : " & mbcount-errcount-swcount & " / Error : " & errcount & "</td>") objtextfile.close mbcount=0 SWcount=0 "Marco Shaw [MVP]" wrote:
|
||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
|
|
#6 | ||||||||||||||
|
Guest
Posts: n/a
|
Hello Swamy,
Try this and see if is any faster. If it is we can work on getting the data out the way you want: get-content user.txt | foreach {[ADSI]"LDAP://$_"} | sort altrecipient | select-object displayname, altrecipient |
||||||||||||||
|
|||||||||||||||
|
|
#7 | ||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
Hi,
I tryed the following command get-content user.txt | foreach {[ADSI]"WinNT://UD1/$_"} where UD1 is the netbios name of the domain. The output is blank with the error message distinguishedName -------------------- out-lineoutput : exception retrieving member "Classidd2e4...... ": unknown error (0x80005000)" Regards, "Karl Mitschke" wrote:
|
||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
|
|
#8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
On Apr 10, 9:16*am, Swamy Channaveera
<SwamyChannave...@xxxxxx> wrote:
Maybe this is just a transcription typo on your part, but isn't there something more fundamentally wrong with this line?
not a '$-' (dollar, minus). - Oisin |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
#9 |