-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWin10.ps1
More file actions
40 lines (36 loc) · 1.32 KB
/
Win10.ps1
File metadata and controls
40 lines (36 loc) · 1.32 KB
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
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 "!") {
$script:tweaks = $script:tweaks | Where-Object { $_ -ne $tweak.Substring(1) }
} ElseIf ($tweak -ne "") {
$script:tweaks += $tweak
}
}
$i = 0
While ($i -lt $args.Length) {
If ($args[$i].ToLower() -eq "-include") {
$include = Resolve-Path $args[++$i]
$PSCommandArgs += "-include `"$include`""
Import-Module -Name $include
} ElseIf ($args[$i].ToLower() -eq "-preset") {
$preset = Resolve-Path $args[++$i]
$PSCommandArgs += "-preset `"$preset`""
Get-Content $preset -ErrorAction Stop | ForEach-Object { AddOrRemoveTweak($_.Split("#")[0].Trim()) }
} ElseIf ($args[$i].ToLower() -eq "-log") {
$log = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($args[++$i])
$PSCommandArgs += "-log `"$log`""
Start-Transcript $log
} Else {
$PSCommandArgs += $args[$i]
AddOrRemoveTweak($args[$i])
}
$i++
}
$tweaks | ForEach-Object { Invoke-Expression $_ }