Initialize-PC.ps1
<#PSScriptInfo .VERSION 1.3 .GUID c7e4c2a6-c3a3-45af-b82a-01d0a2ca28c1 .AUTHOR Dave Farinelli .LICENSEURI https://www.gnu.org/licenses/gpl-3.0.en.html .PROJECTURI https://github.com/dfar-io/initialize-pc #> <# .DESCRIPTION Run this script to set up a new Windows PC. This script is safe to run multiple times to allow for reconfiguration. #> #Requires -RunAsAdministrator Param( [switch] $SkipPrompts ) function Disable-StartMenuIcons { Write-Host 'Disabling Cortana...' $path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" IF (!(Test-Path -Path $path)) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows" -Name "Windows Search" } Set-ItemProperty -Path $path -Name "AllowCortana" -Value 0 Write-Host 'Disabling Search Button...' $path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" IF (!(Test-Path -Path $path)) { New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion" -Name "Search" } Set-ItemProperty -Path $path -Name "SearchboxTaskbarMode" -Value 0 Write-Host 'Disabling Task View Button...' $path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" IF (!(Test-Path -Path $path)) { New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "Advanced" } Set-ItemProperty -Path $path -Name "ShowTaskViewButton" -Value 0 Write-Host 'Disabling People Button...' $path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" IF (!(Test-Path -Path $path)) { New-Item -Path "HKCU:\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "People" } Set-ItemProperty -Path $path -Name "PeopleBand" -Value 0 #Restart Explorer to change it immediately Stop-Process -name explorer } function Install-Chocolatey { try { choco -v | Out-Null Write-Host 'Chocolatey already installed.' return } catch { Write-Host 'Installing Chocolatey...' Set-ExecutionPolicy Bypass -Scope Process -Force; ` Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) } } function Install-SoftwareWithChocolatey { Write-Host 'Installing Software with Chocolatey...' choco install -y ` greenshot ` googlechrome ` divvy ` 7zip ` ccleaner ` dropbox ` filezilla ` git ` nodejs ` libreoffice-fresh ` vscode ` rescuetime ` bitnami-xampp ` mysql.workbench ` postman ` qbittorrent ` sql-server-management-studio ` teamviewer ` visualstudio2017community ` azure-cli ` franz ` intellijidea-community } function Install-AdditionalSoftware { if (IsSoftwareAlreadyInstalled("OpenVPN Connect")) { Write-Host "OpenVPN Connect already installed." return; } Write-Host 'Installing OpenVPN Connect...' Invoke-WebRequest ` -Uri "https://swupdate.openvpn.net/as/clients/openvpn-connect-2.7.1.101_signed.msi" ` -OutFile "install.msi" Start-Process install.msi -Wait Remove-Item install.msi Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux WaitForPrompt("Install WSL") } function IsSoftwareAlreadyInstalled($name) { $x86 = ((Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall") | Where-Object { $_.GetValue( "DisplayName" ) -like "*$name*" } ).Length -gt 0; $x64 = ((Get-ChildItem "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") | Where-Object { $_.GetValue( "DisplayName" ) -like "*$name*" } ).Length -gt 0; return $x86 -or $x64; } function Update-Windows { if ($SkipPrompts) { Write-Host "Skipping updating Windows." return } WaitForPrompt("Update Windows") } function Remove-Clutter { Write-Host "Deleting Windows Appx packages..." DeleteAppxPackage("windowsalarms") DeleteAppxPackage("getstarted") DeleteAppxPackage("zunemusic") DeleteAppxPackage("windowsapps") DeleteAppxPackage("solitarecollection") DeleteAppxPackage("bingnews") DeleteAppxPackage("onenote") DeleteAppxPackage("windowsphone") DeleteAppxPackage("weather") DeleteAppxPackage("DellInc.DellSupportAssistforPCs") DeleteAppxPackage("DellInc.DellDigitalDelivery") DeleteAppxPackage("DellInc.DellCommandUpdate") DeleteAppxPackage("WindowsFeedbackHub") DeleteAppxPackage("Microsoft.Office.Desktop") DeleteAppxPackage("ScreenSketch") DeleteAppxPackage("StickyNotes") DeleteAppxPackage("YourPhone") DeleteAppxPackage("GetHelp") DeleteAppxPackage("MobilePlans") DeleteAppxPackage("MixedReality") DeleteAppxPackage("LinkedIn") DeleteAppxPackage("Microsoft3DViewer") DeleteAppxPackage("WindowsMaps") DeleteAppxPackage("Microsoft.Messaging") Write-Host "Uninstalling OneDrive..." taskkill /f /im OneDrive.exe | Out-Null C:\WINDOWS\SysWOW64\OneDriveSetup.exe /uninstall } function UninstallApplication($name) { $app = Get-CimInstance -Class Win32_Product ` -Filter "Name = '$name'" if ($null -eq $app) { Write-Host "$name not found, no need to uninstall." return } else { $app.Uninstall() } } function DeleteAppxPackage($packageName) { Write-Host "Removing $packageName appx package." Get-AppxPackage *$packageName* | Remove-AppxPackage } function Import-StartMenu { if ($SkipPrompts) { Write-Host "Skipping importing Start Menu." return; } WaitForPrompt("Clean up the start menu of all tiles") WaitForPrompt("Unpin all items") } function WaitForPrompt($prompt) { do { $value = Read-Host "$prompt ('y' to continue)" } while ($value -notmatch 'y') } function Initialize-Software { if ($SkipPrompts) { Write-Host "Skipping configuration of software." return; } WaitForPrompt("OpenVPN - Add all VPN servers") WaitForPrompt("Mail - add accounts, create linked inbox, turn off email notifications, signature, calendar on Monday") WaitForPrompt("Chrome - sign in") WaitForPrompt("Divvy - register, start at Login, hide from tray, set shortcut") WaitForPrompt("Dropbox - sign in, change to simple directory") WaitForPrompt("VSCode - install FiraCode") WaitForPrompt("VSCode - Perform Settings Sync (Shift-Alt-D)") WaitForPrompt("Greenshot - Increase icon size to 32, set output, remove magnifier") WaitForPrompt("PowerShell - Increase font size, use Fira Code") WaitForPrompt("Franz - Login") } function Set-TimeZone { Write-Host "Setting Time Zone..." tzutil /s "Eastern Standard Time" } function Set-PowershellProfile { Write-Host "Setting PowerShell profile..." New-Item -Path $Profile -Type File -Force | Out-Null Write-Output "Set-Location C:/" | Out-File $Profile } function Initialize-Git { Write-Host "Configuring git..." git config --global user.name "Dave Farinelli" git config --global user.email "d@dfar.io" } function Remove-DesktopIcons { Write-Host 'Deleting desktop icons...' Remove-Item C:\Users\*\Desktop\*lnk -Force } ################################################################################ Set-TimeZone Disable-StartMenuIcons Remove-Clutter Import-StartMenu Update-Windows Install-Chocolatey Install-SoftwareWithChocolatey Install-AdditionalSoftware Initialize-Software Update-Windows Set-PowershellProfile Initialize-Git Remove-DesktopIcons |