Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

Querying Active Directory for computers

Querying Active Directory for computers

We have physical and Virtual machines, I need to retrieve a report with the following fields:

Windows OS= I need just windows servers 2003 or 2008
Active Directory account of the server= enabled
Type of windows server= Physical machine or Virtual machine

I have vsphere client console and Active Directory console, but a lot of computers to go through manually and check all that info.

Any help will be very much appreciated.

Thanks
SOLUTION
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

Hostname	Operating System	                                                    Status	Type
           srvfDC02	Windows Server 2008 	R2 Standard	FALSE	<OFFLINE>
           srCTRX01	Windows Server 2003			FALSE	<OFFLINE>
           srvfDC04	Windows Server 2008 	R2 Standard	FALSE	<OFFLINE>
           srvfDC01	Windows Server 2008 	R2 Standard	FALSE	<OFFLINE>
          srmeaDC01	Windows Server 2008 	R2 Standard	FALSE	<OFFLINE>
           srvfDC03	Windows Server 2008 	R2 Standard	FALSE	<OFFLINE>

Open in new window

Avatar of jskfan

ASKER

The CSV output  is shown  as the example above.
I do not see where it should show if a computer is VM or not
You may want to change the string from Virtual to VMware
Avatar of jskfan

ASKER

changed it to VMware it did not work
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

User generated image
the error is pointing to this line:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

It did not retrieve all computers in Active Directory, we have 1564 computers in AD, but the script retrieved just 243, I also don't understand the display of the last column (Type)

Hostname	Operating System	Status	Type

Windows Server 2003	                 FALSE	<OFFLINE>
Windows Server 2003	                 FALSE	Physical
Windows Server 2003	                 FALSE	<OFFLINE>
Windows Server® 2008 Standard	FALSE	<OFFLINE>
Windows Server 2008 R2 Standard	FALSE	<OFFLINE>Windows Server 2008 R2 Standard	FALSE	Virtual
Windows Server 2008 R2 Standard	FALSE	Virtual
Windows Server® 2008 Enterprise	FALSE	<ERROR 462>
Windows Server 2003	                 TRUE	<OFFLINE>
Windows Server 2008 R2 Standard	FALSE	Virtual

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

it is doing the same thing ..it retrieves only 243 computers..
What are the errors you see in the last column?  You may need to check your credentials or WMI health on the remote machines.
Avatar of jskfan

ASKER

it is not about errors….it does not retrieve all computers in AD.
there are 1564 computers, it retrieves only 243.
Avatar of jskfan

ASKER

Sorry…I may have said on my question the OS = windows 2003 and windows 2008.
can you change the script for all computers OS
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

thanks