Last active
July 31, 2023 11:06
-
-
Save timyhac/c1bc5906fdd12d6d2bab850e7164ee5b to your computer and use it in GitHub Desktop.
Get the pipe name for a Local DB instance in powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function GetLocalDBNamedPipe() | |
{ | |
param( [string]$DB) | |
# This function can accept instance names in the format '(localdb)\Instance' | |
$DB = $DB.replace("(localdb)\", '') | |
# Ensure that it is running (assumes the DB already exists) | |
# Note: pipe names change each time the database starts | |
sqllocaldb start $DB | Out-Null | |
return ((sqllocaldb info $DB | Select-String -Pattern "Instance pipe name") -split " ")[3] | |
} | |
sqllocaldb create TheDatabase | |
$ThePipe = GetLocalDBNamedPipe -DB TheDatabase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment