0

In short, I am running a silent install of SQL Server 2016 using a *.ini file. At the end of the installation, I must restart to use any sort of sqlcmd/invoke-sqlcmd to call a SQL file.

Does anyone know of a method (preferably PowerShell) that can forgo a restart and run those commands?

1 Answers1

0

I ran into an identical issue when trying to create SQL server users with sqlcmd after a silent install.

I solved it by using Chocolatey's Update-SessionEnviorment powershell script found here:

https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/helpers/functions/Update-SessionEnvironment.ps1

I just copied all of the required functions into a .ps1 file and called the separate file from the main script to keep everything clean.

Sidenote: They also have a similar script for cmd if you are doing this in batch and not powershell

https://github.com/chocolatey-archive/chocolatey/blob/master/src/redirects/RefreshEnv.cmd