Page 1 of 1 1
Topic Options
#143708 - 2005-07-15 10:12 PM List all workstation from Domain script
singk Offline
Fresh Scripter

Registered: 2002-02-14
Posts: 31
I've been searching for almost a day and can't find any script that will allows me to list all workstations (computer) from Domain. I mean Workstation Only or a way to identify either workstation, member server, PDC, or BDC.

This script I've below will list all computers include servers. Is there any way that I can query ONLY workstations?

Code:
 
$Computers=GetObject("WinNT://$Domain")
$Computers.filter="Computer",""
For Each $Computer In $Computers
'display computer.name here.
Next

_________________________
Thanks, Sing

Top
#143709 - 2005-07-15 11:05 PM Re: List all workstation from Domain script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Use LDAP and pull them from specific OUs assuming you segregate them by OU.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143710 - 2005-07-15 11:21 PM Re: List all workstation from Domain script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
$computers.filter="workstation",""

sounds cool...
_________________________
!

download KiXnet

Top
#143711 - 2005-07-16 03:41 AM Re: List all workstation from Domain script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
You could go here and download this cool little commandline app.


Quote:

Network View v1.20 (NetView.exe) Last Updated: 08/16/2001

Displays a list of all machines visible in the specified domain, based on role. Basically a command-line view of Network Neighborhood, similar to 'Net.exe View' but with the ability to filter on certain types of machines (workstations only, servers only, time servers, SQL servers, etc.). Use 'NetView /?' to view the syntax.

NOTE: This list of machines is not real-time, but compiled and shared between network segments at 12 minute intervals. New machines will not appear in the browse list immediately, it may take up to 48 minutes, depending on the complexity of your network. Likewise, machines removed from the network are not immediately removed from the browse list, it may take up to 72 minutes. For more information, see Microsoft Knowledge Base articles 188001, 102878 and 150800.





Network View
 

Top
#143712 - 2005-07-16 04:56 AM Re: List all workstation from Domain script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Obviously, it does not "List all workstation from Domain" as the subject says.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143713 - 2005-07-16 06:29 AM Re: List all workstation from Domain script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
give me a break, nearly as live as most other solutions. There is always propigation delays in machines being announced on the network. Basically unless someone just recently added one, then for all practical purposes it will return all the workstations.

Yeah, you can do ADSI code too, this is just another method.
 

Top
#143714 - 2005-07-16 06:48 AM Re: List all workstation from Domain script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Here is even a WMI method to do it, you'll need to convert it for use for multiple computers.

ADSI of an OU or NETVIEW 1.2 would be much faster though.


Code:
$strComputer = "."
$objWMIService = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colComputers = $objWMIService.ExecQuery("Select DomainRole from Win32_ComputerSystem")
For Each $objComputer in $colComputers
Select
Case $objComputer.DomainRole=0
$strComputerRole = "Standalone Workstation"
Case $objComputer.DomainRole=1
$strComputerRole = "Member Workstation"
Case $objComputer.DomainRole=2
$strComputerRole = "Standalone Server"
Case $objComputer.DomainRole=3
$strComputerRole = "Member Server"
Case $objComputer.DomainRole=4
$strComputerRole = "Backup Domain Controller"
Case $objComputer.DomainRole=5
$strComputerRole = "Primary Domain Controller"
EndSelect
$strComputerRole ?
Next


 

Top
#143715 - 2005-07-16 06:48 AM Re: List all workstation from Domain script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, I won't give you a break.
Quote:

then for all practical purposes it will return all the workstations.



Wrong!
NetView browse lists will NOT return names of computers that have been turned off for a while.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143716 - 2005-07-16 08:29 AM Re: List all workstation from Domain script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Then who cares about them. LOL

Sir yes Sir - You have proven your worth grasshopper!

Is that something like micro-management?

I have no doubt that that every large enterprise corporation out there DOES NOT know 100% how many workstations they really have at any given point in time.

Given the numerous variables that can happen on a network with thousands of users and computers I'm not aware of anyone being 100% accurate on computer counts.
Even doing a physical inventory of systems often is not accurate due to systems being moved around during the counting process.

But hey, if you have your workstations at 100% accounted for then I suppose I should be glad to know that Merlin is still alive.
 
But thanks for the feedback.
 

Top
#143717 - 2005-07-16 03:17 PM Re: List all workstation from Domain script
singk Offline
Fresh Scripter

Registered: 2002-02-14
Posts: 31
Quote:

$computers.filter="workstation",""

sounds cool...




Is this work with "GetObject("WinNT:" method?
_________________________
Thanks, Sing

Top
#143718 - 2005-07-16 03:20 PM Re: List all workstation from Domain script
singk Offline
Fresh Scripter

Registered: 2002-02-14
Posts: 31
Quote:

Here is even a WMI method to do it, you'll need to convert it for use for multiple computers.

ADSI of an OU or NETVIEW 1.2 would be much faster though.






Eventhough Netview method is faster, but it doesn't display all workstation or offline workstation.

I'll try the WMI method when I get back to the office.
_________________________
Thanks, Sing

Top
#143719 - 2005-07-16 03:21 PM Re: List all workstation from Domain script
singk Offline
Fresh Scripter

Registered: 2002-02-14
Posts: 31
Quote:

Use LDAP and pull them from specific OUs assuming you segregate them by OU.




Les,
How do I or can I use the LDAP against NT4 domain?
_________________________
Thanks, Sing

Top
#143720 - 2005-07-16 03:27 PM Re: List all workstation from Domain script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You cannot.
Didn't anybody tell you that NT4 is past EOL?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143721 - 2005-07-16 03:30 PM Re: List all workstation from Domain script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
For an NT domain, you could e.g. use the COMNetView()or any other NetView UDF and the OSID() UDF to weed out servers.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.077 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org