Get All SharePoint Server Details (Server Name, IP, Role, Status, etc) in the Farm using PowerShell
Requirement: Quickly retrieve and document details all server in the SharePoint Server farm.
Solution: Get all servers in SharePoint farm
To get all Servers in SharePoint farm, We use: Get-SPServer cmdlet.
Get-SPServer
Lets include Server Name, Role and Status fields from SharePoint farm servers
#Get All Servers in SharePoint Farm (including SQL Server, SMTP Server, Etc)
Get-SPServer | select Name, Role, Status | Format-table -AutoSize
The above cmdlet retrieves all servers in the SharePoint farm including SQL Server, SMTP Server, etc. To get only SharePoint Servers we can use:
#Get all SharePoint Servers
$servers = Get-SPServer | where { $_.role -ne "Invalid"}
Lets add one more parameter: IP Address to it.
PowerShell to get all servers in SharePoint farm
#Get all SharePoint Servers
$servers = Get-SPServer | where { $_.role -ne "Invalid"}
#Get Server Details including IP
$servers | select Name, Role, @{Label="IP Address";Expression={[System.Net.Dns]::GetHostByName($_.Name).AddressList.IPAddressToString}} | Format-Table
what a lovely command:
$servers | select Name, Role, @{Label=”IP Address”;Expression={[System.Net.Dns]::GetHostByName($_.Name).AddressList.IPAddressToString}} | Format-Table
🙂
Excellent