Files
Disassembler 1e977ab95f v3.0, 2018-09-15, BYOT - Bring your own tweaks
- Split execution logic from tweak library and add support for custom tweaks
 - Check "Advanced usage" chapter in README
2018-09-15 18:37:28 +02:00

44 lines
1.5 KiB
PowerShell

##########
# Win10 / WinServer2016 Initial Setup Script - Main execution loop
# Author: Disassembler <disassembler@dasm.cz>
# Version: v3.0, 2018-09-15
# 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 = @()
# 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
$tweaks += Get-Content $preset -ErrorAction Stop | ForEach { $_.Split("#")[0].Trim() } | Where { $_ -ne "" }
} Else {
$PSCommandArgs += $args[$i]
# Load tweak names from command line
$tweaks += $args[$i]
}
$i++
}
# Call the desired tweak functions
$tweaks | ForEach { Invoke-Expression $_ }