Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 committed Nov 28, 2024
1 parent d9ad699 commit 318cb69
Show file tree
Hide file tree
Showing 27 changed files with 2,057 additions and 2,006 deletions.
6 changes: 2 additions & 4 deletions Download_Latest_Sophia.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
Download the latest Sophia Script version, depending on what Windows or PowerShell versions are used to
.SYNOPSIS
Download the latest Sophia Script version, depending on what Windows or PowerShell versions are used to
E.g., if you start script on Windows 11 via PowerShell 5.1 you will start downloading Sophia Script for Windows 11 PowerShell 5.1
For example, if you start script on Windows 11 via PowerShell 5.1 you will start downloading Sophia Script for Windows 11 PowerShell 5.1
.EXAMPLE Download and expand Sophia Script archive
.EXAMPLE
iwr sl.sophia.team -useb | iex
#>

Expand Down Expand Up @@ -111,7 +110,6 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
}
}
}
Invoke-WebRequest @Parameters

if (-not (Test-Path -Path "$DownloadsFolder\SophiaScriptTemp"))
{
Expand Down
24 changes: 16 additions & 8 deletions Download_Sophia.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Download and expand latest Sophia Script version, depending on what Windows or PowerShell versions are used to
.SYNOPSIS
E.g., if you start script on Windows 11 via PowerShell 5.1 you will start downloading Sophia Script for Windows 11 PowerShell 5.1
For example, if you start script on Windows 11 via PowerShell 5.1 you will start downloading Sophia Script for Windows 11 PowerShell 5.1
.EXAMPLE
iwr script.sophia.team -useb | iex
Expand Down Expand Up @@ -32,6 +32,7 @@ $Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
UseBasicParsing = $true
}
$JSONVersions = Invoke-WebRequest @Parameters

switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
{
Expand All @@ -40,13 +41,14 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
# Check for Windows 10 LTSC 2019
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2019")
{
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2019
$LatestRelease = $JSONVersions.Sophia_Script_Windows_10_LTSC2019
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip"
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_10_LTSC2019"
}
Expand All @@ -72,13 +74,15 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
# Check for Windows 10 LTSC 2021
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2021")
{
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021
$LatestRelease = $JSONVersions.Sophia_Script_Windows_10_LTSC2021
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip"
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_10_LTSC2021"
}
else
Expand All @@ -102,13 +106,14 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
{
if ($Host.Version.Major -eq 5)
{
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1
$LatestRelease = $JSONVersions.Sophia_Script_Windows_10_PowerShell_5_1
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.v$LatestRelease.zip"
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_10_PowerShell_5.1"
}
Expand All @@ -121,6 +126,7 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_10_PowerShell_7"
}
Expand All @@ -132,44 +138,46 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
{
if ($Host.Version.Major -eq 5)
{
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1
$LatestRelease = $JSONVersions.Sophia_Script_Windows_11_PowerShell_5_1
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.v$LatestRelease.zip"
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_11_PowerShell_5.1"
}
else
{
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_7
$LatestRelease = $JSONVersions.Sophia_Script_Windows_11_PowerShell_7
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip"
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_11_PowerShell_7"
}
}
else
{
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_LTSC2024
$LatestRelease = $JSONVersions.Sophia_Script_Windows_11_LTSC2024
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.LTSC.2024.v$LatestRelease.zip"
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Version = "Windows_11_LTSC2024"
}
}
}
Invoke-WebRequest @Parameters

if (-not (Test-Path -Path "$DownloadsFolder\Sophia.Script.zip"))
{
Expand Down
67 changes: 35 additions & 32 deletions Wrapper/Config/config_Windows_10.json
Original file line number Diff line number Diff line change
Expand Up @@ -572,22 +572,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "CopilotButton",
"Arg": {
"Zero": {
"Tag": "Hide"
},
"One": {
"Tag": "Show"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
Expand Down Expand Up @@ -700,6 +684,25 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "TaskbarCombine",
"Arg": {
"Zero": {
"Tag": "Always"
},
"One": {
"Tag": "Full"
},
"Two": {
"Tag": "Never"
}
},
"Preset": "Zero",
"WindowsDefault": "Zero"
},
{
"Region": "UI & Personalization",
"Control": "chk",
Expand Down Expand Up @@ -1106,22 +1109,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "System",
"Control": "cmb",
"Required": "false",
"Function": "MappedDrivesAppElevatedAccess",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "System",
"Control": "cmb",
Expand Down Expand Up @@ -2228,6 +2215,22 @@
"Preset": "",
"WindowsDefault": "One"
},
{
"Region": "Context menu",
"Control": "cmb",
"Required": "false",
"Function": "ImagesEditContext",
"Arg": {
"Zero": {
"Tag": "Hide"
},
"One": {
"Tag": "Show"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "Context menu",
"Control": "cmb",
Expand Down
37 changes: 19 additions & 18 deletions Wrapper/Config/config_Windows_10_LTSC.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,25 @@
"LTSC2019": "true",
"LTSC2021": "true"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "TaskbarCombine",
"Arg": {
"Zero": {
"Tag": "Always"
},
"One": {
"Tag": "Full"
},
"Two": {
"Tag": "Never"
}
},
"Preset": "Zero",
"WindowsDefault": "Zero"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
Expand Down Expand Up @@ -986,24 +1005,6 @@
"LTSC2019": "true",
"LTSC2021": "true"
},
{
"Region": "System",
"Control": "cmb",
"Required": "false",
"Function": "MappedDrivesAppElevatedAccess",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"LTSC2019": "true",
"LTSC2021": "true"
},
{
"Region": "System",
"Control": "cmb",
Expand Down
32 changes: 0 additions & 32 deletions Wrapper/Config/config_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -591,22 +591,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "CopilotButton",
"Arg": {
"Zero": {
"Tag": "Hide"
},
"One": {
"Tag": "Show"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
Expand Down Expand Up @@ -1029,22 +1013,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "System",
"Control": "cmb",
"Required": "false",
"Function": "MappedDrivesAppElevatedAccess",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "System",
"Control": "cmb",
Expand Down
34 changes: 0 additions & 34 deletions Wrapper/Config/config_Windows_11_LTSC.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,23 +611,6 @@
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "CopilotButton",
"Arg": {
"Zero": {
"Tag": "Hide"
},
"One": {
"Tag": "Show"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
Expand Down Expand Up @@ -1045,23 +1028,6 @@
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "System",
"Control": "cmb",
"Required": "false",
"Function": "MappedDrivesAppElevatedAccess",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "System",
"Control": "cmb",
Expand Down
Loading

0 comments on commit 318cb69

Please sign in to comment.