diff --git a/AppHandling/Publish-NavContainerApp.ps1 b/AppHandling/Publish-NavContainerApp.ps1 index cac3d91a7..d274d44b1 100644 --- a/AppHandling/Publish-NavContainerApp.ps1 +++ b/AppHandling/Publish-NavContainerApp.ps1 @@ -310,6 +310,7 @@ try { } else { [ScriptBlock] $scriptblock = { Param($appFile, $skipVerification, $sync, $install, $upgrade, $tenant, $syncMode, $packageType, $scope, $language, $PublisherAzureActiveDirectoryTenantId, $force, $ignoreIfAppExists) + $prevPreference = $ProgressPreference; $ProgressPreference = "SilentlyContinue" $publishArgs = @{ "packageType" = $packageType } if ($scope) { $publishArgs += @{ "Scope" = $scope } @@ -394,6 +395,7 @@ try { Start-NavAppDataUpgrade -ServerInstance $ServerInstance -Publisher $appPublisher -Name $appName -Version $appVersion -Tenant $tenant @installArgs } } + $ProgressPreference = $prevPreference } if ($isCloudBcContainer) { $containerPath = Join-Path 'C:\DL' ([System.IO.Path]::GetFileName($appfile)) diff --git a/Common/Download-File.ps1 b/Common/Download-File.ps1 index 1eed895ab..e9e0c33a3 100644 --- a/Common/Download-File.ps1 +++ b/Common/Download-File.ps1 @@ -30,9 +30,6 @@ function Download-File { [int] $timeout = 100 ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $replaceUrls = @{ "https://go.microsoft.com/fwlink/?LinkID=844461" = "https://bcartifacts.azureedge.net/prerequisites/DotNetCore.1.0.4_1.1.1-WindowsHosting.exe" "https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi" = "https://bcartifacts.azureedge.net/prerequisites/rewrite_2.0_rtw_x64.msi" @@ -99,12 +96,4 @@ try { } } } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Export-ModuleMember -Function Download-File diff --git a/ContainerHandling/Get-NavContainerSession.ps1 b/ContainerHandling/Get-NavContainerSession.ps1 index 35fb06f38..7893f7e5a 100644 --- a/ContainerHandling/Get-NavContainerSession.ps1 +++ b/ContainerHandling/Get-NavContainerSession.ps1 @@ -30,7 +30,7 @@ function Get-BcContainerSession { $session = $sessions[$containerName] try { $platformVersion = Invoke-Command -Session $session -ScriptBlock { [System.Version](get-item 'C:\Program Files\Microsoft Dynamics NAV\*\Service\Microsoft.Dynamics.Nav.Server.exe').Versioninfo.FileVersion } - if ($platformVersion -ge 24 -and ($usePwsh -xor $session.ConfigurationName -eq 'PowerShell.7')) { + if ($platformVersion.Major -ge 24 -and ($usePwsh -xor $session.ConfigurationName -eq 'PowerShell.7')) { # Cannot use existing session Remove-PSSession -Session $session $sessions.Remove($containerName) diff --git a/ContainerInfo/Get-NavContainerArtifactUrl.ps1 b/ContainerInfo/Get-NavContainerArtifactUrl.ps1 index dc0e9cf9d..282012360 100644 --- a/ContainerInfo/Get-NavContainerArtifactUrl.ps1 +++ b/ContainerInfo/Get-NavContainerArtifactUrl.ps1 @@ -16,9 +16,6 @@ function Get-BcContainerArtifactUrl { [string] $containerName = $bcContainerHelperConfig.defaultContainerName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $inspect = docker inspect $containerName | ConvertFrom-Json $artifactUrlEnv = $inspect.config.Env | Where-Object { $_ -like "artifactUrl=*" } if ($artifactUrlEnv) { @@ -28,13 +25,5 @@ try { return "" } } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerArtifactUrl -Value Get-BcContainerArtifactUrl Export-ModuleMember -Function Get-BcContainerArtifactUrl -Alias Get-NavContainerArtifactUrl diff --git a/ContainerInfo/Get-NavContainerCountry.ps1 b/ContainerInfo/Get-NavContainerCountry.ps1 index 93700ad5f..5d5061b79 100644 --- a/ContainerInfo/Get-NavContainerCountry.ps1 +++ b/ContainerInfo/Get-NavContainerCountry.ps1 @@ -17,23 +17,11 @@ function Get-BcContainerCountry { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $inspect = docker inspect $containerOrImageName | ConvertFrom-Json if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") { throw "Container $containerOrImageName is not a NAV/BC container" } return "$($inspect.Config.Labels.country)" - -} -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} } Set-Alias -Name Get-NavContainerCountry -Value Get-BcContainerCountry Export-ModuleMember -Function Get-BcContainerCountry -Alias Get-NavContainerCountry diff --git a/ContainerInfo/Get-NavContainerDebugInfo.ps1 b/ContainerInfo/Get-NavContainerDebugInfo.ps1 index c14ffb3d1..ffd350af7 100644 --- a/ContainerInfo/Get-NavContainerDebugInfo.ps1 +++ b/ContainerInfo/Get-NavContainerDebugInfo.ps1 @@ -45,9 +45,6 @@ function Get-BcContainerDebugInfo { [switch] $CopyToClipboard ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $debugInfo = @{} $inspect = docker inspect $containerName | ConvertFrom-Json @@ -107,13 +104,5 @@ try { return $debugInfoJson } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerDebugInfo -Value Get-BcContainerDebugInfo Export-ModuleMember -Function Get-BcContainerDebugInfo -Alias Get-NavContainerDebugInfo diff --git a/ContainerInfo/Get-NavContainerEula.ps1 b/ContainerInfo/Get-NavContainerEula.ps1 index 311950a16..0fc95ec9b 100644 --- a/ContainerInfo/Get-NavContainerEula.ps1 +++ b/ContainerInfo/Get-NavContainerEula.ps1 @@ -18,21 +18,11 @@ function Get-BcContainerEula { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { $inspect = docker inspect $containerOrImageName | ConvertFrom-Json if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") { throw "Container $containerOrImageName is not a NAV/BC container" } return "$($inspect.Config.Labels.Eula)" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerEula -Value Get-BcContainerEula Export-ModuleMember -Function Get-BcContainerEula -Alias Get-NavContainerEula diff --git a/ContainerInfo/Get-NavContainerEventLog.ps1 b/ContainerInfo/Get-NavContainerEventLog.ps1 index 0c2c891d7..178952144 100644 --- a/ContainerInfo/Get-NavContainerEventLog.ps1 +++ b/ContainerInfo/Get-NavContainerEventLog.ps1 @@ -23,8 +23,6 @@ function Get-BcContainerEventLog { [switch] $doNotOpen ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { Write-Host "Getting event log for $containername" $eventLogFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "EventLogs" @@ -46,13 +44,5 @@ try { Start-Process -FilePath $eventLogName | Out-Null } } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerEventLog -Value Get-BcContainerEventLog Export-ModuleMember -Function Get-BcContainerEventLog -Alias Get-NavContainerEventLog diff --git a/ContainerInfo/Get-NavContainerGenericTag.ps1 b/ContainerInfo/Get-NavContainerGenericTag.ps1 index e2270ef83..88185d963 100644 --- a/ContainerInfo/Get-NavContainerGenericTag.ps1 +++ b/ContainerInfo/Get-NavContainerGenericTag.ps1 @@ -17,22 +17,11 @@ function Get-BcContainerGenericTag { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $inspect = docker inspect $containerOrImageName | ConvertFrom-Json if ($inspect.Config.Labels.psobject.Properties.Match('tag').Count -eq 0) { throw "Container $containerOrImageName is not a NAV/BC container" } return "$($inspect.Config.Labels.tag)" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerGenericTag -Value Get-BcContainerGenericTag Export-ModuleMember -Function Get-BcContainerGenericTag -Alias Get-NavContainerGenericTag diff --git a/ContainerInfo/Get-NavContainerId.ps1 b/ContainerInfo/Get-NavContainerId.ps1 index cd6f1a6a6..ff9109252 100644 --- a/ContainerInfo/Get-NavContainerId.ps1 +++ b/ContainerInfo/Get-NavContainerId.ps1 @@ -15,9 +15,6 @@ function Get-BcContainerId { [string] $containerName = $bcContainerHelperConfig.defaultContainerName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $id = "" docker ps --format "{{.ID}}:{{.Names}}" -a --no-trunc | ForEach-Object { $ps = $_.split(':') @@ -36,13 +33,5 @@ try { } $id } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerId -Value Get-BcContainerId Export-ModuleMember -Function Get-BcContainerId -Alias Get-NavContainerId diff --git a/ContainerInfo/Get-NavContainerImageLabels.ps1 b/ContainerInfo/Get-NavContainerImageLabels.ps1 index 27468d56f..b56d414eb 100644 --- a/ContainerInfo/Get-NavContainerImageLabels.ps1 +++ b/ContainerInfo/Get-NavContainerImageLabels.ps1 @@ -17,9 +17,6 @@ function Get-BcContainerImageLabels { [PSCredential] $registryCredential ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $webclient = New-Object System.Net.WebClient @@ -72,15 +69,6 @@ try { } catch { } - -} -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} } Set-Alias -Name Get-NavContainerImageLabels -Value Get-BcContainerImageLabels Export-ModuleMember -Function Get-BcContainerImageLabels -Alias Get-NavContainerImageLabels diff --git a/ContainerInfo/Get-NavContainerImageName.ps1 b/ContainerInfo/Get-NavContainerImageName.ps1 index 13e0d5835..7eb2087ad 100644 --- a/ContainerInfo/Get-NavContainerImageName.ps1 +++ b/ContainerInfo/Get-NavContainerImageName.ps1 @@ -16,18 +16,8 @@ function Get-BcContainerImageName { [string] $containerName = $bcContainerHelperConfig.defaultContainerName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { $inspect = docker inspect $containerName | ConvertFrom-Json return "$($inspect.Config.Image)" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerImageName -Value Get-BcContainerImageName Export-ModuleMember -Function Get-BcContainerImageName -Alias Get-NavContainerImageName diff --git a/ContainerInfo/Get-NavContainerImageTags.ps1 b/ContainerInfo/Get-NavContainerImageTags.ps1 index 609e01f58..fc8f31a30 100644 --- a/ContainerInfo/Get-NavContainerImageTags.ps1 +++ b/ContainerInfo/Get-NavContainerImageTags.ps1 @@ -19,9 +19,6 @@ function Get-BcContainerImageTags { [int] $pageSize = -1 ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $webclient = New-Object System.Net.WebClient @@ -77,13 +74,5 @@ try { catch { } } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerImageTags -Value Get-BcContainerImageTags Export-ModuleMember -Function Get-BcContainerImageTags -Alias Get-NavContainerImageTags diff --git a/ContainerInfo/Get-NavContainerIpAddress.ps1 b/ContainerInfo/Get-NavContainerIpAddress.ps1 index 914849a7b..b20b07d8d 100644 --- a/ContainerInfo/Get-NavContainerIpAddress.ps1 +++ b/ContainerInfo/Get-NavContainerIpAddress.ps1 @@ -18,9 +18,6 @@ function Get-BcContainerIpAddress { [string] $networkName = "" ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $ip = Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { $ip = "" $ips = Get-NetIPAddress | Where-Object { $_.AddressFamily -eq "IPv4" -and $_.IPAddress -ne "127.0.0.1" } @@ -47,13 +44,5 @@ try { } return $ip } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerIpAddress -Value Get-BcContainerIpAddress Export-ModuleMember -Function Get-BcContainerIpAddress -Alias Get-NavContainerIpAddress diff --git a/ContainerInfo/Get-NavContainerLegal.ps1 b/ContainerInfo/Get-NavContainerLegal.ps1 index d7bc71ed6..4aab491a9 100644 --- a/ContainerInfo/Get-NavContainerLegal.ps1 +++ b/ContainerInfo/Get-NavContainerLegal.ps1 @@ -18,22 +18,11 @@ function Get-BcContainerLegal { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $inspect = docker inspect $containerOrImageName | ConvertFrom-Json if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") { throw "Container $containerOrImageName is not a NAV/BC container" } return "$($inspect.Config.Labels.legal)" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerLegal -Value Get-BcContainerLegal Export-ModuleMember -Function Get-BcContainerLegal -Alias Get-NavContainerLegal diff --git a/ContainerInfo/Get-NavContainerLicenseInformation.ps1 b/ContainerInfo/Get-NavContainerLicenseInformation.ps1 index 8d047b69b..48e34f276 100644 --- a/ContainerInfo/Get-NavContainerLicenseInformation.ps1 +++ b/ContainerInfo/Get-NavContainerLicenseInformation.ps1 @@ -13,19 +13,9 @@ Function Get-BcContainerLicenseInformation { [String] $ContainerName = $bcContainerHelperConfig.defaultContainerName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Get-NavServerInstance | Export-NAVServerLicenseInformation } } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerLicenseInformation -Value Get-BcContainerLicenseInformation Export-ModuleMember -Function Get-BcContainerLicenseInformation -Alias Get-NavContainerLicenseInformation \ No newline at end of file diff --git a/ContainerInfo/Get-NavContainerName.ps1 b/ContainerInfo/Get-NavContainerName.ps1 index 7e0804607..df22df110 100644 --- a/ContainerInfo/Get-NavContainerName.ps1 +++ b/ContainerInfo/Get-NavContainerName.ps1 @@ -15,18 +15,7 @@ function Get-BcContainerName { [string] $containerId ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - docker ps --format='{{.Names}}' -a --filter "id=$containerId" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerName -Value Get-BcContainerName Export-ModuleMember -Function Get-BcContainerName -Alias Get-NavContainerName diff --git a/ContainerInfo/Get-NavContainerNavVersion.ps1 b/ContainerInfo/Get-NavContainerNavVersion.ps1 index e0cf2da34..0551948e0 100644 --- a/ContainerInfo/Get-NavContainerNavVersion.ps1 +++ b/ContainerInfo/Get-NavContainerNavVersion.ps1 @@ -17,21 +17,11 @@ function Get-BcContainerNavVersion { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { $inspect = docker inspect $containerOrImageName | ConvertFrom-Json if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") { throw "Container $containerOrImageName is not a NAV/BC container" } return "$($inspect.Config.Labels.version)-$($inspect.Config.Labels.country)" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerNavVersion -Value Get-BcContainerNavVersion Export-ModuleMember -Function Get-BcContainerNavVersion -Alias Get-NavContainerNavVersion diff --git a/ContainerInfo/Get-NavContainerOsVersion.ps1 b/ContainerInfo/Get-NavContainerOsVersion.ps1 index 8f1a168e4..b6cee527b 100644 --- a/ContainerInfo/Get-NavContainerOsVersion.ps1 +++ b/ContainerInfo/Get-NavContainerOsVersion.ps1 @@ -17,18 +17,8 @@ function Get-BcContainerOsVersion { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { $inspect = docker inspect $containerOrImageName | ConvertFrom-Json return "$($inspect.Config.Labels.osversion)" } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerOsVersion -Value Get-BcContainerOsVersion Export-ModuleMember -Function Get-BcContainerOsVersion -Alias Get-NavContainerOsVersion diff --git a/ContainerInfo/Get-NavContainerPath.ps1 b/ContainerInfo/Get-NavContainerPath.ps1 index 7adee4765..387f98b76 100644 --- a/ContainerInfo/Get-NavContainerPath.ps1 +++ b/ContainerInfo/Get-NavContainerPath.ps1 @@ -21,8 +21,6 @@ function Get-BcContainerPath { [switch] $throw ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { $containerPath = "" if ($path.StartsWith(":")) { $path =$path.Substring(1) @@ -50,13 +48,5 @@ try { } return $containerPath } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerPath -Value Get-BcContainerPath Export-ModuleMember -Function Get-BcContainerPath -Alias Get-NavContainerPath diff --git a/ContainerInfo/Get-NavContainerPlatformVersion.ps1 b/ContainerInfo/Get-NavContainerPlatformVersion.ps1 index 6c74d3429..49493a061 100644 --- a/ContainerInfo/Get-NavContainerPlatformVersion.ps1 +++ b/ContainerInfo/Get-NavContainerPlatformVersion.ps1 @@ -18,8 +18,6 @@ function Get-BcContainerPlatformVersion { [string] $containerOrImageName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { $inspect = docker inspect $containerOrImageName | ConvertFrom-Json if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") { throw "Container $containerOrImageName is not a NAV/BC container" @@ -30,13 +28,5 @@ try { return "" } } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerPlatformVersion -Value Get-BcContainerPlatformVersion Export-ModuleMember -Function Get-BcContainerPlatformVersion -Alias Get-NavContainerPlatformVersion diff --git a/ContainerInfo/Get-NavContainerServerConfiguration.ps1 b/ContainerInfo/Get-NavContainerServerConfiguration.ps1 index 805c00cdd..2f2065f22 100644 --- a/ContainerInfo/Get-NavContainerServerConfiguration.ps1 +++ b/ContainerInfo/Get-NavContainerServerConfiguration.ps1 @@ -13,37 +13,19 @@ Function Get-BcContainerServerConfiguration { [String] $ContainerName = $bcContainerHelperConfig.defaultContainerName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $ResultObjectArray = @() - $config = Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock{ - Get-NavServerInstance | Get-NAVServerConfiguration -AsXml - } - - $Object = New-Object -TypeName PSObject -Property @{ - ContainerName = $ContainerName - } - - if ($config) { - $Config.configuration.appSettings.add | ForEach-Object{ - $Object | Add-Member -MemberType NoteProperty -Name $_.Key -Value $_.Value + Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock{ Param($ContainerName) + $config = Get-NAVServerConfiguration -serverinstance BC -AsXml + $Object = [ordered]@{ "ContainerName" = $ContainerName } + if ($config) { + $Config.configuration.appSettings.add | ForEach-Object{ + $Object += @{ "$($_.Key)" = $_.Value } + } } - } - else { - $Object | Add-Member -MemberType NoteProperty -Name "ServerInstance" -Value "" - } - - $ResultObjectArray += $Object - - Write-Output $ResultObjectArray -} -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} + else { + $Object += @{ "ServerInstance" = "" } + } + $object | ConvertTo-Json -Depth 99 -compress + } -argumentList $containerName | ConvertFrom-Json } Set-Alias -Name Get-NavContainerServerConfiguration -Value Get-BcContainerServerConfiguration Export-ModuleMember -Function Get-BcContainerServerConfiguration -Alias Get-NavContainerServerConfiguration diff --git a/ContainerInfo/Get-NavContainerSharedFolders.ps1 b/ContainerInfo/Get-NavContainerSharedFolders.ps1 index c302011ee..fc32b6a3f 100644 --- a/ContainerInfo/Get-NavContainerSharedFolders.ps1 +++ b/ContainerInfo/Get-NavContainerSharedFolders.ps1 @@ -19,9 +19,6 @@ function Get-BcContainerSharedFolders { [string] $containerName = $bcContainerHelperConfig.defaultContainerName ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { - $inspect = docker inspect $containerName | ConvertFrom-Json $sharedFolders = @{} if ($inspect.HostConfig.Binds) { @@ -50,13 +47,5 @@ try { } return $sharedFolders } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainerSharedFolders -Value Get-BcContainerSharedFolders Export-ModuleMember -Function Get-BcContainerSharedFolders -Alias Get-NavContainerSharedFolders diff --git a/ContainerInfo/Get-NavContainers.ps1 b/ContainerInfo/Get-NavContainers.ps1 index 81164bd4c..adf99df77 100644 --- a/ContainerInfo/Get-NavContainers.ps1 +++ b/ContainerInfo/Get-NavContainers.ps1 @@ -11,8 +11,6 @@ function Get-BcContainers { [switch] $includeLabels ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { if ($includeLabels) { $containers = @() docker ps --filter "label=nav" -a --no-trunc --format 'name={{.Names}},id={{.ID}},image={{.Image}},createdat={{.CreatedAt}},runningfor={{.RunningFor}},size={{.Size}},status={{.Status}},{{.Labels}}' | % { @@ -30,13 +28,5 @@ try { } $containers } -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope -} -} Set-Alias -Name Get-NavContainers -Value Get-BcContainers Export-ModuleMember -Function Get-BcContainers -Alias Get-NavContainers diff --git a/HelperFunctions.ps1 b/HelperFunctions.ps1 index bcaeb33fc..1c75250ee 100644 --- a/HelperFunctions.ps1 +++ b/HelperFunctions.ps1 @@ -535,7 +535,16 @@ function CopyAppFilesToFolder { elseif (Test-Path $appFile -PathType Leaf) { Get-ChildItem $appFile | ForEach-Object { $appFile = $_.FullName - if ([string]::new([char[]](Get-Content $appFile @byteEncodingParam -TotalCount 2)) -eq "PK") { + if ($appFile -like "*.app") { + $destFileName = [System.IO.Path]::GetFileName($appFile) + $destFile = Join-Path $folder $destFileName + if (Test-Path $destFile) { + Write-Host -ForegroundColor Yellow "::WARNING::$destFileName already exists, it looks like you have multiple app files with the same name. App filenames must be unique." + } + Copy-Item -Path $appFile -Destination $destFile -Force + $destFile + } + elseif ([string]::new([char[]](Get-Content $appFile @byteEncodingParam -TotalCount 2)) -eq "PK") { $tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) $copied = $false try { @@ -553,15 +562,6 @@ function CopyAppFilesToFolder { if ($copied) { Remove-Item -Path $appFile -Force } } } - elseif ($appFile -like "*.app") { - $destFileName = [System.IO.Path]::GetFileName($appFile) - $destFile = Join-Path $folder $destFileName - if (Test-Path $destFile) { - Write-Host -ForegroundColor Yellow "::WARNING::$destFileName already exists, it looks like you have multiple app files with the same name. App filenames must be unique." - } - Copy-Item -Path $appFile -Destination $destFile -Force - $destFile - } } } else {