Txt2AL

 


Below Command Execute In BC14 Development Shell

Base Object Export From BC14

Export-NAVApplicationObject  -DatabaseName DemoDB14-IN -Path 'D:\BFPL\Bikano\SourceBase\Base.txt' -DatabaseServer localhost -ExportToNewSyntax -Filter 'Modified=Yes'

Export-NAVApplicationObject  -DatabaseName DemoDB14-IN -Path 'D:\BFPL\Bikano\SourceBase\Base.txt' -DatabaseServer localhost -ExportToNewSyntax -Filter 

'Type=Page;Id=5740'

Customized Object Export From BC14

Export-NAVApplicationObject  -DatabaseName BIK2016TOBC -Path 'D:\BFPL\Bikano\SourceBase\42Page.txt' -DatabaseServer localhost -ExportToNewSyntax -Filter 'Type=Page;Id=42'

Export-NAVApplicationObject  -DatabaseName BIK2016TOBC -Path 'D:\BFPL\Bikano\SourceBase\507Page.txt' -DatabaseServer localhost -ExportToNewSyntax -Filter 'Type=Page;Id=507'

Object  Compare

Compare-NAVApplicationObject -OriginalPath 'D:\BFPL\Bikano\SourceBase\Base.txt' -ModifiedPath 'D:\BFPL\Bikano\SourceBase\42Page.txt' -DeltaPath 'D:\BFPL\Bikano\Delta\' -ExportToNewSyntax

cmd 

cd C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client

txt2al.exe –-source="D:\BFPL\Bikano\Delta" –-target="D:\BFPL\Bikano\AL"


Export-NAVApplicationObject  -DatabaseName DemoDB14-IN -Path 'D:\BFPL\Bikano\SourceBase\Base.txt' -DatabaseServer localhost -ExportToNewSyntax -Filter 'Type=Page;Id=5740'


Export-NAVApplicationObject  -DatabaseName BIK2016TOBC -Path 'D:\BFPL\Bikano\Modified\Page.txt' -DatabaseServer localhost -ExportToNewSyntax -Filter 'Type=Page;Id=5740'


Compare-NAVApplicationObject -OriginalPath 'D:\BFPL\Bikano\SourceBase\Base.txt' -ModifiedPath 'D:\BFPL\Bikano\Modified\Page.txt' -DeltaPath 'D:\BFPL\Bikano\Delta\' -ExportToNewSyntax


txt2al.exe –-source="D:\BFPL\Bikano\Delta" –-target="D:\BFPL\Bikano\AL"



Continue Reading...

Recording Business Central NavContainerHelper benchmarks

 $StartTime = $(get-date)   

  Try {   
   $output = "Started: " + $StartTime   
   Write-Output $output    
   $containerName = 'bc1'   
   $password = 'P@ssw0rd'   
   $securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force   
   $credential = New-Object pscredential 'admin', $securePassword   
   $auth = 'UserPassword'   
   $artifactUrl = Get-BcArtifactUrl -type 'Sandbox' -version '' -country 'us' -select 'Latest'   
   New-BcContainer `   
    -accept_eula `   
    -containerName $containerName `   
    -credential $credential `   
    -auth $auth `   
    -artifactUrl $artifactUrl `   
    -imageName 'myimage1' `   
    -dns '8.8.8.8' `   
    -updateHosts   
   }   
   Catch {   
    Write-Error "Um, something didn't go well:"   
    Write-Error $_   
   }   
   Finally {   
    $EndTime = $(get-date)   
    $output = "End time: " + $EndTime   
    Write-Output $output    
    $elapsedTime = $(get-date) - $StartTime   
    $totalTime = "{0:HH:mm:ss}" -f ([datetime]$elapsedTime.Ticks)   
    $output = "Elapsed time: " + $totalTime   
    Write-Output $output   
   }   
Continue Reading...

