Category Archives: Technical

Azure DevOps release pipeline

Some days ago I wrote a blog post about Azure release Pipelines (CD) and how we can’t use YAML in that. The only option is to do it visually with designer. If I compare this with GitHub workflows, there we can write CI and CD both in YAML syntax.

After that I found a blog post from Microsoft dev blog saying we can use YAML for CD in Azure Pipelines as well. Designing a release pipeline visually with designer, is a legacy way of doing CD now.

PowerShell in a container

Recently I found that we can execute a PowerShell script in a docker container. There is a base image for PowerShell in docker hub and you can use that to create your own image with your PowerShell script. Now when you create docker image and container from that, your PowerShell script can execute inside that container.

Example: https://github.com/Arnab-Developer/PowerShellInContainer

Custom PowerShell prompt

My custom PowerShell prompt without the use of oh-my-posh. Create or open file with name Microsoft.PowerShell_profile.ps1 at location C:\Users\<your user name>\Documents\PowerShell\ and paste this code inside that. Then open a PowerShell window to check the prompt.

function prompt
{
    [string] $currentFolderName = GetCurrentFolderName
    [string] $gitStatus = (git status)
    if ([string]::IsNullOrEmpty($gitStatus))
    {
        Write-Host "→ $currentFolderName" -NoNewLine -ForegroundColor DarkCyan
    }
    else
    {
        Write-Host "→ $currentFolderName (" -NoNewLine -ForegroundColor DarkCyan
        Write-Host "$(git branch --show-current)" -NoNewLine -ForegroundColor DarkRed
        Write-Host ")" -NoNewLine -ForegroundColor DarkCyan
    }
    return " "
}

function GetCurrentFolderName
{
    [string] $location = Get-Location
    [string] $currentFolderName = [string]::Empty
    if ($location.EndsWith("\"))
    {
        $currentFolderName = $location
    }
    else
    {
        [int] $lastIndexOfSlash = $location.LastIndexOf("\")
        $currentFolderName = $location.SubString($lastIndexOfSlash + 1)
    }
    return $currentFolderName
}