Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Set-Location "/home/<whatisyourlinuxuser>/sqltoolservice/"
$Assem = (
Add-Type -AssemblyName $Assem
Function Connect-SqlConnection {
$sqlConnection = new-object Microsoft.SqlServer.Management.Common.SqlConnectionInfo($instance, $uname, $pword)
try {
$SqlSvr = New-Object Microsoft.SqlServer.Management.Smo.Server($SqlConnection)
return $SqlSvr
catch {
throw $_.Exception.InnerException.ToString()
$thisInstance = "localhost"
$thisUname = "sa"
$thisPword = "<WhatIsYourPassword>"
$thisSqlConn = Connect-SqlConnection -Instance $ThisInstance -Uname $thisUName -Pword $thisPword
foreach ($db in $thisSqlConn.Databases)
Write-Verbose $db.Name -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment