mirror of
https://github.com/Disassembler0/Win10-Initial-Setup-Script.git
synced 2026-01-12 23:48:20 -05:00
- Add "Disable IE first run wizard" (thx @sippi90) - Add "Disable Modern UI swap file" (thx gtein) - Add "Disable enhanced pointer precision" - Add "Enable clearing of recent files on exit" (thx @r3incarnat0r) - Add "Disable recent files lists" (thx @r3incarnat0r) - Reimplement HideMostUsedApps using GPO (thx @r3incarnat0r) - *BREAKING* Removed HideRecentJumplists (superseded by DisableRecentFiles) - Update UninstallMsftBloat to not remove Snipping tool - Update DisableTelemetry to not report KMS client activation data (thx @wallrik) - Fix main execution loop when the script is called by another PowerShell process
54 lines
1.8 KiB
PowerShell
54 lines
1.8 KiB
PowerShell
##########
|
|
# Win 10 / Server 2016 / Server 2019 Initial Setup Script - Main execution loop
|
|
# Author: Disassembler <disassembler@dasm.cz>
|
|
# Version: v3.6, 2019-01-28
|
|
# Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script
|
|
##########
|
|
|
|
# Relaunch the script with administrator privileges
|
|
Function RequireAdmin {
|
|
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
|
|
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -Verb RunAs
|
|
Exit
|
|
}
|
|
}
|
|
|
|
$tweaks = @()
|
|
$PSCommandArgs = @()
|
|
|
|
Function AddOrRemoveTweak($tweak) {
|
|
If ($tweak[0] -eq "!") {
|
|
# If the name starts with exclamation mark (!), exclude the tweak from selection
|
|
$script:tweaks = $script:tweaks | Where-Object { $_ -ne $tweak.Substring(1) }
|
|
} ElseIf ($tweak -ne "") {
|
|
# Otherwise add the tweak
|
|
$script:tweaks += $tweak
|
|
}
|
|
}
|
|
|
|
# Parse and resolve paths in passed arguments
|
|
$i = 0
|
|
While ($i -lt $args.Length) {
|
|
If ($args[$i].ToLower() -eq "-include") {
|
|
# Resolve full path to the included file
|
|
$include = Resolve-Path $args[++$i]
|
|
$PSCommandArgs += "-include `"$include`""
|
|
# Import the included file as a module
|
|
Import-Module -Name $include
|
|
} ElseIf ($args[$i].ToLower() -eq "-preset") {
|
|
# Resolve full path to the preset file
|
|
$preset = Resolve-Path $args[++$i]
|
|
$PSCommandArgs += "-preset `"$preset`""
|
|
# Load tweak names from the preset file
|
|
Get-Content $preset -ErrorAction Stop | ForEach-Object { AddOrRemoveTweak($_.Split("#")[0].Trim()) }
|
|
} Else {
|
|
$PSCommandArgs += $args[$i]
|
|
# Load tweak names from command line
|
|
AddOrRemoveTweak($args[$i])
|
|
}
|
|
$i++
|
|
}
|
|
|
|
# Call the desired tweak functions
|
|
$tweaks | ForEach-Object { Invoke-Expression $_ }
|