Skip to content

Instantly share code, notes, and snippets.

@nvarscar
Last active January 24, 2019 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvarscar/25eed474b0351a6683e1f0b2bf50482b to your computer and use it in GitHub Desktop.
Save nvarscar/25eed474b0351a6683e1f0b2bf50482b to your computer and use it in GitHub Desktop.
Examples for Invoke-DBOQuery
# Get current database from a PostgreSQL server
Invoke-DBOQuery -Type PostgreSQL -Server localhost:5432 -Database postgres -Query 'SELECT current_database()' -As SingleValue
# Run a query against MySQL database
Invoke-DBOQuery -Type MySQL -Server localhost -Database mysql -Query 'SELECT Name from Users'
# Run multiple files from a folder in a specific SQL Server database
Get-ChildItem .\Scripts | Invoke-DBOQuery -SqlInstance 'SqlServer1:1443' -Database MyDB
# Connect to an Oracle database interactively as SYSDBA
Invoke-DBOQuery -Type Oracle -SqlInstance localhost -Interactive -Username sys -Password $mySecurePassword -ConnectionAttribute @{ 'DBA Privilege' = 'SYSDBA' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment