#include ;~ #include _AD_Open(); are we in AD? If @error Then Exit MsgBox(48, "Error", "System not in AD domain") Global $aPrinterQueues = _AD_ListPrintQueues2( "*", "*") ; BE-BRU SplashTextOn("AD Printer survey", "Processing ...", 300, 50) Global $sOutput = "", $iElement For $i = 1 to $aPrinterQueues[0][0] SplashTextOn("AD Printer survey", $aPrinterQueues[$i][0], 300, 50) $aPrinterDetails = _AD_GetObjectProperties($aPrinterQueues[$i][2]) $sOutput &= "PrinterName: " & $aPrinterQueues[$i][0] & " - ServerName " & $aPrinterQueues[$i][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "cn", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "description", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "driverName", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "driverVersion", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "location", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "name", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "portName", 1, 0, 0, 0, 1, 0) ; IP address If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "PrinterName", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "printLanguage", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "printShareName", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "serverName", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $iElement =_ArraySearch($aPrinterDetails, "url", 1, 0, 0, 0, 1, 0) If $iElement > 0 Then $sOutput &= " " & $aPrinterDetails[$iElement][0] & ": " & $aPrinterDetails[$iElement][1] & @CRLF $sOutput &= @CRLF Next _AD_Close() $hFile=fileopen("Get_Ad_Users_Textfile.txt", 2) FileWrite($hFile, $sOutput) Fileclose($hFile) SplashOff ( ) Exit Func _AD_ListPrintQueues2($sServername = "*", $sPrinterName = "*") ; syntax _AD_ListPrintQueues2($sServername = "*"[, $sPrinterName = "*"]) ; $sPrinterName partial match search, for example location 'Brussels' ; Default = "*" (all printers) $__oAD_Command.CommandText = ";(&(objectclass=printQueue)(shortservername=" & $sServername & "));distinguishedName,PrinterName,ServerName;subtree" Local $oRecordSet = $__oAD_Command.Execute If @error Or Not IsObj($oRecordSet) Or $oRecordSet.RecordCount = 0 Then Return SetError(1, @error, "") Local $aPrinterList[$oRecordSet.RecordCount + 1][3] = [[0, 3]] $oRecordSet.MoveFirst Do Local $sTest = $oRecordSet.Fields("printerName").Value If $sPrinterName = "*" Or StringInStr($sTest, $sPrinterName) > 0 Then $aPrinterList[0][0] += 1 $aPrinterList[$aPrinterList[0][0]][0] = $sTest ;$oRecordSet.Fields("printerName").Value $aPrinterList[$aPrinterList[0][0]][1] = $oRecordSet.Fields("serverName").Value $aPrinterList[$aPrinterList[0][0]][2] = $oRecordSet.Fields("distinguishedName").Value EndIf $oRecordSet.MoveNext Until $oRecordSet.EOF $oRecordSet.Close ReDim $aPrinterList[$aPrinterList[0][0]+1][3] Return $aPrinterList EndFunc ;==>_AD_ListPrintQueues2