#211261 - 2016-04-04 09:51 PM
List domain computers
|
Iz3k34l
Just in Town
Registered: 2016-02-19
Posts: 4
Loc: Texas
|
is there a way to query the domain for a list of domain computers? Ultimately i want to rename a computer and join it to a domain. I want to be able to step through computer names pc1, pc2 by verifying the computer is not already on the domain or the computer name inst already being used, then naming the next sequential number.
Thanks
|
Top
|
|
|
|
#211272 - 2016-04-07 06:18 PM
Re: List domain computers
[Re: Glenn Barnas]
|
Iz3k34l
Just in Town
Registered: 2016-02-19
Posts: 4
Loc: Texas
|
ok, thanks so much.. i got it to compare and to read in a CSV list, strip out the comma, and compare but now i want to limit the return of the first -1 it finds because as it stand it return the last...
For Each $Target in $aData[0]
if (ASCAN($aList,$Target,,,1) < 0)
? $Target ?
$rTurn = $Target
EndIF
;? $Target
Next
? $rTurn
Thanks
|
Top
|
|
|
|
#211285 - 2016-04-08 11:06 PM
Re: List domain computers
[Re: Iz3k34l]
|
Iz3k34l
Just in Town
Registered: 2016-02-19
Posts: 4
Loc: Texas
|
Ok so on to another note, i need to be able to search the domain for a list of computers already on the domain BEFORE being joined to the domain ;o)... i got the script to search for systems within the domain, return a value (not exactly the way i wanted but for testing it will do) and rename the system with the returned value... after a reboot it gave me a domain trust error... any ideas on how to get the computer list from the domain BEFORE being added to the domain?
Thanks
|
Top
|
|
|
|
#211288 - 2016-04-10 02:33 AM
Re: List domain computers
[Re: Lonkero]
|
Iz3k34l
Just in Town
Registered: 2016-02-19
Posts: 4
Loc: Texas
|
Thanks Glenn and Lonkero; here is the updated code that will get a list of domain computers without being on a domain computer
Function GetMachineList($DomainName, $DomainUser, $DomianPass)
Dim $Machines[0], $iX
;Create domain object
$Domain = GetObject("WinNT:").OpenDSObject("WinNT://$DomainName" , $DomainUser, $DomainPass, 1)
;Set container object equal to domain object.
$Container = $Domain
;Iterates through EVERY object in the domain. Those
;objects that match the class are included in the array.
$iX = -1
For Each $Computer In $Container
If $Computer.Class = "Computer"
$iX = $iX + 1
ReDim Preserve $Machines[$iX]
$Machines[$iX] = $Computer.Name
EndIf
Next
; Return the $Machines array...
$GetMachineList = $Machines
;Object cleanup
$Domain = 0
$Container = 0
EndFunction
Edited by Iz3k34l (2016-04-10 02:34 AM)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|