
Yeah, I’ve made the switch over to VSCode. I pretty much live in GitHub now days. I find my current website annoying since I’ve been working in GitBook at 2Pint Software. Don’t get me wrong, I still use PowerShell ISE for some things, like running scripts and making MINOR changes, but anytime I need to do REAL powershell scripting development, I use VSCode with GIT integration.
So yes, I have like a million test machines I use, and VMs galore, so now my OSD process just runs a powershell step that installs GIT & VSCode from the cloud for me and does some basic settings
Basically I’ve added 4 steps into my task sequences. Note, this is a DeployR Task Sequence, but the code / idea works in ConfigMgr as well

Step Content
Apps – Install VSCode from Cloud = Run PowerShell Step
2PintLabs/DeployR/TSScripts/Functions/Install-VSCode.ps1 – For Function Version
This script will reach out to the URL “https://code.visualstudio.com/sha/download?build=stable&os=win32-x64”, download and run the silent install command.
# Define variables
$downloadUrl = "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64"
$installerPath = "$env:TEMP\VSCodeSetup.exe"
$logPath = "$env:TEMP\VSCodeInstall.log"
try {
# Attempt download with Start-BitsTransfer
Write-Host "Attempting to download VS Code installer using BITS..."
try {
Start-BitsTransfer -Source $downloadUrl -Destination $installerPath -ErrorAction Stop
}
catch {
Write-Host "BITS download failed, falling back to Invoke-WebRequest..." -ForegroundColor Yellow
Invoke-WebRequest -Uri $downloadUrl -OutFile $installerPath -ErrorAction Stop
}
# Install VS Code silently
Write-Host "Installing VS Code..."
Start-Process -FilePath $installerPath -ArgumentList "/VERYSILENT /NORESTART /MERGETASKS=!runcode /LOG=$logPath" -Wait -ErrorAction Stop
Write-Host "VS Code installed successfully."
}
catch {
Write-Host "Error occurred: $_" -ForegroundColor Red
}
Add PowerShell Extension to VSCode
This will add the PowerShell extension into VSCode for all users via “side loading shanaghans”
2PintLabs/DeployR/TSScripts/Functions/Install-VSCode.ps1 – For Function Version
# PowerShell script to install the PowerShell extension for VS Code system-wide
# Run as Administrator
# Define paths
$sharedExtensionsDir = "C:\Program Files\Microsoft VS Code\resources\app\extensions"
$tempExtensionsDir = "$env:USERPROFILE\.vscode\extensions"
$extensionId = "ms-vscode.powershell"
# Ensure the shared extensions directory exists
New-Item -ItemType Directory -Force -Path $sharedExtensionsDir -ErrorAction Stop | Out-Null
# Install the PowerShell extension to the current user's profile temporarily
Write-Host "Installing PowerShell extension ($extensionId) to temporary profile..."
Start-Process -FilePath "code" -ArgumentList "--install-extension $extensionId" -Wait -NoNewWindow
# Verify installation
if (Test-Path "$tempExtensionsDir\$extensionId*") {
Write-Host "Extension installed successfully to temporary profile."
# Copy the extension to the shared directory
Write-Host "Copying extension to shared directory: $sharedExtensionsDir"
Copy-Item -Path "$tempExtensionsDir\$extensionId*" -Destination $sharedExtensionsDir -Recurse -Force
# Set permissions to ensure all users can access
Write-Host "Setting permissions on shared extensions directory..."
icacls "$sharedExtensionsDir" /grant "Users:(RX)" /T | Out-Null
icacls "$sharedExtensionsDir" /grant "Administrators:(F)" /T | Out-Null
Write-Host "PowerShell extension successfully preloaded for all users."
} else {
Write-Error "Failed to install PowerShell extension to temporary profile."
exit 1
}
# Optional: Clean up temporary user extensions
Write-Host "Cleaning up temporary extensions..."
Remove-Item -Path "$tempExtensionsDir\$extensionId*" -Recurse -Force -ErrorAction SilentlyContinue
# Instruct users to launch VS Code with the shared extensions directory (if needed)
Write-Host "To use the shared extensions, launch VS Code with: code --extensions-dir '$sharedExtensionsDir'"
Write-Host "Setup complete. Test by launching VS Code as a new user."
App – Install Git from Cloud
This will get the latest version of GIT and install. I originally wrote this as an intune remediation script to ensure it was installed on all my lab machines, but also turned it into a standalone script.
2PintLabs/DeployR/TSScripts/Functions/Install-GIT.ps1
# Simple Git for Windows installer (64-bit, latest release)
# Ensure TLS 1.2 for GitHub API
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Get latest Git for Windows release info
$apiUrl = "https://api.github.com/repos/git-for-windows/git/releases/latest"
$release = Invoke-RestMethod -Uri $apiUrl -Method Get
# Find the 64-bit installer asset
$asset = $release.assets | Where-Object { $_.name -like "*64-bit.exe" } | Select-Object -First 1
$downloadUrl = $asset.browser_download_url
$packageName = $asset.name
# Download to temp folder
$tempDir = [System.IO.Path]::GetTempPath()
$packagePath = Join-Path $tempDir $packageName
Write-Host "Downloading Git installer..."
try {
Start-BitsTransfer -Source $downloadUrl -Destination $packagePath -ErrorAction Stop
} catch {
Write-Warning "Start-BitsTransfer failed, falling back to Invoke-WebRequest."
Invoke-WebRequest -Uri $downloadUrl -OutFile $packagePath
}
Write-Host "Installing Git silently..."
Start-Process $packagePath -ArgumentList "/VERYSILENT" -Wait
Write-Host "Git installation complete."
Set GIT User & Email
This is a very simple step, because I was tired of doing this manually or forgetting to do it manually.
# Define Git username and email
$gitUser = "gwblok"
$gitEmail = "myemail@garytown.com"
# Log start of configuration
Write-Host "Starting Git configuration..." -ForegroundColor Green
# Set Git global username
Write-Host "Setting Git username to: $gitUser"
git config --global user.name "$gitUser"
# Verify username was set
$configuredUser = git config --global user.name
Write-Host "Current Git username: $configuredUser" -ForegroundColor Cyan
# Set Git global email
Write-Host "Setting Git email to: $gitEmail"
git config --global user.email "$gitEmail"
# Verify email was set
$configuredEmail = git config --global user.email
Write-Host "Current Git email: $configuredEmail" -ForegroundColor Cyan
# Log completion
Write-Host "Git configuration completed successfully!" -ForegroundColor Green
Now, after OSD all of my machines have this software! I also leverage nearly identical scripts to have Intune catch anything that slips through the cracks.
Posted on GARYTOWN.COM