SQL Stuff

Find SQL Ports With Powershell

Ok; so you’re looking at another database server, and you want to make sure all the ports are properly configured. You might have the impulse to login to the server, and check the ports out from there, but at this stage you might find logging into the server is a bit annoying if you can just run something locally. Powershell to the rescue.

If you’re running Server 2012 or later; all the Powershell cmdlets are already there; you just need to know what to run. Take this little statement. Using PSSESSION you can connect remotely to the server, and get all the "SQL" port information.

The powershell logic to do that is here:

enter-pssession "MyServerName"

Get-NetFirewallRule `

| Where { $_.Enabled -eq ‘True’ -and $_.Direction -eq ‘Inbound’ -and $_.'displayname' -like "*sql*" } `

| select displayname, enabled, action, direction `

| out-string -width 98



Categories: SQL Stuff

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s