Search the Community
Showing results for tags 'get-adcomputer'.
-
You must have the ActiveDirectory module available for import (usually done by installing RSAT). In reply to a question posed on the AD UDF thread. How to dump an array of users from AD with a partial Last Name: #include <AutoItConstants.au3> #include <Array.au3> $sName = inputbox("Get AD User Info" , "AD Lastname (or partial)") $sName = "*" & $sName & "*" $sCommands = "powershell -Command import-module ActiveDirectory; Get-ADUser -LDAPfilter '(name=" & $sName & ")'" $iPID = Run(@ComSpec & " /c " & $sCommands, "", @SW_SHOW , $stdout_child) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aOut = stringsplit($sOutput, @LF , 2) for $i = ubound($aOut) - 1 to 0 step -1 $aOut[$i] = StringStripWS($aOut[$i] , 8) If stringinstr($aOut[$i] , "GivenName") And Stringright($aOut[$i] , 1) <> ":" Then $aOut[$i] = stringtrimleft($aOut[$i] , 10) ElseIf stringinstr($aOut[$i] , "Surname") And Stringright($aOut[$i] , 1) <> ":" Then $aOut[$i] = stringtrimleft($aOut[$i] , 8) Else _ArrayDelete($aOut , $i) EndIf next ;~ _ArrayDisplay($aOut) Local $aFullName[0] For $i = 0 to ubound($aOut) - 1 step 2 _ArrayAdd ($aFullName , $aOut[$i] & " " & $aOut[$i + 1]) Next $aFullNameUnique = _ArrayUnique($aFullName, 0 ,0 ,0 ,0) _ArrayDisplay($aFullNameUnique)
- 9 replies
-
- get-aduser
- get-adcomputer
-
(and 1 more)
Tagged with: