Public/Get-Txt2AlFromArtifacts.ps1

function Get-Txt2AlFromArtifacts {
    param (
        [String] $version = '14',
        [ValidateSet('Latest', 'First', 'All', 'Closest', 'SecondToLastMajor', 'Current', 'NextMinor', 'NextMajor')]
        [String] $select = 'Latest'
    )

    $majorVersion = [int]($version.Split('.')[0])
    if ($majorVersion -ne "14") {
        Write-Error "Invalid version. Txt2Al tool is only available on BC 14."
        return
    }

    $txt2AlFolderName = "Txt2Al"
    $txt2AlFolder = Join-Path (Get-Location) $txt2AlFolderName
    if (Test-Path $txt2AlFolder) {
        Write-Host "Txt2Al folder already exists and won't be created."
        return
    }
    $txt2AlFolder = New-Item -Path $txt2AlFolder -ItemType "directory"

    $type = 'OnPrem'
    $artifactUrl = Get-BCArtifactUrl -version $version -country w1 -select $select -type $type
    
    $artifactPaths = Download-Artifacts -artifactUrl $artifactUrl -includePlatform
    $platformArtifactPath = $artifactPaths[1]

    $rtcClientPath = Join-Path $platformArtifactPath "RoleTailoredClient\program files\Microsoft Dynamics NAV\140\RoleTailored Client"
    Copy-Item -Path (Join-Path $rtcClientPath "Txt2Al.exe") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Txt2AlConverter.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "CommandLine.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.CodeAnalysis.CSharp.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.CodeAnalysis.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.Dynamics.Nav.CodeAnalysis.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.Dynamics.Nav.Model.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.Dynamics.Nav.Model.Parser.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.Dynamics.Nav.Model.TypeSystem.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "System.Collections.Immutable.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.dll") -Destination $txt2AlFolder
    Copy-Item -Path (Join-Path $rtcClientPath "Mono.Cecil.dll") -Destination $txt2AlFolder

    Write-Host "Txt2Al files copied to $($txt2AlFolder)"
}

Export-ModuleMember -Function Get-Txt2AlFromArtifacts