Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for setting up my windows install. Run setup-windows.ps1
{
"Name": "altonaut",
"Author": "Andrew Montgomery",
"Colors": {
"Foreground": "#FFFAF4",
"Background": "#0E1019",
"Cursor": "#FFFFFF",
"CursorAccent": "#FF0018",
"Selection": "rgba(0, 42, 59, 0.30078125)",
"Black": "#000000",
"Red": "#FF0000",
"Green": "#8CE10B",
"Yellow": "#FFB900",
"Blue": "#008DF8",
"Magenta": "#6D43A6",
"Cyan": "#00D8EB",
"White": "#FFFFFF",
"BrightBlack": "#444444",
"BrightRed": "#FF2740",
"BrightGreen": "#ABE15B",
"BrightYellow": "#FFD242",
"BrightBlue": "#0092FF",
"BrightMagenta": "#9A5FEB",
"BrightCyan": "#67FFF0",
"BrightWhite": "#FFFFFF"
}
}
# Setup useful variables
$USERID = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
$USER = $env:UserName
$DOMAIN = $env:UserDomain
# Enable windows dev features
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
Enable-WindowsOptionalFeature -FeatureName Microsoft-Windows-Subsystem-Linux -Online -All -LimitAccess -NoRestart
# Install Scoop
Set-ExecutionPolicy RemoteSigned -scope CurrentUser -Force; iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
# Setup scoop buckets
scoop install git # needed to be able to add buckets
scoop bucket add nerd-fonts
scoop bucket add extras
scoop bucket add Ash258 'https://github.com/Ash258/scoop-Ash258.git'
scoop bucket add darkliquid 'https://github.com/darkliquid/bucket.git'
# Install scoop packages
scoop install vcredist2017
scoop uninstall vcredist2017
scoop install DirectX
scoop uninstall DirectX
scoop install 7zip
scoop install altdrag
scoop install audioswitcher
scoop install Chrome
scoop install discord
scoop install docker
scoop install EpicGamesLauncher
scoop install everything
scoop install firacode-nf
scoop install firamono-nf
scoop install innounp
scoop install keypirinha
scoop install lxrunoffline
scoop install notable
scoop install steam
scoop install sudo
scoop install vlc
scoop install vscode
reg import $HOME\scoop\apps\vscode\current\vscode-install-context.reg
scoop install linuxreader
scoop install desktopinfo
scoop install ssh-agent-wsl
scoop install pshazz
scoop install quicklook
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install chocolatey packages
choco install -y divvy
choco install -y origin
choco install -y zoom
choco install -y GPMDP
choco install -y dropbox
choco install -y fluent-terminal --pre
choco install -y virtualbox
# SSH setup
Set-Service -StartupType Automatic ssh-agent
Start-Service ssh-agent
# Windows 10 Debloater
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Sycnex/Windows10Debloater/master/Windows10SysPrepDebloater.ps1')); iex 'Start-Debloat Remove-Keys Protect-Privacy'
# pshazz config
New-Item $HOME\.config\pshazz\themes -ItemType Directory -Force
@'
{
"plugins": [ "git", "z", "aliases" ],
"prompt": [
[ "black", "red", "$(&{If($isadmin) {${rightarrow} + ' '}})" ],
[ "white", "red", "$(&{If($isadmin) {${user} + '@' + ${hostname} + ' '}})" ],
[ "white", "black", "$(&{If(!$isadmin) {${user} + '@' + ${hostname} + ' '}})" ],
[ "red", "darkblue", "$(&{If($isadmin) {${rightarrow}}})" ],
[ "black", "darkblue", "$(&{If(!$isadmin) {${rightarrow}}})" ],
[ "white", "darkblue", " $path " ],
[ "darkblue", "black", "$(&{If(!$git_branch.Length) {${rightarrow}}})" ],
[ "darkblue", "darkyellow", "$(&{If($git_branch.Length) {${rightarrow}}})" ],
[ "white", "darkyellow", "$(&{If($git_branch.Length) {' ' + $([text.encoding]::utf8.getstring((238,130,160)))}})" ],
[ "white", "darkyellow", "$(&{If($git_branch.Length) {' ' + $git_branch}})" ],
[ "white", "darkyellow", "$(&{If($git_branch.Length) {' ' + $git_local_state}})" ],
[ "white", "darkyellow", "$(&{If($git_branch.Length) {$git_remote_state}})" ],
[ "darkyellow", "darkyellow", "$(&{If($git_branch.Length) {${rightarrow}}})" ],
[ "darkyellow", "black", "$(&{If($git_branch.Length) {${rightarrow}}})" ]
],
"git": {
"prompt_unstaged": "*",
"prompt_staged": "+",
"prompt_stash": "$",
"prompt_untracked": "%",
"prompt_remote_push": ">",
"prompt_remote_pull": "<",
"prompt_remote_same": "="
},
"hg": {
"prompt_dirty": "*"
}
}
'@ | Out-File $HOME\.config\pshazz\themes\darkl.json
@'
{
"editor": "code",
"theme": "darkl"
}
'@ | Out-File $HOME\.config\pshazz\config.json
# Powershell profile
New-Item $HOME\Documents\WindowsPowerShell -ItemType Directory -Force
@'
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal $identity
$isadmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
Remove-Variable identity
Remove-Variable principal
try { $null = gcm pshazz -ea stop; pshazz init 'default' } catch { }
function su {
&$HOME\scoop\shims\sudo.cmd powershell -NoLogo
}
'@ | Out-File $HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# altdrag config
@'
[General]
AutoFocus=0
Aero=1
InactiveScroll=0
AutoSnap=0
MDI=0
Language=en-US
[Input]
LMB=Move
MMB=Resize
RMB=Resize
MB4=Nothing
MB5=Nothing
Scroll=Volume
LowerWithMMB=0
Hotkeys=A4 A5
[Blacklist]
ProcessBlacklist=
Blacklist=*|MultitaskingViewFrame,Volume Control|Windows.UI.Core.CoreWindow,*|TaskSwitcherWnd,*|TaskSwitcherOverlayWnd,|#32770
Snaplist=*|BaseWindow_RootWnd,*|SkinWnd,*|ChatSkinWnd,*|SpotifyMainWindow,*|USurface_33202
[Advanced]
HookWindows=0
AutoRemaximize=1
FocusOnTyping=0
SnapThreshold=20
MultipleInstances=0
AlwaysElevate=0
[Performance]
Cursor=1
MoveRate=2
ResizeRate=5
[Update]
CheckOnStartup=1
Beta=0
'@ | Out-File $HOME\scoop\apps\altdrag\current\AltDrag.ini
# desktopinfo config
@'
[options]
# size and position
top=0
right=0
width=360
monitor-mode=0
monitor-num=2
# font
font-face=Arial
font-size=10
font-charset=1
font-rtl=0
ssfontsize=16
# logging
log=desktopinfo.log
log-level=error
# navigation buttons
nav=0
desktopinfo64=1
formcolor=000000
transparency=30
[text]
noresults=<n/a>
error=[error]
[pages]
1=Main Page
2=
3=
4=
5=
6=
7=
8=
9=
[items]
# padding
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,color:cccccc,style:iwb,text:jahraman
# page 1 date/time
DATETIME=active:1,interval:10,color:#42c8f4,display:%1[ddd] %2[1.0d] %3[mmm] %4[yyyy]\, %5[1.0a]:%6[2.0d] %5[2.0p]
# page 1 - cpu
CPUTEMP=active:1,interval:10,display:%1C / %2C
CPU=active:1,interval:3,chart:line linear 100 1 00ff00 2 0000bb,threshold1:1 80 0000ff,threshold2:2 40 0000ff,display:Tot: %1[2.0f]%\, Krnl: %2[2.0f]%\, Queue: %3
# page 1 - top processes
COMMENT=active:1,color:cccccc,style:iwb,text:Top Processes
TOPPROCESSCPU=active:1,interval:5,color:22dd99,text:Cpu,display:%1 (pid:%2) %3%
TOPPROCESSMEM=active:1,interval:5,counter:pu,text:Memory,display:%1 (pid:%2) %3[1.1b]B
TOPPROCESSPF=active:1,interval:5,text:Page Faults,display:%1 (pid:%2) %3 faults
# page 1 - memory
COMMENT=active:1,color:cccccc,style:iwb,text:Memory
PHYSICALRAM=active:1,interval:30,color:ffd0e0,threshold1:3 80 0000FF,display:%1[3.1b]B / %2[3.1b]B (%3% used)
PAGEFAULTS=active:1,interval:5,threshold1:2 200 0000ff,display:Total: %1\, Hard: %2
# page 1 - network
COMMENT=active:1,color:cccccc,style:iwb,text:Network
NETWORKINTERFACES=active:1,interval:30,color:22dddd,operstatus:1,iftype:6 71,display:%2: %8 / %10| gw:%17
WMI=active:0,interval:3,chart:line log 22 1 00ff00 2 bb00bb,threshold1:1 1500000 0000ff,threshold2:2 500000 ff0000,text:Wifi Traffic,namespace:root\cimv2,query:Win32_PerfFormattedData_Tcpip_NetworkInterface where Name like "%Wireless%",display:R: %BytesReceivedPersec%[3.1k]KiBps\, S: %BytesSentPersec%[3.1k]KiBps\, B: %CurrentBandwidth%[1.0B]B
WMI=active:1,interval:3,chart:line log 22 1 00ff00 2 bb00bb,threshold1:1 1500000 0000ff,threshold2:2 500000 ff0000,text:Ethernet Traffic,namespace:root\cimv2,query:Win32_PerfFormattedData_Tcpip_NetworkInterface where Name like "%Ethernet%",display:R: %BytesReceivedPersec%[3.1k]KiBps\, S: %BytesSentPersec%[3.1k]KiBps\, B: %CurrentBandwidth%[1.0B]B
# page 1 - disks
COMMENT=active:1,color:cccccc,style:iwb,text:Fixed Disks
FIXEDDISK=active:1,interval:300,color:ffbb77,chart:none linear 100 7 60,threshold1:7 90 0000FF,count:8,display:%1: %3[1.0B]B/%5[1.0B]B (%7% used),filter:
DISKIO=active:1,interval:5,chart:none log 23 1 00ffff 2 ffff00,threshold1:1 4000000 0000FF,threshold2:2 4000000 0055ff,display:r:%1[3.1b]B/s\, w:%2[3.1b]B/s\, q:%3
# page 1 - dates and times
COMMENT=active:1,color:cccccc,style:iwb,text:Dates / Times
DATETIME=active:1,interval:2,color:ffdd00,display:%1[ddd] %2[1.0d] %3[mmm] %4[yyyy]\, %5[1.0a]:%6[2.0d] %5[2.0p]
TIMEZONE=active:1,interval:3600
WMI=active:1,interval:3600,text:Daylight Savings,namespace:root\cimv2,query:CIM_ComputerSystem,display:Enabled: %EnableDaylightSavingsTime%[b:Yes:No]\, In Effect: %DaylightInEffect%[b:Yes:No]
USER=active:1,set:username,hidden:1
HOST=active:1,text:Host/User,display:%1/%username%
UPTIME=active:1,interval:60,display:%1 days %2 hrs %3 mins
# page 1 - windows configuration
COMMENT=active:1,color:cccccc,style:iwb,text:Windows Configuration
WMI=active:1,color:eeeeee,text:Windows,namespace:root\cimv2,query:Win32_OperatingSystem,display:%caption%|Architecture: %OSArchitecture%|Installed: %InstallDate_day% %InstallDate_month%[mmm] %Installdate_year% %installdate_utcoffset%|Boot Time: %LastBootupTime_day% %LastBootupTime_month%[mmm] %LastBootupTime_year% %LastBootupTime_hour%[1.0a]:%LastBootupTime_minute%[2.0d] %LastBootupTime_hour%[2.0p]|Win Dir: %WindowsDirectory%|Sys Dir: %SystemDirectory%
OSBUILD=active:1
# page 1 - hardware
COMMENT=active:1,color:cccccc,style:iwb,text:Hardware
CPUTYPE=active:1
WMI=active:1,text:CPU Info,namespace:root\cimv2,query:Win32_Processor,display:Cores:%NumberOfCores%\, Sp:%MaxClockSpeed%MHz\, Cur:%CurrentClockSpeed%MHz
WMI=active:1,text:Motherboard,namespace:root\cimv2,query:Win32_Baseboard,display:%Manufacturer% %Product%
WMI=active:1,text:Bios,namespace:root\cimv2,query:Win32_Bios,display:%Manufacturer% %Version%
WMI=active:1,text:Audio Controller,namespace:root\cimv2,query:Win32_SoundDevice,display:%Caption%
WMI=active:1,text:Printers,namespace:root\cimv2,query:Win32_Printer,maxrows:1,display:%rowcount% printers
# padding
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,text:
COMMENT=active:1,text:
'@ | Out-File $HOME\scoop\persist\desktopinfo\desktopinfo.ini
# keypirinha config
New-Item $HOME\scoop\apps\keypirinha\current\portable\Profile\User -ItemType Directory -Force
@'
[app]
launch_at_startup = yes
hotkey_run = Alt+Space
[gui]
always_on_top = yes
hide_on_focus_lost = delayed
show_on_taskbar = no
theme = MiniLayout, MonokaiColors
'@ | Out-File $HOME\scoop\apps\keypirinha\current\portable\Profile\User\Keypirinha.ini
@'
[main]
installed_packages =
keypirinha-winsys
Keypirinha-PackageControl
Steam
Keypirinha-WindowsApps
Keypirinha-Plugin-Kill
'@ | Out-File $HOME\scoop\apps\keypirinha\current\portable\Profile\User\PackageControl.ini
# keypirinha plugins
New-Item $HOME\scoop\apps\keypirinha\current\portable\Profile\InstalledPackages -ItemType Directory -Force
Invoke-WebRequest -Uri "https://github.com/ueffel/Keypirinha-WindowsApps/releases/download/0.5/WindowsApps.keypirinha-package" -OutFile $HOME\scoop\apps\keypirinha\current\portable\Profile\InstalledPackages\WindowsApps.keypirinha-package
Invoke-WebRequest -Uri "https://github.com/ueffel/Keypirinha-PackageControl/releases/download/1.0.0/PackageControl.keypirinha-package" -OutFile $HOME\scoop\apps\keypirinha\current\portable\Profile\InstalledPackages\PackageControl.keypirinha-package
Invoke-WebRequest -Uri "https://github.com/ueffel/Keypirinha-Plugin-Kill/releases/download/2.6/Kill.keypirinha-package" -OutFile $HOME\scoop\apps\keypirinha\current\portable\Profile\InstalledPackages\Kill.keypirinha-package
Invoke-WebRequest -Uri "https://github.com/EhsanKia/keypirinha-plugins/raw/master/keypirinha-steam/build/Steam.keypirinha-package" -OutFile $HOME\scoop\apps\keypirinha\current\portable\Profile\InstalledPackages\Steam.keypirinha-package
Invoke-WebRequest -Uri "https://github.com/kvnxiao/keypirinha-winsys/releases/download/1.0.0/WinSys.keypirinha-package" -OutFile $HOME\scoop\apps\keypirinha\current\portable\Profile\InstalledPackages\WinSys.keypirinha-package
# Launch Divvy as admin so it can manage admin-privileged windows
$task = @"
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2019-03-24T01:10:39.3853493</Date>
<Author>$DOMAIN\$USER</Author>
<URI>\Divvy</URI>
</RegistrationInfo>
<Principals>
<Principal id="Author">
<UserId>$USERID</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<StartWhenAvailable>true</StartWhenAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
</Settings>
<Triggers>
<LogonTrigger>
<UserId>$DOMAIN\$USER</UserId>
</LogonTrigger>
</Triggers>
<Actions Context="Author">
<Exec>
<Command>"$HOME\AppData\Local\Mizage LLC\Divvy\Divvy.exe"</Command>
</Exec>
</Actions>
</Task>
"@
Register-ScheduledTask -Xml $task -TaskName "Divvy"
$task = @"
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2019-03-26T22:43:24.2746466</Date>
<Author>$DOMAIN\$USER</Author>
<URI>\AltDrag</URI>
</RegistrationInfo>
<Principals>
<Principal id="Author">
<UserId>$USERID</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<StartWhenAvailable>true</StartWhenAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
</Settings>
<Triggers>
<LogonTrigger>
<UserId>$DOMAIN\$USER</UserId>
</LogonTrigger>
</Triggers>
<Actions Context="Author">
<Exec>
<Command>$HOME\scoop\apps\altdrag\current\AltDrag.exe</Command>
</Exec>
</Actions>
</Task>
"@
Register-ScheduledTask -Xml $task -TaskName "AltDrag"
$task = @"
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2019-03-24T11:42:37.2180416</Date>
<Author>$DOMAIN\$USER</Author>
<URI>\Desktop Info</URI>
</RegistrationInfo>
<Principals>
<Principal id="Author">
<UserId>$USERID</UserId>
<LogonType>InteractiveToken</LogonType>
</Principal>
</Principals>
<Settings>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<StartWhenAvailable>true</StartWhenAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
</Settings>
<Triggers>
<LogonTrigger>
<UserId>$DOMAIN\$USER</UserId>
</LogonTrigger>
</Triggers>
<Actions Context="Author">
<Exec>
<Command>$HOME\scoop\apps\desktopinfo\current\DesktopInfo.exe</Command>
</Exec>
</Actions>
</Task>
"@
Register-ScheduledTask -Xml $task -TaskName "Desktop Info"
# Setup useful variables
$USERID = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
$USER = $env:UserName
$DOMAIN = $env:UserDomain
# Setup WSL
Invoke-WebRequest -Uri "https://partner-images.canonical.com/core/bionic/current/ubuntu-bionic-core-cloudimg-amd64-root.tar.gz" -OutFile $HOME\Downloads\ubuntu-bionic-core-cloudimg-amd64-root.tar.gz
lxrunoffline i -n "UbuntuBionic" -d $HOME\UbuntuBionic -f $HOME\Downloads\ubuntu-bionic-core-cloudimg-amd64-root.tar.gz
lxrunoffline r -n "UbuntuBionic" -c "echo '[automount]' > /etc/wsl.conf"
lxrunoffline r -n "UbuntuBionic" -c "echo 'options = `"metadata`"' >> /etc/wsl.conf"
lxrunoffline r -n "UbuntuBionic" -c "apt update"
lxrunoffline r -n "UbuntuBionic" -c "apt upgrade"
lxrunoffline r -n "UbuntuBionic" -c "apt install -y sudo git-core"
Get-Service LxssManager | Restart-Service
lxrunoffline r -n "UbuntuBionic" -c "useradd -m -G sudo -d /mnt/c/Users/$USER $USER"
lxrunoffline r -n "UbuntuBionic" -c "cp /etc/skel/.* /mnt/c/Users/$USER/"
lxrunoffline r -n "UbuntuBionic" -c "chown $USER:$USER /mnt/c/Users/$USER/.profile"
lxrunoffline r -n "UbuntuBionic" -c "chown $USER:$USER /mnt/c/Users/$USER/.bashrc"
lxrunoffline r -n "UbuntuBionic" -c "chown $USER:$USER /mnt/c/Users/$USER/.bash_logout"
# This is temporary - passwordless sudo is bad, m'kay?
lxrunoffline r -n "UbuntuBionic" -c "echo '$USER ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
# Make our new non-privileged user the default
lxrunoffline su -n "UbuntuBionic" -v 1000
# Windows defender tweaks
Add-MpPreference -ExclusionPath $HOME\UbuntuBionic\rootfs
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin", "\usr\local\bin", "\home\linuxbrew\.linuxbrew\bin", "\home\$USER\.cargo\bin", "\home\$USER\go\bin", "\snap\bin")
$dirs | ForEach-Object {
$exclusion = "$HOME\UbuntuBionic\rootfs" + $_ + "\*"
Add-MpPreference -ExclusionProcess $exclusion
}
Set-MpPreference -EnableControlledFolderAccess Enabled
Add-MpPreference -ControlledFolderAccessAllowedApplications "C:\windows\system32\windowspowershell\v1.0\powershell.exe"
# Configure WSL environment
lxrunoffline r -n "UbuntuBionic" -c "bash -c 'cd && git clone https://github.com/darkliquid/dotfiles.git && bash ./dotfiles/setup.sh'"
# Remove nopasswd sudo support for our user
lxrunoffline r -n "UbuntuBionic" -c "bash -c `"sudo sed -i '/$USER/d' /etc/sudoers`""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.