SqlLocalDB not recognized after installation using powershell command

when I run these below commands one after another in a same powershell window , we are getting below error.
And it is working when we run the second command in a new powershell window.

step 1: MsiExec.exe /i SqlLocalDB.msi IACCEPTSQLLOCALDBLICENSETERMS=YES /qn | Out-Null

step 2: sqlocaldb info

error : sqllocaldb : The term ‘sqllocaldb’ is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • sqllocaldb info
  • CategoryInfo : ObjectNotFound: (sqllocaldb:String) , CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Any help would be appreciated to run these command in the same batch :slight_smile:

I assume the installation adds environment variables and thus a new session would have those. The original already loaded the environment variables prior to installation when they did not exist. If you want to run in the same session then you will likely need to provide the full path to the executable.

1 Like