Link to home
Start Free TrialLog in
Avatar of damejen
damejen

asked on

Inventory Servers in Domain with Powershell

Hi experts,

I need some help from the PowerShell gurus out there as I am still a novice and learning powershell.

I would like to get an inventory of all the servers in a domain whether the servers are physical or Virtual. Find info such as OS, RAM, CPU, IP Address, make and model, group them by site and then export the output to .csv

If anyone can help this would save me a lot of time.

Many thanks.
SOLUTION
Avatar of Prashant Girennavar
Prashant Girennavar
Flag of India 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
Avatar of damejen
damejen

ASKER

Hi Prashant,

Thanks for the script I've created a .txt file with my Domain controllers though when I run the script it tells me "cannot find path C:\ADcomputer.csv because it does not exits?

Also it only writes to the 2nd line of the excel document and it overwrites the same line with each server it discovers...

What could be the issue, is there anything else i need to do before running the script?
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 damejen

ASKER

Hi Prishant,

Thanks again for looking into this, although it doesn't seem to quite work for me.
The second issue of the text being overwritten in row 2 is still occuring rather than the script populating the other rows. So its only showing one row of server information, though it gets overwritten when it finds the next server.

The information it is pulling out is exactly what im looking for though apart from the issue above.
The script works for me.

$intRow +=1; is the variable which is responsible to increment the Rows in excel. Check it is proper.

If it does not work , copy your code and paste it here.

Thanks,

-Prashant Girennavar.
Avatar of damejen

ASKER

This is the code.

Line 41 in the original was $intRow = 2
I changed that to $intRow +=1 as you suggested. Same result.
I dont see the code.

Can you please send it once again.

Thanks,

-Prashant Girennavar.
Avatar of damejen

ASKER

sorry here you go, see attached.
Get-Servers.txt
Avatar of damejen

ASKER

Hi Prashant

Im not sure where I'm going wrong with this script. I've added the RSAT to the server i'm running the script on member 2012 server.

I seem to get the following.

It creates the excel file, but then I get the following (please see attachments.)
28-02-2014-16-52-21.png
28-02-2014-16-52-50.png
Do you have the windows server 2008 DC???

basically script is unable to contact do a query of DC as I suspect you are using w2k3 for DC query.

I suggest you to put the DC which has w2k8 as OS in domaincontoller.txt


Let me know if you don't have w2k8.

Thanks,

-Prashant Girennavar.
Avatar of damejen

ASKER

Hi Prashant,

No unfortunately the environment I'm using does not have a W2k8 DC's
FFL and DFL is at W2K3. We only have W2K3 DC's at the moment.

Many thanks for you help Prishant.
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 damejen

ASKER

Hi Prashant,

Ok I've created another .txt file with my DC's under C:\Temp\Servers.txt.
Though now I seem to only get results from the Server I'm running the script from. and then the script completes. No other errors.
03-03-2014-12-13-32.png
Make sure you dont have spaces in the text file.

I would suggest you to put only 2 servers in a text file and run the script.

let me know your findings.

-Prashant Girennavar.
Avatar of damejen

ASKER

I've only put two Dc's without any spaces in the txt file e.g DC01,DC02

But it still only gives me output for the server I'm running the script on.  No other information on any other servers is being produced.

There are no errors from the script, just only getting information on one server, the one im running the script on.
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 damejen

ASKER

This powershell script is originally intended to gather W2k8 Domain, Domain servers information, it has been amended by its creator Prashant Girennavar for W2K3 Domain