Skip to content

Commit

Permalink
remove usepwsh false and require 1.0.2.20 (#3497)
Browse files Browse the repository at this point in the history
1.0.2.20 now has SqlServer PS module preinstalled on PS 7 + compatible
overrides

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk authored Apr 23, 2024
1 parent f3af93a commit a71489d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions AppHandling/Clean-BcContainerDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ try {
$copyTables += @("Entitlement", "Entitlement Set", "Membership Entitlement")
}

Invoke-ScriptInBCContainer -containerName $containerName -usePwsh:$false -scriptblock { Param($platformVersion, $databaseName, $databaseServer, $databaseInstance, $copyTables, $multitenant)
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($platformVersion, $databaseName, $databaseServer, $databaseInstance, $copyTables, $multitenant)

Write-Host "Stopping ServiceTier in order to replace database"
Set-NavServerInstance -ServerInstance $ServerInstance -stop
Expand Down Expand Up @@ -196,7 +196,7 @@ try {
if ($customconfig.Multitenant -eq "True") {

Write-Host "Switching to multitenancy"
Invoke-ScriptInBCContainer -containerName $containerName -usePwsh:$false -scriptblock { Param($databaseName, $databaseServer, $databaseInstance)
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($databaseName, $databaseServer, $databaseInstance)
$databaseServerInstance = $databaseServer
if ($databaseInstance) {
$databaseServerInstance += "\$databaseInstance"
Expand Down
2 changes: 1 addition & 1 deletion AppHandling/Compile-AppInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ try {
# locate application version number in database if using SQLEXPRESS
try {
if (($customConfig.DatabaseServer -eq "localhost") -and ($customConfig.DatabaseInstance -eq "SQLEXPRESS")) {
$appVersion = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh:$false -scriptblock { Param($databaseName)
$appVersion = Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($databaseName)
(invoke-sqlcmd -ServerInstance 'localhost\SQLEXPRESS' -ErrorAction Stop -Query "SELECT [applicationversion] FROM [$databaseName].[dbo].[`$ndo`$dbproperty]").applicationVersion
} -argumentList $customConfig.DatabaseName
$publishedApps += @{ "Name" = "Application"; "Publisher" = "Microsoft"; "Version" = $appversion }
Expand Down
2 changes: 1 addition & 1 deletion Bacpac/Backup-NavContainerDatabases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ try {
}
$containerBakFolder = Get-BcContainerPath -containerName $containerName -path $bakFolder -throw

Invoke-ScriptInBcContainer -containerName $containerName -usePwsh:$false -ScriptBlock { Param($containerBakfolder, $bakFolder, $tenant, $databasecredential, $compress)
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param($containerBakfolder, $bakFolder, $tenant, $databasecredential, $compress)

function Backup {
Param (
Expand Down
2 changes: 1 addition & 1 deletion Bacpac/Export-NavContainerDatabasesAsBacpac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ try {
}
$containerBacpacFolder = Get-BcContainerPath -containerName $containerName -path $bacpacFolder -throw

Invoke-ScriptInBcContainer -containerName $containerName -usePwsh:$false -ScriptBlock { Param([PSCredential]$sqlCredential, $bacpacFolder, $tenant, $commandTimeout, $includeDacPac, $diagnostics, $additionalArguments, $doNotCheckEntitlements)
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param([PSCredential]$sqlCredential, $bacpacFolder, $tenant, $commandTimeout, $includeDacPac, $diagnostics, $additionalArguments, $doNotCheckEntitlements)

function CmdDo {
Param(
Expand Down
2 changes: 1 addition & 1 deletion Bacpac/Restore-DatabasesInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ try {
$containerBakFolder = Get-BcContainerPath -containerName $containerName -path $bakFolder -throw
}

Invoke-ScriptInBCContainer -containerName $containerName -usePwsh:$false -scriptblock { Param($bakFolder, $bakFile, $databaseName, $tenant, $databaseFolder, $sqlTimeout)
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($bakFolder, $bakFile, $databaseName, $tenant, $databaseFolder, $sqlTimeout)

function Restore {
Param (
Expand Down
6 changes: 3 additions & 3 deletions ContainerHandling/New-NavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ try {
$imageName = $bestImageName
if ($artifactUrl) {
$genericTagVersion = [Version](Get-BcContainerGenericTag -containerOrImageName $imageName)
if ($genericTagVersion -lt [Version]"1.0.2.15") {
if ($genericTagVersion -lt [Version]"1.0.2.20") {
Write-Host "Generic image is version $genericTagVersion - pulling a newer image"
$pullit = $true
}
Expand Down Expand Up @@ -2045,7 +2045,7 @@ if (-not `$restartingInstance) {

if ($SqlServerMemoryLimit -and $customConfig.databaseServer -eq "localhost" -and $customConfig.databaseInstance -eq "SQLEXPRESS") {
Write-Host "Set SQL Server memory limit to $SqlServerMemoryLimit MB"
Invoke-ScriptInBCContainer -containerName $containerName -usePwsh:$false -scriptblock { Param($SqlServerMemoryLimit)
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($SqlServerMemoryLimit)
Invoke-Sqlcmd -ServerInstance 'localhost\SQLEXPRESS' -Query "USE master EXEC sp_configure 'show advanced options', 1 RECONFIGURE WITH OVERRIDE;"
Invoke-Sqlcmd -ServerInstance 'localhost\SQLEXPRESS' -Query "USE master EXEC sp_configure 'max server memory', $SqlServerMemoryLimit RECONFIGURE WITH OVERRIDE;"
Invoke-Sqlcmd -ServerInstance 'localhost\SQLEXPRESS' -Query "USE master EXEC sp_configure 'show advanced options', 0 RECONFIGURE WITH OVERRIDE;"
Expand Down Expand Up @@ -2443,7 +2443,7 @@ if (-not `$restartingInstance) {
if ($multitenant) {
Write-Host "Switching to multitenant"

Invoke-ScriptInBCContainer -containerName $containerName -usePwsh:$false -scriptblock {
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock {

$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
Expand Down
25 changes: 12 additions & 13 deletions HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,17 @@ function DownloadLatestAlLanguageExtension {
[switch] $allowPrerelease
)

# Check if we already have the latest version downloaded and located in this session
if ($script:AlLanguageExtenssionPath[$allowPrerelease.IsPresent]) {
$path = $script:AlLanguageExtenssionPath[$allowPrerelease.IsPresent]
if (Test-Path $path -PathType Container) {
return $path
}
else {
$script:AlLanguageExtenssionPath[$allowPrerelease.IsPresent] = ''
}
}

$mutexName = "DownloadAlLanguageExtension"
$mutex = New-Object System.Threading.Mutex($false, $mutexName)
try {
Expand All @@ -1273,17 +1284,6 @@ function DownloadLatestAlLanguageExtension {
Write-Host "Other process terminated abnormally"
}

# Check if we already have the latest version downloaded and located in this session
if ($script:AlLanguageExtenssionPath[$allowPrerelease.IsPresent]) {
$path = $script:AlLanguageExtenssionPath[$allowPrerelease.IsPresent]
if (Test-Path $path -PathType Container) {
return $path
}
else {
$script:AlLanguageExtenssionPath[$allowPrerelease.IsPresent] = ''
}
}

$version, $url = GetLatestAlLanguageExtensionVersionAndUrl -allowPrerelease:$allowPrerelease
$path = Join-Path $bcContainerHelperConfig.hostHelperFolder "alLanguageExtension/$version"
if (!(Test-Path $path -PathType Container)) {
Expand Down Expand Up @@ -1312,8 +1312,7 @@ function RunAlTool {
Param(
[string[]] $arguments
)
# ALTOOL is at the moment only available in prerelease
$path = DownloadLatestAlLanguageExtension -allowPrerelease
$path = DownloadLatestAlLanguageExtension
if ($isLinux) {
$alToolExe = Join-Path $path 'extension/bin/linux/altool'
Write-Host "Setting execute permissions on altool"
Expand Down
2 changes: 1 addition & 1 deletion Misc/Set-BcContainerFeatureKeys.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -paramet
try {

if ($featureKeys.Keys.Count -ne 0) {
Invoke-ScriptInBCContainer -containerName $containerName -usePwsh:$false -ScriptBlock { Param([string] $tenant, [hashtable] $featureKeys)
Invoke-ScriptInBCContainer -containerName $containerName -ScriptBlock { Param([string] $tenant, [hashtable] $featureKeys)
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
$databaseServer = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseServer']").Value
Expand Down
2 changes: 1 addition & 1 deletion TenantHandling/New-NavContainerTenant.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ try {
throw "You cannot add a tenant called tenant"
}

Invoke-ScriptInBcContainer -containerName $containerName -usePwsh:$false -ScriptBlock { Param($containerName, $tenantId, [PSCredential]$sqlCredential, $sourceDatabase, $destinationDatabase, $alternateId, $doNotCopyDatabase, $allowAppDatabaseWrite, $applicationInsightsKey)
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param($containerName, $tenantId, [PSCredential]$sqlCredential, $sourceDatabase, $destinationDatabase, $alternateId, $doNotCopyDatabase, $allowAppDatabaseWrite, $applicationInsightsKey)

$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
Expand Down
2 changes: 1 addition & 1 deletion UserHandling/New-NavContainerNavUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -paramet
try {
$navversion = Get-BcContainerNavversion -containerOrImageName $containerName
$version = [System.Version]($navversion.split('-')[0])
Invoke-ScriptInBcContainer -containerName $containerName -usePwsh:$false -ScriptBlock { param([PSCredential]$Credential, [string]$Tenant, [string]$WindowsAccount, [string]$AuthenticationEMail, [bool]$ChangePasswordAtNextLogOn, [string]$PermissionSetId, [string]$AppName, [string]$AppPublisher, $assignPremiumPlan, [PSCredential]$databaseCredential, [string]$fullName, [System.Version]$version)
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { param([PSCredential]$Credential, [string]$Tenant, [string]$WindowsAccount, [string]$AuthenticationEMail, [bool]$ChangePasswordAtNextLogOn, [string]$PermissionSetId, [string]$AppName, [string]$AppPublisher, $assignPremiumPlan, [PSCredential]$databaseCredential, [string]$fullName, [System.Version]$version)

$TenantParam = @{}
if ($Tenant) {
Expand Down

0 comments on commit a71489d

Please sign in to comment.