|
# Developer Workstation Setup For Windows |
|
# Required run in Powershell 7 |
|
# Run all commands or this script in an elevated powershell command prompt |
|
# Script has not been tested to run all at once, but run each install individually. |
|
|
|
#region Install Winget |
|
# get latest download url |
|
$URL = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" |
|
$URL = (Invoke-WebRequest -Uri $URL).Content | ConvertFrom-Json | |
|
Select-Object -ExpandProperty "assets" | |
|
Where-Object "browser_download_url" -Match '.msixbundle' | |
|
Select-Object -ExpandProperty "browser_download_url" |
|
# download |
|
Invoke-WebRequest -Uri $URL -OutFile "Setup.msix" -UseBasicParsing |
|
# install |
|
Add-AppxPackage -Path "Setup.msix" |
|
# delete file |
|
Remove-Item "Setup.msix" |
|
|
|
winget --version |
|
|
|
# Fix winget sources. |
|
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix |
|
#endregion |
|
|
|
# Install Powershell 7 if not in Company Portal |
|
winget install --id Microsoft.PowerShell |
|
|
|
# Install Chocolatey |
|
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) |
|
|
|
# Install Go Lang |
|
choco install golang |
|
|
|
#region Install tenv for terraform https://github.com/tofuutils/tenv |
|
go install github.com/sigstore/cosign/v2/cmd/cosign@latest |
|
choco install tenv |
|
|
|
# Run in regular |
|
tenv completion powershell | Out-String | Invoke-Expression |
|
|
|
# run in git bash |
|
tenv completion bash > ~/.tenv.completion.bash |
|
echo "source \$HOME/.tenv.completion.bash" >> ~/.profile |
|
#endregion |
|
|
|
# Install terraformdocs https://github.com/terraform-docs/terraform-docs |
|
choco install terraform-docs |
|
|
|
# Install Dotnet |
|
winget install Microsoft.DotNet.SDK.9 |
|
dotnet --list-sdks |
|
|
|
# Install Azure CLI |
|
winget install --exact --id Microsoft.AzureCLI |
|
|
|
# Install Node |
|
choco install nodejs.install |
|
node -v |
|
npm -v |
|
|
|
# Setup Nodejs Options in .profile in git bash or wsl |
|
# Setup Node.js Options in PowerShell |
|
$profilePath = "$HOME\.profile" |
|
if (-not (Test-Path $profilePath)) { |
|
New-Item -ItemType File -Path $profilePath -Force | Out-Null |
|
} |
|
|
|
$nodeOptionsLine = 'export NODE_OPTIONS=--use-openssl-ca' |
|
$profileContent = Get-Content -Path $profilePath -ErrorAction SilentlyContinue |
|
|
|
if ($profileContent -notcontains $nodeOptionsLine) { |
|
Add-Content -Path $profilePath -Value $nodeOptionsLine -Append |
|
Write-Host "NODE_OPTIONS added to .profile" |
|
} else { |
|
Write-Host "NODE_OPTIONS is already in .profile" |
|
} |
|
|
|
# Source the profile (equivalent to `. ~/.profile` in Bash) |
|
if (Test-Path $profilePath) { |
|
. $profilePath |
|
} |
|
|
|
# Install Docker |
|
# Download and install docker desktop from https://www.docker.com/products/docker-desktop/ |
|
# Enable WSL2 first by following setup-wsl.md |
|
|
|
# Install VSCode |
|
winget install Microsoft.VisualStudioCode |
|
|
|
# Install Postman |
|
choco install postman |
|
|
|
# Install K6 |
|
winget install k6 --source winget |
|
k6 --version |
|
|
|
# Install kubectl |
|
winget install -e --id Kubernetes.kubectl |
|
kubectl version --client |
|
|
|
# Run in Git Bash |
|
command_in_profile=$(cat ~/.profile | grep "kb='kubectl'") |
|
if [[ $command_in_profile == "" ]]; then |
|
echo "alias kb='kubectl'" >>~/.profile |
|
fi |
|
|
|
winget install --id=Microsoft.Azure.Kubelogin -e |
|
# Or install from Azure cli |
|
az aks install-cli |
|
|
|
# Helm |
|
winget install Helm.Helm |
|
|
|
# Yaml FMT |
|
go install github.com/google/yamlfmt/cmd/yamlfmt@latest |
|
|
|
# Install Active Directory Users and Computers |
|
# Open Elevated Command Prompt |
|
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 |
|
Install-WindowsFeature RSAT-AD-PowerShell |
|
|
|
# Setting up NPM and Nuget Github Packages for im-orgs |
|
# Run the shell version in wsl |
|
./github-packages-local-setup.ps1 |
|
|
|
# Install mktp-local-gateway ca cert as trusted certificate |
|
# Run this in an regular user powershell command prompt |
|
Write-Host "Copy raw url from your browser by navigating to github.com to ca cert file." |
|
$certPath = "./ca.crt" |
|
$certUrl = Read-Host -Prompt "Add Raw URL for https://github.com/im-enrollment/mktp-web-local-gateway/blob/main/src/Mktp.Web.LocalGateway/certs/ca.crt" |
|
Invoke-WebRequest -Uri $certUrl -OutFile $certPath |
|
|
|
$certImportParams = @{ |
|
FilePath = $certPath |
|
CertStoreLocation = 'Cert:\CurrentUser\Root' |
|
} |
|
Import-Certificate @certImportParams |
|
Remove-Item $certPath |
|
|
|
# Setup SSH Agent Run in Git Bash |
|
$sshAgent = @' |
|
command_in_profile=$(cat ~/.profile | grep '.ssh/agent.env') |
|
if [[ $command_in_profile == "" ]]; then |
|
ssh_agent_commands=$( |
|
cat <<EOF |
|
env=~/.ssh/agent.env |
|
export SSHAGENTARGS="-t 1h" |
|
agent_load_env() { test -f "$env" && . "$env" >|/dev/null; } |
|
agent_start() { |
|
( |
|
umask 077 |
|
ssh-agent >|"$env" |
|
) |
|
. "$env" >|/dev/null |
|
} |
|
agent_load_env |
|
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running |
|
agent_run_state=$( |
|
ssh-add -l >|/dev/null 2>&1 |
|
echo $? |
|
) |
|
if [ $agent_run_state = 2 ]; then |
|
agent_start |
|
ssh-add ~/.ssh/id_ed25519 |
|
elif [ $agent_run_state = 1 ]; then |
|
ssh-add ~/.ssh/id_ed25519 |
|
fi |
|
unset env |
|
EOF |
|
) |
|
echo "$ssh_agent_commands" >>~/.profile |
|
else |
|
echo "SSH Agent commands are already in .profile" |
|
fi |
|
'@ |
|
Write-Output "$sshAgent" | Out-File -FilePath ~/.profile -Append -Encoding utf8 |