waldo1001 / Cloud.Ready.Software.PowerShell

waldo's PowerShell Scripts & Modules
http://www.waldo.be
85 stars 93 forks source link

New-NAVEnvironment do not close SQL connection ? #40

Open ffulconis-pdw opened 7 years ago

ffulconis-pdw commented 7 years ago

Hi,

I'm not sure but it seems New-NAVEnvironment function does not close opened SQL connections once execution is done. For example I tried to create a script by using this function followed by invoking database conversion and synch tables (newer build on development environment), but an error about non exclusive connection is always raised. Closing and reopen PS ISE to launch again only convertion and Synch works fine.

waldo1001 commented 7 years ago

thanks for mentioning!

Do you have a repro for me? Like a (small) script to test this out?

ffulconis-pdw commented 7 years ago

Hi,

Here is the script I’m Trying to execute : My exe Build is greater than the backup file’s one and conversion is needed. So it’s normal for me that service does not start after environment creation, and I wanted to launch conversion and synch in same script.

$BckpFile = "Demo Database NAV (10-0) - FR - Cu4.bak" $Server = "Localhost" $InstanceSQL = "SQL2016" $DatabasePath = 'D:\Databases\MSSQL13.SQL2016\MSSQL\Data' $DatabaseName = "ConvTest"

New-NAVEnvironment -BackupFile $BckpFile -ClientServicesPort 7046 -CreateWebServerInstance -DatabaseInstance $InstanceSQL -Databasename $DatabaseName -DatabaseServer $Server -EnablePortSharing -ManagementServicesPort 7045 -ServerInstance $DatabaseName

Invoke-NAVDatabaseConversion -DatabaseName $DatabaseName -DatabaseServer ($Server + '\' + $InstanceSQL) Set-NAVServerInstance -Start -ServerInstance $DatabaseName Sync-NAVTenant -ServerInstance $DatabaseName -Force -Mode ForceSync

I don’t matter service starting errors, but this one is annoying : Invoke-NAVDatabaseConversion : : [22924111] The ConvTest database on the xxxxxxxxxx\SQL2016 server must be converted before you can use it with this version of the Microsoft Dynamics NAV Development Environment. The database conversion cannot continue because there are other SQL Server sessions using the database. Close all other sessions and then try again. Au caractère D:\Users\xxxxxxxxx\Documents\Scripts\Repro Waldo.ps1:11 : 1

If I close PowerShell ISE and then reopen to execute script again with comment on New-NAVEnvironment line, conversion and synch work fine. I supposed then that open SQL connection was about database restore or rights modifications within New-NAVEnvironment

Regards. De : waldo [mailto:notifications@github.com] Envoyé : jeudi 7 septembre 2017 09:55 À : waldo1001/Cloud.Ready.Software.PowerShell Cloud.Ready.Software.PowerShell@noreply.github.com Cc : AcererakTheLich acererak@outlook.fr; Author author@noreply.github.com Objet : Re: [waldo1001/Cloud.Ready.Software.PowerShell] New-NAVEnvironment do not close SQL connection ? (#40)

thanks for mentioning!

Do you have a repro for me? Like a (small) script to test this out?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/waldo1001/Cloud.Ready.Software.PowerShell/issues/40#issuecomment-327719653, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AdohJsecusIKgxcB1WnBSlxJqUgrhS7Oks5sf6E2gaJpZM4POFnA.