PowerShell 2 min read
How to Install Visual Studio Code and Configure with Azure Repos for PowerShell Scripts
Michael Wu ·
I previously managed PowerShell scripts using ISE and Dropbox, but found this approach lacked change tracking. Visual Studio Code with Azure Repos integration became the preferred solution.
Installation Steps
Install Visual Studio Code
- Download the latest version from Visual Studio Code
- Choose between User Installer or System Installer
- Install PowerShell Extension via Extensions marketplace
- Install Azure Repos extension (VSTS)
Install Git for Windows
- Download Git for Windows
- Configure VSCode as Git’s default editor
- Select OpenSSH option
- Use native Windows Secure Channel library
Install Posh-Git Module
Install-Module posh-git -Scope AllUsers
Verify installation:
Get-Module posh-git -ListAvailable
Clone Azure Repos in VSCode
- Sign into Azure Repos and select “Clone in VS Code”
- Choose repository location on local drive
- If encountering fatal access errors, rename project to remove spaces
- Authenticate via Team section in VSCode
Configure PowerShell Profile
code $profile.CurrentUserAllHosts
Add this custom prompt function:
function prompt {
$curUser = (Get-ChildItem Env:\USERNAME).Value
$curComp = (Get-ChildItem Env:\COMPUTERNAME).Value
Write-Host -NoNewLine $curUser -ForegroundColor Cyan
Write-Host -NoNewLine " @ " -ForegroundColor Magenta
Write-Host -NoNewLine $(Get-Location) -ForegroundColor Yellow
Write-Host -NoNewLine "[" -ForegroundColor Yellow
Write-Host -NoNewLine ("{0:HH}:{0:mm}:{0:ss}" -f (Get-Date)) -ForegroundColor White
Write-Host -NoNewLine "]" -ForegroundColor Yellow
Write-Host -NoNewLine ">" -ForegroundColor Red
$host.UI.RawUI.WindowTitle = "PowerShell -- $curUser @ $curComp "
Write-VcsStatus
return " "
}
After reopening VSCode, the terminal will display colorful Git status information with the custom prompt.