SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a really big script which will get a lot of info from my farm. I'd like to make it work dynamically, so I would need to:

  1. Get all the database servers in the SharePoint farm
  2. Get all the SharePoint machines in the farm

The problem is that cmdlet


… returns all the servers together, mixed up, including the SMTP servers.

And with

Get-SPDatabase | Select NormalizedDataSource

I get them multiple times. What do I have to change to do this right?

share|improve this question
Get-SPServer | where {$_.Role -ne "Invalid"}

That will not return SQL or SMTP servers (or other non-configured servers).

share|improve this answer

Probably you're looking for Get-Unique cmdlet:

Thus please, try running this command:

Get-SPDatabase | Select NormalizedDataSource | Sort-Object | Get-Unique
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.