|
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } |
|
|
|
function Check-Command($cmdname) { |
|
return [bool](Get-Command -Name $cmdname -ErrorAction SilentlyContinue) |
|
} |
|
|
|
function Activate-Windows { |
|
@echo off |
|
if %errorlevel% EQU 0 (cscript //nologo slmgr.vbs /ipk NPPR9-FWDCX-D2C8J-H872K-2YT43 >nul||cscript //nologo slmgr.vbs /ipk DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4 >nul||cscript //nologo slmgr.vbs /ipk YYVX9-NTFWV-6MDM3-9PT4T-4M68B >nul||cscript //nologo slmgr.vbs /ipk 44RPN-FTY23-9VTTB-MP9BX-T84FV >nul||cscript //nologo slmgr.vbs /ipk WNMTR-4C88C-JK8YV-HQ7T2-76DF9 >nul||cscript //nologo slmgr.vbs /ipk 2F77B-TNFGY-69QQF-B8YKP-D69TJ >nul||cscript //nologo slmgr.vbs /ipk DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ >nul||cscript //nologo slmgr.vbs /ipk QFFDN-GRT3P-VKWWX-X7T3R-8B639 >nul||cscript //nologo slmgr.vbs /ipk M7XTQ-FN8P6-TTKYV-9D4CC-J462D >nul||cscript //nologo slmgr.vbs /ipk 92NFX-8DJQP-P6BBQ-THF9C-7CG2H >nul&goto skms) else wmic os | findstr /I "home" >nul |
|
if %errorlevel% EQU 0 (cscript //nologo slmgr.vbs /ipk TX9XD-98N7V-6WMQ6-BX7FG-H8Q99 >nul||cscript //nologo slmgr.vbs /ipk 3KHY7-WNT83-DGQKR-F7HPR-844BM >nul||cscript //nologo slmgr.vbs /ipk 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH >nul||cscript //nologo slmgr.vbs /ipk PVMJN-6DFY6-9CCP6-7BKTT-D3WVR >nul&goto skms) else wmic os | findstr /I "education" >nul |
|
if %errorlevel% EQU 0 (cscript //nologo slmgr.vbs /ipk NW6C2-QMPVW-D7KKK-3GKT6-VCFB2 >nul||cscript //nologo slmgr.vbs /ipk 2WH4N-8QGBV-H22JP-CT43Q-MDWWJ >nul&goto skms) else wmic os | findstr /I "11 pro" >nul |
|
if %errorlevel% EQU 0 (cscript //nologo slmgr.vbs /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX >nul||cscript //nologo slmgr.vbs /ipk MH37W-N47XK-V7XM9-C7227-GCQG9 >nul||cscript //nologo slmgr.vbs /ipk NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J >nul||cscript //nologo slmgr.vbs /ipk 9FNHH-K3HBT-3W4TD-6383H-6XYWF >nul||cscript //nologo slmgr.vbs /ipk 6TP4R-GNPTD-KYYHQ-7B7DP-J447Y >nul||cscript //nologo slmgr.vbs /ipk YVWGF-BXNMC-HTQYQ-CPQ99-66QFC >nul&goto skms) else (goto notsupported) |
|
:skms |
|
if %i% GTR 10 goto busy |
|
if %i% EQU 1 set KMS=s9.us.to |
|
if %i% EQU 2 set KMS=s8.uk.to |
|
if %i% EQU 3 set KMS=kms9.MSGuides.com |
|
if %i% GTR 3 goto ato |
|
cscript //nologo slmgr.vbs /skms %KMS%:1688 >nul |
|
:ato |
|
echo ============================================================================&echo.&echo.&cscript //nologo slmgr.vbs /ato | find /i "successfully" && (echo.&echo ============================================================================&echo.&echo #My official blog: MSGuides.com&echo.&echo #How it works: bit.ly/kms-server&echo.&echo #Please feel free to contact me at [email protected] if you have any questions or concerns.&echo.&echo #Please consider supporting this project: donate.msguides.com&echo #Your support is helping me keep my servers running 24/7!&echo.&echo ============================================================================&choice /n /c YN /m "Would you like to visit my blog [Y,N]?" & if errorlevel 2 exit) || (echo The connection to my KMS server failed! Trying to connect to another one... & echo Please wait... & echo. & echo. & set /a i+=1 & goto skms) |
|
explorer "http://MSGuides.com"&goto halt |
|
:notsupported |
|
echo ============================================================================&echo.&echo Sorry, your version is not supported.&echo.&goto halt |
|
:busy |
|
echo ============================================================================&echo.&echo Sorry, the server is busy and can't respond to your request. Please try again.&echo. |
|
:halt |
|
pause >nul |
|
} |
|
|
|
function AddToPath { |
|
param ( |
|
[string]$folder |
|
) |
|
|
|
Write-Host "Adding $folder to environment variables..." -ForegroundColor Yellow |
|
|
|
$currentEnv = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine).Trim(";"); |
|
$addedEnv = $currentEnv + ";$folder" |
|
$trimmedEnv = (($addedEnv.Split(';') | Select-Object -Unique) -join ";").Trim(";") |
|
[Environment]::SetEnvironmentVariable( |
|
"Path", |
|
$trimmedEnv, |
|
[EnvironmentVariableTarget]::Machine) |
|
|
|
#Write-Host "Reloading environment variables..." -ForegroundColor Green |
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") |
|
} |
|
|
|
function Remove-UWP { |
|
param ( |
|
[string]$name |
|
) |
|
|
|
Write-Host "Removing UWP $name..." -ForegroundColor Yellow |
|
Get-AppxPackage $name | Remove-AppxPackage |
|
Get-AppxPackage $name | Remove-AppxPackage -AllUsers |
|
} |
|
|
|
slmgr/ipk W269N-WFGWX-YVC9B-4J6C9-T83GX >nul |
|
Activate-Windows |
|
|
|
|
|
Write-Host "OS Info:" -ForegroundColor Green |
|
Get-CimInstance Win32_OperatingSystem | Format-List Name, Version, InstallDate, OSArchitecture |
|
(Get-ItemProperty HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0\).ProcessorNameString |
|
# ----------------------------------------------------------------------------- |
|
$computerName = Read-Host 'Enter New Computer Name' |
|
Write-Host "Renaming this computer to: " $computerName -ForegroundColor Yellow |
|
Rename-Computer -NewName $computerName |
|
# ----------------------------------------------------------------------------- |
|
Write-Host "" |
|
Write-Host "Disable Sleep on AC Power..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Powercfg /Change monitor-timeout-ac 60 |
|
Powercfg /Change standby-timeout-ac 0 |
|
# ----------------------------------------------------------------------------- |
|
Write-Host "" |
|
Write-Host "Add 'This PC' Desktop Icon..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
$thisPCIconRegPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" |
|
$thisPCRegValname = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" |
|
$item = Get-ItemProperty -Path $thisPCIconRegPath -Name $thisPCRegValname -ErrorAction SilentlyContinue |
|
if ($item) { |
|
Set-ItemProperty -Path $thisPCIconRegPath -name $thisPCRegValname -Value 0 |
|
} |
|
else { |
|
New-ItemProperty -Path $thisPCIconRegPath -Name $thisPCRegValname -Value 0 -PropertyType DWORD | Out-Null |
|
} |
|
|
|
# To list all appx packages: |
|
# Get-AppxPackage | Format-Table -Property Name,Version,PackageFullName |
|
Write-Host "Removing UWP Shit..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
$uwpRubbishApps = @( |
|
"Microsoft.Microsoft3DViewer" |
|
"Microsoft.ZuneMusic" |
|
"Microsoft.ZuneVideo" |
|
"*549981C3F5F10*" |
|
"Microsoft.WindowsSoundRecorder" |
|
"Microsoft.BingWeather" |
|
"Microsoft.BingNews" |
|
"king.com.CandyCrushSaga" |
|
"Microsoft.Messaging" |
|
"Microsoft.WindowsFeedbackHub" |
|
"Microsoft.MicrosoftOfficeHub" |
|
"Microsoft.MicrosoftSolitaireCollection" |
|
"4DF9E0F8.Netflix" |
|
"Microsoft.GetHelp" |
|
"Microsoft.People" |
|
"Microsoft.YourPhone" |
|
"MicrosoftTeams" |
|
"Microsoft.Getstarted" |
|
"Microsoft.Microsoft3DViewer" |
|
"Microsoft.WindowsMaps" |
|
"Microsoft.MixedReality.Portal" |
|
"Microsoft.SkypeApp") |
|
|
|
foreach ($uwp in $uwpRubbishApps) { |
|
Remove-UWP $uwp |
|
} |
|
# ----------------------------------------------------------------------------- |
|
|
|
# ----------------------------------------------------------------------------- |
|
Write-Host "" |
|
Write-Host "Installing IIS..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument -All |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionDynamic -All |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic -All |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets -All |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit -All |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45 -All |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ServerSideIncludes |
|
Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication |
|
# ----------------------------------------------------------------------------- |
|
Write-Host "" |
|
Write-Host "Enable Windows 11 Developer Mode..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" |
|
# ----------------------------------------------------------------------------- |
|
Write-Host "" |
|
|
|
if ($true) { |
|
Write-Host "Enable Remote Desktop..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\" -Name "fDenyTSConnections" -Value 0 |
|
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" -Name "UserAuthentication" -Value 1 |
|
Enable-NetFirewallRule -DisplayGroup "Remote Desktop" |
|
} |
|
|
|
|
|
if (Check-Command -cmdname 'choco') { |
|
Write-Host "Choco is already installed, skip installation." |
|
} |
|
else { |
|
Write-Host "" |
|
Write-Host "Installing Chocolate for Windows..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) |
|
} |
|
|
|
$installerName = Read-Host 'Which installer do you prefer, choco or winget?' |
|
|
|
Write-Host "" |
|
Write-Host "Installing Applications using $installerName..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
|
|
if ($installerName -contains 'choco') { |
|
$Apps = @( |
|
"7zip.install", |
|
"git", |
|
"vlc", |
|
"vscode", |
|
"sysinternals", |
|
"linqpad", |
|
"postman", |
|
"beyondcompare", |
|
"microsoft-teams.install", |
|
"github-desktop", |
|
"irfanview", |
|
"nodejs-lts", |
|
"azure-cli", |
|
"powershell-core", |
|
"obs-studio") |
|
|
|
foreach ($app in $Apps) { |
|
choco install $app -y |
|
} |
|
} |
|
else { |
|
$Apps = @( |
|
"Microsoft.WindowsTerminal", |
|
"Microsoft.PowerShell", |
|
"Git.Git", |
|
"Microsoft.VisualStudioCode", |
|
#"Notepad++.Notepad++", |
|
#"SublimeHQ.SublimeText.4", |
|
"Notion.Notion", |
|
"Google.Chrome", |
|
"Lexikos.AutoHotkey", |
|
#"Microsoft.VisualStudio.2019.Community", |
|
#"Microsoft.VisualStudio.2019.BuildTools", |
|
"Anaconda.Anaconda3", |
|
#"JetBrains.PyCharm.Professional", |
|
#"Docker.DockerDesktop", |
|
#"OpenJS.NodeJS", |
|
#"vim.vim", |
|
#"Mozilla.Firefox.DeveloperEdition", |
|
#"Microsoft.SQLServerManagementStudio", |
|
#"ImageMagick.ImageMagick", |
|
#"TopalaSoftwareSolutions.SIW", |
|
#"Microsoft.TeamsExploration", |
|
#"Microsoft.TeamsContinuousDeployment", |
|
#"LutzRoeder.Netron", |
|
#"Sinew.Enpass", |
|
#"Oracle.VirtualBox", |
|
#"Microsoft.Teams", |
|
#"stackless.stackless", |
|
#"Microsoft.RemoteDesktopClient", |
|
#"qBittorrent.qBittorrent", |
|
#"Microsoft.XMLNotepad", |
|
#"eloston.ungoogled-chromium", |
|
"BraveSoftware.BraveBrowser", |
|
#"Kitware.CMake", |
|
#"Elastic.Elasticsearch", |
|
"Microsoft.AzureCLI", |
|
"Mozilla.Firefox", |
|
#"beekeeper-studio.beekeeper-studio", |
|
#"dbeaver.dbeaver", |
|
#"BiglySoftware.BiglyBT", |
|
#"OSGeo.QGIS", |
|
#"HTTPToolKit.HTTPToolKit", |
|
#"Heroku.HerokuCLI", |
|
"Dropbox.Dropbox", |
|
"Microsoft.PowerBI", |
|
#"JetBrains.GoLand", |
|
#"JetBrains.CLion", |
|
#"JetBrains.PHPStorm", |
|
#"JetBrains.WebStorm", |
|
#"Files-Community.Files", |
|
"schemacrawler.schemacrawler", |
|
#"Glarysoft.GlaryUtilities", |
|
#"Puppet.puppet-bolt", |
|
#"Microsoft.PowerToys", |
|
#"QL-Win.QuickLook", |
|
#"sbt.sbt", |
|
#"Postman.Postman", |
|
#"Microsoft.OfficeDeploymentTool", |
|
#"GLab.GLab", |
|
#"PDFsam.PDFsam", |
|
"WiresharkFoundation.Wireshark", |
|
#"Google.IAPDesktop", |
|
#"Microsoft.AzureFunctionsCoreTools", |
|
#"GoLang.Go", |
|
#"Rustlang.Rust.GNU", |
|
#"Microsoft.dotnetRuntime.5-x64", |
|
#"Microsoft.VisualStudio.2019.RemoteTools", |
|
"Microsoft.dotnet", |
|
"7zip.7zip", |
|
#"Oracle.JavaRuntimeEnvironment", |
|
"Microsoft.SharePointOnlineManagementShell", |
|
#"Microsoft.WindowsVirtualDesktopAgent", |
|
#"LibreOffice.LibreOffice", |
|
#"Nlitesoft.NTLite", |
|
"Microsoft.AzureStorageExplorer", |
|
#"Microsoft.MouseandKeyboardCenter", |
|
#"GitHub.cli", |
|
#"Kubernetes.minikube", |
|
#"AgileBits.1Password", |
|
#"Alacritty.Alacritty", |
|
#"Canonical.Multipass", |
|
"JohnMacFarlane.Pandoc", |
|
#"Joplin.Joplin", |
|
"LyX.LyX", |
|
#"CloudApp.CloudApp", |
|
#"NagleCode.PacketSender", |
|
#"Rustlang.Rust.MSVC", |
|
#"Microsoft.WindowsAdminCenter", |
|
#"LaurentPRenedeCotret.pandoc-plot", |
|
#"tantowi.maven", |
|
#"PostgreSQL.pgAdmin", |
|
#"AlexandrSubbotin.Cerebro", |
|
#"Zotero.Zotero", |
|
#"Yarn.Yarn", |
|
#"Mirantis.Lens", |
|
"Oracle.JavaRuntimeEnvironment", |
|
"RedHat.VirtViewer", |
|
"RealVNC.VNCViewer", |
|
"WinDirStat.WinDirStat", |
|
#"RichardsonSoftware.RazorSQL", |
|
"TorProject.TorBrowser", |
|
"Transmission.Transmission", |
|
"Microsoft.Office", |
|
#"HeidiSQL.HeidiSQL", |
|
#"Lazarus.Lazarus", |
|
"ZAP.ZAP", |
|
"AirVPN.Eddie") |
|
|
|
foreach ($app in $Apps) { |
|
winget install -e --id $app --accept-package-agreements --accept-source-agreements |
|
} |
|
} |
|
|
|
|
|
if (Get-Command -Name 'scoop') { |
|
Write-Host "Scoop is already installed, skip installation." |
|
} |
|
else { |
|
Write-Host "" |
|
Write-Host "Installing Scoop for Windows..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
#Set-ExecutionPolicy Bypass -Scope Process -Force; iex "& {$(irm get.scoop.sh)} -RunAsAdmin" |
|
iex "& {$(irm get.scoop.sh)} -RunAsAdmin" |
|
} |
|
|
|
|
|
if (Get-Command -Name 'sudo') { |
|
Write-Host "Sudo is already installed, skip installation." |
|
} |
|
else { |
|
Write-Host "" |
|
Write-Host "Installing Sudo with Scoop..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
scoop install sudo -y |
|
} |
|
|
|
|
|
$thisPCIconRegPath = "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" |
|
$thisPCRegValname = "LongPathsEnabled" |
|
$item = Get-ItemProperty -Path $thisPCIconRegPath -Name $thisPCRegValname -ErrorAction SilentlyContinue |
|
if ($item) { |
|
sudo Set-ItemProperty -Path $thisPCIconRegPath -name $thisPCRegValname -Value 1 |
|
} |
|
else { |
|
sudo New-ItemProperty -Path $thisPCIconRegPath -Name $thisPCRegValname -Value 1 | Out-Null |
|
} |
|
|
|
|
|
if ($true) { |
|
Write-Host "Adding Scoop to PATH using sudo..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
|
|
sudo Add-MpPreference -ExclusionPath "C:\Users\x\scoop" -Force |
|
sudo Add-MpPreference -ExclusionPath "C:\ProgramData\scoop" -Force |
|
} |
|
|
|
|
|
Write-Host "Installing Scoop Apps..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
|
|
$Apps = @( |
|
"git", |
|
"innounp", |
|
"dark", |
|
"wixtoolset", |
|
"everything", |
|
"jq", |
|
"jid", |
|
"age", |
|
"pshazz", |
|
"concfg", |
|
"aria2", |
|
"bit", |
|
"bat", |
|
"less", |
|
"tldr", |
|
"nodejs") |
|
|
|
foreach ($app in $Apps) { |
|
scoop install $app -g |
|
} |
|
|
|
if (Test-Path -Path (echo $PROFILE)) { |
|
Write-Host "Profile exists, skipping..." |
|
} else { |
|
Write-Host "Creating Profile file..." |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
New-Item -Path $PROFILE -Type File -Force |
|
} |
|
|
|
if ($true) { |
|
Write-Host "Adding Scoop Extras..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
scoop bucket add extras |
|
|
|
Write-Host "Installing keypirinha with scoop..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
scoop install keypirinha |
|
|
|
Write-Host "Running ketpirinha.exe..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
keypirinha.exe |
|
|
|
Write-Host "Starting SSH Agent..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
sudo Set-Service ssh-agent -StartupType Manual |
|
|
|
Write-Host "Backing up console config to console-backup.json..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
concfg export console-backup.json |
|
|
|
Write-Host "Importing solarized-dark to config..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
concfg import solarized-dark |
|
|
|
Write-Host "Adding Autocompletion..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Add-Content -Path (echo $PROFILE) -Value '# Autocompletion' |
|
Add-Content -Path (echo $profile) -Value 'try { $null = gcm gh -ea stop; Invoke-Expression -Command $(gh completion -s powershell | Out-String) } catch { }' |
|
Add-Content -Path (echo $PROFILE) -Value '' |
|
} |
|
|
|
# add autocompletion |
|
#bit complete |
|
|
|
if ($true) { |
|
Write-Host "Installing fonts..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
scoop bucket add nerd-fonts |
|
sudo scoop install FiraCode |
|
sudo scoop install FiraCode-NF |
|
sudo scoop install Hack-NF |
|
sudo scoop install Hack-NF-Mono |
|
sudo scoop install Cascadia-Code |
|
|
|
Write-Host "Installing chexmoi..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
scoop config aria2-warning-enabled false |
|
scoop bucket add twpayne https://github.com/twpayne/scoop-bucket |
|
scoop install chezmoi |
|
|
|
if (Get-Command -Name 'oh-my-posh') { |
|
Write-Host "OhMyPosh is already installed, skip installation." |
|
} |
|
else { |
|
Write-Host "" |
|
Write-Host "Installing OhMyPosh..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force; winget install JanDeDobbeleer.OhMyPosh -s winget |
|
} |
|
|
|
Add-Content -Path (echo $PROFILE) -Value '# Powerline setup' |
|
Add-Content -Path (echo $PROFILE) -Value 'oh-my-posh init pwsh | Invoke-Expression' |
|
Add-Content -Path (echo $PROFILE) -Value '#& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))' |
|
Add-Content -Path (echo $PROFILE) -Value '' |
|
. $PROFILE |
|
|
|
#Install-Module posh-git -Scope CurrentUser -Force |
|
#Install-Module oh-my-posh -Scope CurrentUser -Force |
|
#Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck |
|
|
|
#Set-PoshPrompt -Theme -PowerLineFont |
|
#Add-Content -Path (echo $PROFILE) -Value '# Powerline setup' |
|
#Add-Content -Path (echo $PROFILE) -Value 'Import-Module posh-git' |
|
#Add-Content -Path (echo $PROFILE) -Value 'Import-Module oh-my-posh' |
|
#Add-Content -Path (echo $PROFILE) -Value 'Set-PoshPrompt -Theme -PowerLineFont' |
|
} |
|
|
|
if ($true) { |
|
Write-Host "Activating WSL..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
## * https://docs.microsoft.com/fr-fr/windows/wsl/install-win10) |
|
## * https://support.rstudio.com/hc/en-us/articles/360049776974-Using-RStudio-Server-in-Windows-WSL2 |
|
sudo dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart |
|
## WSL 2 |
|
sudo dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart |
|
## restart |
|
## update kernel : https://docs.microsoft.com/fr-fr/windows/wsl/wsl2-kernel |
|
#sudo wsl --set-default-version 2 |
|
#sudo wsl --install -d Ubuntu |
|
## Install ubuntu from winstore and run it to install |
|
|
|
## Share env var (https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/) |
|
setx WSLENV |
|
} |
|
|
|
|
|
Write-Host "Setting up Git for Windows..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
|
|
$gitEmail = Read-Host 'Enter email address for global git config:' |
|
git config --global user.email $gitEmail |
|
|
|
$gitUsername = Read-Host 'Enter username for global git config:' |
|
git config --global user.name $gitUsername |
|
git config --global core.autocrlf true |
|
|
|
# FFmpeg |
|
if ($true) { |
|
Write-Host "Downloading FFmpeg..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
$ffmpegPath = "${env:ProgramFiles}\FFMPEG" |
|
$downloadUri = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z" |
|
|
|
$downloadedFfmpeg = $env:USERPROFILE + "\ffmpeg-git-full.7z" |
|
Remove-Item $downloadedFfmpeg -ErrorAction SilentlyContinue |
|
aria2c.exe $downloadUri -d $HOME -o "ffmpeg-git-full.7z" |
|
|
|
& ${env:ProgramFiles}\7-Zip\7z.exe x $downloadedFfmpeg "-o$($ffmpegPath)" -y |
|
$subPath = $(Get-ChildItem -Path $ffmpegPath | Where-Object { $_.Name -like "ffmpeg*" } | Sort-Object Name -Descending | Select-Object -First 1).Name |
|
$subPath = Join-Path -Path $ffmpegPath -ChildPath $subPath |
|
$binPath = Join-Path -Path $subPath -ChildPath "bin" |
|
Remove-Item $ffmpegPath\*.exe |
|
Move-Item $binPath\*.exe $ffmpegPath |
|
|
|
Write-Host "Adding FFmpeg to PATH..." -ForegroundColor Green |
|
AddToPath -folder $ffmpegPath |
|
Remove-Item -Path $downloadedFfmpeg -Force |
|
} |
|
|
|
|
|
Write-Host "Set home path hidden folders and files..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Get-ChildItem -Path $HOME -Filter .* -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object { $_.Attributes = $_.Attributes -bor [System.IO.FileAttributes]::Hidden } |
|
|
|
Write-Host "Avoid Edge showing sidebar..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -ErrorAction SilentlyContinue |
|
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Name HubsSidebarEnabled -Type DWORD -Value 0 -ErrorAction SilentlyContinue |
|
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Name HubsSidebarEnabled -Type DWORD -Value 0 |
|
|
|
Write-Host "Disabling Alt+Tab swiching Edge tabs..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -ErrorAction SilentlyContinue |
|
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name MultiTaskingAltTabFilter -Type DWORD -Value 3 -ErrorAction SilentlyContinue |
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name MultiTaskingAltTabFilter -Type DWORD -Value 3 |
|
|
|
Write-Host "Avoid shitty folder grouping..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
(gci 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags' -s | ? PSChildName -eq '{885a186e-a440-4ada-812b-db871b942259}' ) | ri -Recurse |
|
|
|
Write-Host "Applying file explorer settings..." -ForegroundColor Green |
|
cmd.exe /c "reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f" |
|
cmd.exe /c "reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v AutoCheckSelect /t REG_DWORD /d 0 /f" |
|
cmd.exe /c "reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v LaunchTo /t REG_DWORD /d 1 /f" |
|
|
|
Write-Host "Disabling the Windows Ink Workspace..." -ForegroundColor Green |
|
REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace" /V PenWorkspaceButtonDesiredVisibility /T REG_DWORD /D 0 /F |
|
|
|
Write-Host "Exclude repos from Windows Defender..." -ForegroundColor Green |
|
Add-MpPreference -ExclusionPath "$env:USERPROFILE\source\repos" |
|
Add-MpPreference -ExclusionPath "$env:USERPROFILE\.nuget" |
|
Add-MpPreference -ExclusionPath "$env:USERPROFILE\.vscode" |
|
Add-MpPreference -ExclusionPath "$env:USERPROFILE\.dotnet" |
|
Add-MpPreference -ExclusionPath "$env:USERPROFILE\.ssh" |
|
Add-MpPreference -ExclusionPath "$env:USERPROFILE\.azuredatastudio" |
|
Add-MpPreference -ExclusionPath "$env:APPDATA\npm" |
|
|
|
Write-Host "Syncing time..." -ForegroundColor Green |
|
net stop w32time |
|
net start w32time |
|
w32tm /resync /force |
|
w32tm /query /status |
|
|
|
Write-Host "Setting Time zone..." -ForegroundColor Green |
|
Set-TimeZone -Name "Eastern Standard Time" |
|
|
|
Write-Host "Enabling Hardware-Accelerated GPU Scheduling..." -ForegroundColor Green |
|
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\" -Name 'HwSchMode' -Value '2' -PropertyType DWORD -Force |
|
|
|
Write-Host "Installing Github.com/microsoft/artifacts-credprovider..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1')) |
|
|
|
Write-Host "Removing Bluetooth icons..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
cmd.exe /c "reg add `"HKCU\Control Panel\Bluetooth`" /v `"Notification Area Icon`" /t REG_DWORD /d 0 /f" |
|
|
|
# ----------------------------------------------------------------------------- |
|
Write-Host "" |
|
Write-Host "Checking Windows updates..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Install-Module -Name PSWindowsUpdate -Force |
|
Write-Host "Installing updates... (Computer will reboot in minutes...)" -ForegroundColor Green |
|
Get-WindowsUpdate -AcceptAll -Install -ForceInstall -AutoReboot |
|
|
|
$settingsUrl = "https://gist.githubusercontent.com/ericbaranowski/5ae5caf89df40267164043b4fa0fb8ec/raw/c3081cceace69e02d9a44a8bebfe1fa6b5584ce8/settings.json" |
|
Write-Host "Installing Terminal Settings..." -ForegroundColor Green |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
iex ((New-Object System.Net.WebClient).DownloadString($settingsUrl)) |
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
Write-Host "------------------------------------" -ForegroundColor Green |
|
Read-Host -Prompt "Setup is done, restart is needed, press [ENTER] to restart computer." |
|
Restart-Computer |