Repository navigation
Expand file tree
/
Copy pathbootstrap.ps1
More file actions
54 lines (44 loc) · 2.02 KB
/
Copy pathbootstrap.ps1
File metadata and controls
54 lines (44 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<#
.SYNOPSIS
Bootstraps the PowerShell dotfiles from the brootware/ansible-machine repository.
.DESCRIPTION
This script downloads and installs the PowerShell profile and configuration files
to the user's PowerShell documents directory. It ensures the necessary directory
structure exists and then copies the files from the repository.
.EXAMPLE
iex (irm 'https://raw.githubusercontent.com/brootware/ansible-machine/main/bootstrap.ps1')
This command downloads and executes the script from GitHub.
#>
# --- Configuration ---
$RepoOwner = "brootware"
$RepoName = "ansible-machine"
$Branch = "main"
$BaseUrl = "https://raw.githubusercontent.com/$RepoOwner/$RepoName/$Branch"
$ProfileSourceUrl = "$BaseUrl/roles/base/files/windows/Microsoft.Powershell_profile.ps1"
$ModularConfigBaseUrl = "$BaseUrl/roles/base/files/windows"
$DocumentsPath = [Environment]::GetFolderPath('MyDocuments')
$PSConfigPath = Join-Path -Path $DocumentsPath -ChildPath "WindowsPowerShell\config"
$PSProfilePath = Join-Path -Path $DocumentsPath -ChildPath "WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
# --- Installation ---
Write-Host "Ensuring PowerShell config directory exists at $PSConfigPath..."
if (-not (Test-Path -Path $PSConfigPath)) {
New-Item -Path $PSConfigPath -ItemType Directory -Force | Out-Null
}
Write-Host "Installing main PowerShell profile..."
Invoke-RestMethod -Uri $ProfileSourceUrl -OutFile $PSProfilePath
Write-Host "Installing modular PowerShell configuration..."
# Define the list of modular config files to download.
# This avoids hitting the GitHub API and its rate limits.
$ModularConfigFiles = @(
"aliases.ps1",
"functions.ps1"
"env.ps1"
"prompt.ps1"
)
foreach ($fileName in $ModularConfigFiles) {
$sourceUrl = "$ModularConfigBaseUrl/$fileName"
$destinationPath = Join-Path -Path $PSConfigPath -ChildPath $fileName
Write-Host "Downloading $fileName..."
Invoke-RestMethod -Uri $sourceUrl -OutFile $destinationPath
}
Write-Host "Bootstrap complete! Please restart your PowerShell session."