PowerShell – Query Database Remotely

The basic syntax for sending a query to SQL Server using PowerShell.

sqlcmd -S SERVER_NAME -d master -Q "select count(1) from sys.objects"

This site uses Akismet to reduce spam. Learn how your comment data is processed.