Skip to content

Commit 5d25208

Browse files
authored
Freddydk/smallbugfixes (#3715)
Small bugfixes: - Wait for databases to be mounted when running Restore-DatabasesInBcContainer - Include AI Toolkit when copying symbols from container - Issue 3714 Download-BcNuGetPackageToFolder - throws error when use "-select Exact" - Issue 3621 New-AadAppsForBc shows "-includeEmailAadApp is deprecated. Use -includeOtherServicesAadApp instead." but includeOtherServicesAadApp us not setting email permissions - Issue 3718 Business Central Web Client Fails to Load After Updating to Windows 24H2 Fixes #3714 Fixes #3621 Fixes #3718 --------- Co-authored-by: freddydk <[email protected]>
1 parent f95c2a5 commit 5d25208

10 files changed

+217
-278
lines changed

AzureAD/New-AadAppsForBc.ps1

-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ try {
418418

419419
# EMail App
420420
if ($IncludeEmailAadApp) {
421-
Write-Host -ForegroundColor Yellow "-includeEmailAadApp is deprecated. Use -includeOtherServicesAadApp instead."
422421
# Remove "old" Email AD Application
423422
$EMailIdentifierUri = $appIdUri.Replace('://','://email.')
424423
Get-MgApplication -All | Where-Object { $_.IdentifierUris -contains $EMailIdentifierUri } | ForEach-Object { Remove-MgApplication -ApplicationId $_.Id }

Bacpac/Restore-DatabasesInNavContainer.ps1

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ try {
132132
}
133133

134134
Set-NavServerInstance -ServerInstance $serverInstance -start
135+
$boo = $true
136+
while (Get-NAVServerInstance | Get-NavTenant | Where-Object { $_.State -eq "Mounting" }) {
137+
if ($boo) { Write-Host "Waiting for tenants to be mounted"; $boo = $false }
138+
Start-Sleep -Seconds 1
139+
}
135140
}
136141

137142
} -argumentList $containerBakFolder, $containerBakFile, $databaseName, $tenant, $databaseFolder, $sqlTimeout

BcContainerHelper.psm1

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ if ($useVolumes -or $isInsideContainer) {
3131
$bcContainerHelperConfig.UseVolumes = $true
3232
}
3333

34-
$hypervState = ""
35-
function Get-HypervState {
36-
if ($isAdministrator -and $hypervState -eq "") {
34+
$hypervState = "Unknown"
35+
function GetHypervState {
36+
if ($isAdministrator -and $hypervState -eq "Unknown") {
3737
try {
3838
$feature = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online
3939
if ($feature) {

ContainerHandling/Get-BestGenericImageName.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ function Get-BestGenericImageName {
1616
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
1717
try {
1818

19+
if ($LatestGenericTagVersion -eq '0.0.0.0') {
20+
$labels = Get-BcContainerImageLabels -imageName 'mcr.microsoft.com/businesscentral:ltsc2022'
21+
Write-Host "Setting LatestGenericTagVersion to $($labels.tag)"
22+
$LatestGenericTagVersion = $labels.tag
23+
}
24+
1925
if ($hostOsVersion -eq $null) {
2026
$os = (Get-CimInstance Win32_OperatingSystem)
2127
if ($os.OSType -ne 18 -or !$os.Version.StartsWith("10.0.")) {

ContainerHandling/New-NavContainer.ps1

+9-192
Original file line numberDiff line numberDiff line change
@@ -421,77 +421,14 @@ try {
421421
$UBR = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name UBR).UBR
422422

423423
$hostOsVersion = [System.Version]::Parse("$($os.Version).$UBR")
424-
$hostOs = "Unknown/Insider build"
425-
$bestGenericImageName = Get-BestGenericImageName -onlyMatchingBuilds -filesOnly:$filesOnly
426-
427424
$isServerHost = $os.ProductType -eq 3
428-
429-
if ($os.BuildNumber -eq 26100) {
430-
$hostOs = "24H2"
431-
}
432-
elseif ($os.BuildNumber -eq 22631) {
433-
$hostOs = "23H2"
434-
}
435-
elseif ($os.BuildNumber -eq 22621) {
436-
$hostOs = "22H2"
437-
}
438-
elseif ($os.BuildNumber -eq 22000) {
439-
$hostOs = "21H2"
440-
}
441-
elseif ($os.BuildNumber -eq 20348) {
442-
$hostOs = "ltsc2022"
443-
}
444-
elseif ($os.BuildNumber -eq 19045) {
445-
$hostOs = "22H2"
446-
}
447-
elseif ($os.BuildNumber -eq 19044) {
448-
$hostOs = "21H2"
449-
}
450-
elseif ($os.BuildNumber -eq 19043) {
451-
$hostOs = "21H1"
452-
}
453-
elseif ($os.BuildNumber -eq 19042) {
454-
$hostOs = "20H2"
455-
}
456-
elseif ($os.BuildNumber -eq 19041) {
457-
$hostOs = "2004"
458-
}
459-
elseif ($os.BuildNumber -eq 18363) {
460-
$hostOs = "1909"
461-
}
462-
elseif ($os.BuildNumber -eq 18362) {
463-
$hostOs = "1903"
464-
}
465-
elseif ($os.BuildNumber -eq 17763) {
466-
if ($isServerHost) {
467-
$hostOs = "ltsc2019"
468-
}
469-
else {
470-
$hostOs = "1809"
471-
}
472-
}
473-
elseif ($os.BuildNumber -eq 17134) {
474-
$hostOs = "1803"
475-
}
476-
elseif ($os.BuildNumber -eq 16299) {
477-
$hostOs = "1709"
478-
}
479-
elseif ($os.BuildNumber -eq 15063) {
480-
$hostOs = "1703"
481-
}
482-
elseif ($os.BuildNumber -eq 14393) {
483-
if ($isServerHost) {
484-
$hostOs = "ltsc2016"
485-
}
486-
else {
487-
$hostOs = "1607"
488-
}
489-
}
425+
$hostOs = GetHostOs -hostOsVersion $hostOsVersion -isServerHost $isServerHost
426+
$bestGenericImageName = Get-BestGenericImageName -onlyMatchingBuilds -filesOnly:$filesOnly
490427

491428
Write-Host "BcContainerHelper is version $BcContainerHelperVersion"
492429
if ($isAdministrator) {
493430
Write-Host "BcContainerHelper is running as administrator"
494-
Write-Host "HyperV is $(Get-HypervState)"
431+
Write-Host "HyperV is $(GetHypervState)"
495432
}
496433
else {
497434
Write-Host "BcContainerHelper is not running as administrator"
@@ -1095,50 +1032,9 @@ try {
10951032
AddTelemetryProperty -telemetryScope $telemetryScope -key "genericTag" -value "$genericTag"
10961033

10971034
$containerOsVersion = [Version]"$($inspect.Config.Labels.osversion)"
1098-
if ("$containerOsVersion".StartsWith('10.0.14393.')) {
1099-
$containerOs = "ltsc2016"
1100-
if (!$useBestContainerOS -and $TimeZoneId -eq $null) {
1101-
$timeZoneId = (Get-TimeZone).Id
1102-
}
1103-
}
1104-
elseif ("$containerOsVersion".StartsWith('10.0.15063.')) {
1105-
$containerOs = "1703"
1106-
}
1107-
elseif ("$containerOsVersion".StartsWith('10.0.16299.')) {
1108-
$containerOs = "1709"
1109-
}
1110-
elseif ("$containerOsVersion".StartsWith('10.0.17134.')) {
1111-
$containerOs = "1803"
1112-
}
1113-
elseif ("$containerOsVersion".StartsWith('10.0.17763.')) {
1114-
$containerOs = "ltsc2019"
1115-
}
1116-
elseif ("$containerOsVersion".StartsWith('10.0.18362.')) {
1117-
$containerOs = "1903"
1118-
}
1119-
elseif ("$containerOsVersion".StartsWith('10.0.18363.')) {
1120-
$containerOs = "1909"
1121-
}
1122-
elseif ("$containerOsVersion".StartsWith('10.0.19041.')) {
1123-
$containerOs = "2004"
1124-
}
1125-
elseif ("$containerOsVersion".StartsWith('10.0.19042.')) {
1126-
$containerOs = "20H2"
1127-
}
1128-
elseif ("$containerOsVersion".StartsWith('10.0.19043.')) {
1129-
$containerOs = "21H1"
1130-
}
1131-
elseif ("$containerOsVersion".StartsWith('10.0.19044.')) {
1132-
$containerOs = "21H2"
1133-
}
1134-
elseif ("$containerOsVersion".StartsWith('10.0.19045.')) {
1135-
$containerOs = "22H2"
1136-
}
1137-
elseif ("$containerOsVersion".StartsWith('10.0.20348.')) {
1138-
$containerOs = "ltsc2022"
1139-
}
1140-
else {
1141-
$containerOs = "unknown"
1035+
$containerOs = GetContainerOs -containerOsVersion $containerOsVersion
1036+
if ($containerOs -eq 'ltsc2016' -and !$useBestContainerOS -and $TimeZoneId -eq $null) {
1037+
$timeZoneId = (Get-TimeZone).Id
11421038
}
11431039
Write-Host "Container OS Version: $containerOsVersion ($containerOs)"
11441040
Write-Host "Host OS Version: $hostOsVersion ($hostOs)"
@@ -1223,94 +1119,15 @@ try {
12231119
}
12241120

12251121
$containerOsVersion = [Version]"$($inspect.Config.Labels.osversion)"
1226-
1227-
if ("$containerOsVersion".StartsWith('10.0.14393.')) {
1228-
$containerOs = "ltsc2016"
1229-
}
1230-
elseif ("$containerOsVersion".StartsWith('10.0.15063.')) {
1231-
$containerOs = "1703"
1232-
}
1233-
elseif ("$containerOsVersion".StartsWith('10.0.16299.')) {
1234-
$containerOs = "1709"
1235-
}
1236-
elseif ("$containerOsVersion".StartsWith('10.0.17134.')) {
1237-
$containerOs = "1803"
1238-
}
1239-
elseif ("$containerOsVersion".StartsWith('10.0.17763.')) {
1240-
$containerOs = "ltsc2019"
1241-
}
1242-
elseif ("$containerOsVersion".StartsWith('10.0.18362.')) {
1243-
$containerOs = "1903"
1244-
}
1245-
elseif ("$containerOsVersion".StartsWith('10.0.18363.')) {
1246-
$containerOs = "1909"
1247-
}
1248-
elseif ("$containerOsVersion".StartsWith('10.0.19041.')) {
1249-
$containerOs = "2004"
1250-
}
1251-
elseif ("$containerOsVersion".StartsWith('10.0.19042.')) {
1252-
$containerOs = "20H2"
1253-
}
1254-
elseif ("$containerOsVersion".StartsWith('10.0.19043.')) {
1255-
$containerOs = "21H1"
1256-
}
1257-
elseif ("$containerOsVersion".StartsWith('10.0.19044.')) {
1258-
$containerOs = "21H2"
1259-
}
1260-
elseif ("$containerOsVersion".StartsWith('10.0.19045.')) {
1261-
$containerOs = "22H2"
1262-
}
1263-
elseif ("$containerOsVersion".StartsWith('10.0.20348.')) {
1264-
$containerOs = "ltsc2022"
1265-
}
1266-
else {
1267-
$containerOs = "unknown"
1268-
}
1269-
1122+
$containerOs = GetContainerOs -containerOsVersion $containerOsVersion
1123+
12701124
Write-Host "Generic Container OS Version: $containerOsVersion ($containerOs)"
12711125

12721126
$genericTagVersion = [Version]"$($inspect.Config.Labels.tag)"
12731127
Write-Host "Generic Tag of better generic: $genericTagVersion"
12741128
}
12751129

1276-
if ($hostOsVersion -eq $containerOsVersion) {
1277-
if ($isolation -eq "") {
1278-
$isolation = "process"
1279-
}
1280-
}
1281-
elseif ($hostOsVersion.Build -ge 20348 -and $containerOsVersion.Build -ge 20348) {
1282-
if ($isolation -eq "") {
1283-
Write-Host -ForegroundColor Yellow "WARNING: Container and host OS build is 20348 or above, defaulting to process isolation. If you encounter issues, you could try to install HyperV."
1284-
$isolation = "process"
1285-
}
1286-
}
1287-
elseif (("$hostOsVersion".StartsWith('10.0.19043.') -or "$hostOsVersion".StartsWith('10.0.19044.') -or "$hostOsVersion".StartsWith('10.0.19045.')) -and "$containerOsVersion".StartsWith("10.0.19041.")) {
1288-
if ($isolation -eq "") {
1289-
Write-Host -ForegroundColor Yellow "WARNING: Host OS is Windows 10 21H1 or newer and Container OS is 2004, defaulting to process isolation. If you experience problems, add -isolation hyperv."
1290-
$isolation = "process"
1291-
}
1292-
}
1293-
else {
1294-
if ($isolation -eq "") {
1295-
if ($isAdministrator) {
1296-
if (Get-HypervState -ne "Disabled") {
1297-
$isolation = "hyperv"
1298-
}
1299-
else {
1300-
$isolation = "process"
1301-
Write-Host -ForegroundColor Yellow "WARNING: Host OS and Base Image Container OS doesn't match and HyperV is not installed. If you encounter issues, you could try to install HyperV."
1302-
}
1303-
}
1304-
else {
1305-
$isolation = "hyperv"
1306-
Write-Host -ForegroundColor Yellow "WARNING: Host OS and Base Image Container OS doesn't match, defaulting to hyperv. If you do not have HyperV installed or you encounter issues, you could try to specify -isolation process"
1307-
}
1308-
1309-
}
1310-
elseif ($isolation -eq "process") {
1311-
Write-Host -ForegroundColor Yellow "WARNING: Host OS and Base Image Container OS doesn't match and process isolation is specified. If you encounter issues, you could try to specify -isolation hyperv"
1312-
}
1313-
}
1130+
$isolation = GetIsolationMode -hostOsVersion $hostOsVersion -containerOsVersion $containerOsVersion -useSSL $useSSL -isolation $isolation
13141131
Write-Host "Using $isolation isolation"
13151132

13161133
if ($isolation -eq "process" -and !$isServerHost -and ($os.BuildNumber -eq 22621 -or $os.BuildNumber -eq 22631 -or $os.BuildNumber -eq 26100) -and $useSSL) {

ContainerHandling/New-NavImage.ps1

+3-81
Original file line numberDiff line numberDiff line change
@@ -355,48 +355,7 @@ try {
355355
}
356356

357357
$containerOsVersion = [Version](Get-BcContainerOsVersion -containerOrImageName $baseImage)
358-
if ("$containerOsVersion".StartsWith('10.0.14393.')) {
359-
$containerOs = "ltsc2016"
360-
}
361-
elseif ("$containerOsVersion".StartsWith('10.0.15063.')) {
362-
$containerOs = "1703"
363-
}
364-
elseif ("$containerOsVersion".StartsWith('10.0.16299.')) {
365-
$containerOs = "1709"
366-
}
367-
elseif ("$containerOsVersion".StartsWith('10.0.17134.')) {
368-
$containerOs = "1803"
369-
}
370-
elseif ("$containerOsVersion".StartsWith('10.0.17763.')) {
371-
$containerOs = "ltsc2019"
372-
}
373-
elseif ("$containerOsVersion".StartsWith('10.0.18362.')) {
374-
$containerOs = "1903"
375-
}
376-
elseif ("$containerOsVersion".StartsWith('10.0.18363.')) {
377-
$containerOs = "1909"
378-
}
379-
elseif ("$containerOsVersion".StartsWith('10.0.19041.')) {
380-
$containerOs = "2004"
381-
}
382-
elseif ("$containerOsVersion".StartsWith('10.0.19042.')) {
383-
$containerOs = "20H2"
384-
}
385-
elseif ("$containerOsVersion".StartsWith('10.0.19043.')) {
386-
$containerOs = "21H1"
387-
}
388-
elseif ("$containerOsVersion".StartsWith('10.0.19044.')) {
389-
$containerOs = "21H2"
390-
}
391-
elseif ("$containerOsVersion".StartsWith('10.0.19045.')) {
392-
$containerOs = "22H2"
393-
}
394-
elseif ("$containerOsVersion".StartsWith('10.0.20348.')) {
395-
$containerOs = "ltsc2022"
396-
}
397-
else {
398-
$containerOs = "unknown"
399-
}
358+
$containerOs = GetContainerOs -containerOsVersion $containerOsVersion
400359
Write-Host "Container OS Version: $containerOsVersion ($containerOs)"
401360
Write-Host "Host OS Version: $hostOsVersion ($hostOs)"
402361

@@ -406,45 +365,8 @@ try {
406365

407366
throw "The container operating system is newer than the host operating system, cannot use image"
408367
}
409-
410-
if ($hostOsVersion -eq $containerOsVersion) {
411-
if ($isolation -eq "") {
412-
$isolation = "process"
413-
}
414-
}
415-
elseif ($hostOsVersion.Build -ge 20348 -and $containerOsVersion.Build -ge 20348) {
416-
if ($isolation -eq "") {
417-
Write-Host -ForegroundColor Yellow "WARNING: Container and host OS build is 20348 or above, defaulting to process isolation. If you encounter issues, you could try to install HyperV."
418-
$isolation = "process"
419-
}
420-
}
421-
elseif (("$hostOsVersion".StartsWith('10.0.19043.') -or "$hostOsVersion".StartsWith('10.0.19044.') -or "$hostOsVersion".StartsWith('10.0.19045.')) -and "$containerOsVersion".StartsWith("10.0.19041.")) {
422-
if ($isolation -eq "") {
423-
Write-Host -ForegroundColor Yellow "WARNING: Host OS is Windows 10 21H1 or newer and Container OS is 2004, defaulting to process isolation. If you experience problems, add -isolation hyperv."
424-
$isolation = "process"
425-
}
426-
}
427-
else {
428-
if ($isolation -eq "") {
429-
if ($isAdministrator) {
430-
if (Get-HypervState -ne "Disabled") {
431-
$isolation = "hyperv"
432-
}
433-
else {
434-
$isolation = "process"
435-
Write-Host "WARNING: Host OS and Base Image Container OS doesn't match and Hyper-V is not installed. If you encounter issues, you could try to install Hyper-V."
436-
}
437-
}
438-
else {
439-
$isolation = "hyperv"
440-
Write-Host "WARNING: Host OS and Base Image Container OS doesn't match, defaulting to hyperv. If you do not have Hyper-V installed or you encounter issues, you could try to specify -isolation process"
441-
}
442-
443-
}
444-
elseif ($isolation -eq "process") {
445-
Write-Host "WARNING: Host OS and Base Image Container OS doesn't match and process isolation is specified. If you encounter issues, you could try to specify -isolation hyperv"
446-
}
447-
}
368+
369+
$isolation = GetIsolationMode -hostOsVersion $hostOsVersion -containerOsVersion $containerOsVersion -useSSL $false -isolation $isolation
448370
Write-Host "Using $isolation isolation"
449371
}
450372

0 commit comments

Comments
 (0)