Ironman Software Forums
Continue the conversion on the Ironman Software forums. Chat with over 1000 users about PowerShell, PowerShell Universal, and PowerShell Pro Tools.
In this post, we’ll query SQL with PowerShell.
DBATools is an amazing PowerShell module that anyone dealing with SQL should be aware of. The Invoke-DbaQuery
cmdlet can be used to query tables.
Install-Module dbatools
Invoke-DbaQuery -Query "SELECT * FROM job" -SqlInstance '(localdb)\MSSQLLocalDB' -Database universal
The SQLServer module is the official SQL module developed by Microsoft. You can use the Invoke-SqlCmd
cmdlet to query SQL using this module.
Install-Module SqlServer
Invoke-SqlCmd -ServerInstance '(localdb)\MSSQLLocalDb' -Database universal -Query 'SELECT * FROM job'
InvokeQuery is a popular community module for querying various types of databases. It supports databases like Sqlite, MS SQL and MySQL.
Install-Module InvokeQuery
Invoke-SqlServerQuery -Database universal -Server '(localdb)\MSSQLLocalDB' -Sql 'SELECT * FROM job'
Find this useful? Please consider sharing this article. Have a question about PowerShell? Contact us and we'll write a post about it.
Continue the conversion on the Ironman Software forums. Chat with over 1000 users about PowerShell, PowerShell Universal, and PowerShell Pro Tools.
Receive once-a-month updates about Ironman Software. You'll learn about our product updates and blogs related to PowerShell.