forked from Disassembler0/Win10-Initial-Setup-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWin10.ps1
43 lines (39 loc) · 1.49 KB
/
Win10.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
##########
# Win10 / WinServer2016 Initial Setup Script - Main execution loop
# Author: Disassembler <[email protected]>
# 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 $_ }