Basic Business Central Docker Commands That I Use

 Open Powershell / Powershell ISE on HOST machine using Run As Administrator  

   
 
 NOTE: When referring to a Container ID or Image ID, you can use the first 
       few characters of the ID if they are unique--you do not have to always
       use the full ID.


 Check NavContainerHelper Version  
   
      Get-InstalledModule NavContainerHelper  
   
   
 Fresh Install of NavContainerHelper  
   
      Install-module navcontainerhelper  
      Import-Module navcontainerhelper  
   
   
 Install Latest NavContainerHelper  
   
 If you KNOW you don't have multiple versions installed:  
   
      Update-Module NavContainerHelper -Force  
   
 If you MIGHT have multiple versions installed:  
   
      $MyModuleName = <modulename>  
      Uninstall-Module $MyModuleName -allversions   
      Install-Module $MyModuleName
   
      NOTE: I do not recommend using the -Force option with Install-Module. 
            It can bypass valuable warnings that you want to know about.


 Alternate method to Remove Old Versions of NavContainerHelper  
   
      $ModuleName = 'navcontainerhelper';  
      $Latest = Get-InstalledModule $ModuleName;   
      Get-InstalledModule $ModuleName -AllVersions | ? {$_.Version -ne $Latest.Version} | Uninstall-Module -WhatIf  
   
   
   
 Container Management Commands  
   
   	Compact Container listing:
    
      docker ps --format "table {{.Names}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Status}}"
      
    Full listing:
    
      docker ps  
      docker ps -a  
        
      docker start <id>  
      docker stop <id>  
   
      
      docker container inspect 


 Remove Container  
   
    Recommended method:

      Remove-BCContainer <containername>


    Manual Docker method:

      docker stop <id> 
      docker rm <id> 
      Manually clean up hosts file
      Manually remove desktop icons
      Manually remove extensions from C:\ProgramData\NavContainerHelper\Extensions\
   

 Stop all running containers:  
        
      docker stop $(docker ps -aq)  
   
   
 Images  
   
       docker images  
       docker images -a  
   
 Remove Image  
   
      docker rmi <id>  
        
      docker rmi <repository>:<tag>  
   
   Remove all images:

      docker rmi $(docker images -aq)

   
 Clean up old images  
   
   Remove orphaned images with "< none >" identifiers:

      docker images -q -f dangling=true | % { docker rmi $_ }  


   Remove orphaned images:
   
   	  docker image prune -f
      
   Remove orphaned AND UNUSED images:
   
   WARNING: Be careful with this: It will remove generic OS images used by NavContainerHelper!

      docker image prune -a -f
   

   
 Get Artifact Info for an existing BC Container:  
   
      Get-BcContainerArtifactUrl containername  
        
      Get-NavContainerArtifactUrl containername  
   
   
 Diagnostics  
   
      Get-BcContainerEventLog  
   
   
   
 Create New BC Container  
   
      New-BcContainerWizard  
   
   
 https://blog.baudson.de/blog/stop-and-remove-all-docker-containers-and-images  
Continue Reading...

Automatically Update BcContainerHelper - Improved Script

  #v1.0 - March 27, 2021

#
$server = $env:COMPUTERNAME
#Define date values
$simpleDate = Get-Date -Format "M/d/yy"
$dateTime = Get-Date -Format "M/d/yy HH:mm"
$fileDateTime = Get-Date -Format "yyyy-MM-dd HHmm"

#Define the module name
$moduleName = 'BcContainerHelper'

$body = ""
$message = ""
$updated = $false

#Specify file location for activity transcript log file
$transcriptFile = "D:\BCPowerShell\Logs\" + $fileDateTime + " " + $server + " " + $moduleName + " Update Log.txt"

#Start recording transcript
Start-Transcript -Path $transcriptFile

#Record the start time
$StartTime = $(get-date)


#Define email configuration
$emailFrom = "myemail@gmail.com"
$emailTo = "myemail@gmail.com"
$smtpServer = "smtp.gmail.com"
$port = "587"
#Email password file created using:  Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File -FilePath D:\BCPowerShell\Gmail_password.securestring
$passwordFile = "D:\BCPowerShell\Gmail_password.securestring"
$securePassword = ConvertTo-SecureString (Get-Content -Path $passwordFile)
$smtpCred = New-Object -TypeName PSCredential ($emailFrom, $securePassword)

$subject = $server + ": " + $simpleDate + " " + $moduleName + " Update Log";

$started = "Start time: " + $StartTime
$body += $started + "`n`n"

Try
{
    #Get currently installed version
    $currentVersion = (Get-InstalledModule $moduleName -ErrorAction SilentlyContinue).Version.ToString()
}
Catch 
{
    $currentVersion = "(not installed)"
}

#Get the latest version available
$latestVersion = (Find-Module $moduleName).Version.ToString()



#If we don't have the latest version installed
If ($currentVersion -ne $latestVersion)
{

    $message = "Current version: " + $currentVersion + "`nLatest version: " + $latestVersion;
    $message += "`n`nUpdating to version " + $latestVersion;
    #Remove existing version(s)
    Uninstall-Module $moduleName -Force -AllVersions -ErrorAction SilentlyContinue

    #Install latest version
    Install-Module $moduleName -Force

    $updated = $true;

    #Verify version number
    $currentVersion = (Get-InstalledModule $moduleName).Version.ToString()
    $message += "`nUpdate complete";
    $message += "`nCurrent version is now " + $currentVersion;
        
    $body += "`n" + $message;

    Write-Output $message
}
Else
{
    #If we are on the latest version, log that info
    $message = "You are on the latest version of " + $moduleName + ": " + $currentVersion;
    Write-Output $message
}



#Record end time
$EndTime = $(get-date)
$output = "`nEnd time: " + $EndTime
$body += "`n" + $output 
Write-Output $output 

#Calculate elapsed time
$elapsedTime = $EndTime - $StartTime
$totalTime = "{0:HH:mm:ss}" -f ([datetime]$elapsedTime.Ticks)
$output = "Elapsed time: " + $totalTime
$body += "`n" + $output 
Write-Output $output

$body += "`n`nFull log file is attached" 

#Finish the transcript recording
#The Transcript must be stopped before trying to send the email,
#otherwise the log file will be locked, causing the email to fail
Stop-Transcript
        
if ($updated)
{
#Send the email
Send-MailMessage -From $emailFrom -To $emailTo `
    -Subject $subject `
    -Body $body `
    -Attachments $transcriptFile `
    -SmtpServer $smtpServer `
    -Credential $smtpCred `
    -Port $port `
    -UseSsl
}  
Continue Reading...