How can I extract a specific web application port number using Powershell?

2 Answers 2


Here you go :)

if ( (Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
        Add-PsSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
        Write-Host "PSSnapin SharePoint is now ON" -ForegroundColor Green `n
    Write-Host "PSSnapin SharePoint already ON" -ForegroundColor Magenta `n
$web = Get-SPWebApplication http://YOUR_WEB_APPLICATION
# $web.IisSettings["Default"] #Most of the settings
# $web.IisSettings["Default"].ServerBindings #HostHeader and Port number
$web.IisSettings["Default"].ServerBindings.Port #Only Port number
  • @Suhayl Bhat, please mark it as answer if this is what you asked for ;)
    – Marko Tica
    Jul 31, 2015 at 8:31

Below command should return the details in url property:

Get-SPWebApplication | Select DisplayName, Url

This will return all the web apps with in the server farm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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