Get all the machines in sharepoint farm

alex picture alex · Jan 8, 2012 · Viewed 10.3k times · Source

im writing really big script that will get a lot of info on the farm I want to make it dynamically so I want :
1. Get all the database servers in the sharepoint farm 2. And I want to get all the sharepoint machines in farm

The problem is that with

Get-SPServer

I get all the server together mixed up and I get the smtp server as well And with

Get-SPDatabase | Select NormalizedDataSource

I get them multiple times

Please help

Answer

vonPryz picture vonPryz · Jan 9, 2012

If Get-SPDatabase | Select NormalizedDataSource returns all the databases, you can filter the results by using the -Unique switch:

Get-SPDatabase | Select NormalizedDataSource -unique

You can get all the SP application servers by filtering by role:

get-spserver | ? { $_.Role -eq "Application" }