Powershell script to identify server roles for a farm of servers

Hello Experts,

I just wonder if you can provide me with a nice Powershell  script that exports into a CSV the FQDN of servers from a forest/domain and the server role as well of OS installed on each server. Please see example below

ServerFQDN                            Server role        OS                                   Forestname                domainname
server1.root.domainname    schema master  Windows 2003 R2          root.domainname      domainA
server2.domainname            dhcp server         Windows 2008              root.domainname      domainB
server3.domainname            DNS                      Windows 2008 R2
server4.domainname            Exchange             Windows 2012 R2
server5.domainname            File server            Windows 2012

The script should be able to read information from AD and all servers and/or discovery the server roles installed on each server that is part of that forest/domain

Any help is highly appreciated
Jerry SeinfieldAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Have you tried Microsoft MAP?  If not I recommend you try MAP as it could provide you various kinds of reports.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David Johnson, CD, MVPOwnerCommented:
server1.root.domainname    schema master  Windows 2003 R2          root.domainname      
server2.domainname            dhcp server         Windows 2008              root.domainname      
server3.domainname            DNS                      Windows 2008 R2
server4.domainname            Exchange             Windows 2012 R2
server5.domainname            File server            Windows 2012


getting the operating system and whether or not it is a DC or not is trivial. How would one differentiate between a member server and a file server?  you can check the roles and see if dhcp and/or dns is installed.  (doesn't mean that it is active).  Exchange is an application that runs on the server it is not a role.
0
Jerry SeinfieldAuthor Commented:
Any other suggestions from the Powershell team?
0
compdigit44Commented:
I am not a powershell expert but I believe the following MS blog article will give you tell you how to get most of the information you are looking for..

http://blogs.technet.com/b/heyscriptingguy/archive/2010/07/19/hey-scripting-guy-how-can-i-use-windows-powershell-2-0-to-retrieve-information-about-domain-controllers.aspx

http://technet.microsoft.com/en-us/library/ee176825.aspx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.