From da5f98ded6ecd1426cc802090da4c1e9412cd3de Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Wed, 13 Dec 2023 14:25:25 +0300 Subject: [PATCH] Update Download_Sophia.ps1 --- Download_Sophia.ps1 | 152 +++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 95 deletions(-) diff --git a/Download_Sophia.ps1 b/Download_Sophia.ps1 index 9b43c5d8..8874dfa9 100644 --- a/Download_Sophia.ps1 +++ b/Download_Sophia.ps1 @@ -9,20 +9,9 @@ .EXAMPLE Download and expand Sophia Script archive iwr script.sophia.team -useb | iex - .EXAMPLE Download and expand Wrapper archive - iex "& {$(irm script.sophi.app -useb)} -Wrapper" - .NOTES Current user #> -[CmdletBinding()] -param -( - [Parameter(Mandatory = $false)] - [switch] - $Wrapper -) - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 if ($Host.Version.Major -eq 5) @@ -33,101 +22,79 @@ if ($Host.Version.Major -eq 5) } $Parameters = @{ - Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest" - UseBasicParsing = $true + Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest" + UseBasicParsing = $true } $LatestGitHubRelease = (Invoke-RestMethod @Parameters).tag_name $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" -if ($Wrapper) -{ - $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" - UseBasicParsing = $true - } - $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Wrapper - $Parameters = @{ - Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.Wrapper.v$LatestRelease.zip" - OutFile = "$DownloadsFolder\Sophia.Script.Wrapper.zip" - UseBasicParsing = $true - Verbose = $true - } - Invoke-WebRequest @Parameters - - $Version = "Wrapper" - - $Parameters = @{ - Path = "$DownloadsFolder\Sophia.Script.Wrapper.zip" - DestinationPath = "$DownloadsFolder" - Force = $true - } - Expand-Archive @Parameters - - Remove-Item -Path "$DownloadsFolder\Sophia.Script.Wrapper.zip" -Force - - Start-Sleep -Second 1 - - Invoke-Item -Path "$DownloadsFolder\Sophia_Script_Wrapper_v$LatestRelease" -} - switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) { "17763" { - $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" - UseBasicParsing = $true + # Check if Windows 10 is an LTSC 2019 + if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2019") + { + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + UseBasicParsing = $true + } + $LatestRelease = (Invoke-RestMethod @Parameters).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 + } + + $Version = "LTSC2019" } - $LatestRelease = (Invoke-RestMethod @Parameters).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 + else + { + Write-Verbose -Message "Windows version is not supported. Update your Windows" -Versbose } - - $Version = "LTSC2019" - - break } - {($_ -ge 19044) -and ($_ -le 19048)} + "19044" { - if ($PSVersionTable.PSVersion.Major -eq 5) + # Check if Windows 10 is an LTSC 2021 + if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2021") { - # Check if Windows 10 is an LTSC 2021 - if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -eq "Windows 10 Enterprise LTSC 2021") - { - $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" - UseBasicParsing = $true - } - $LatestRelease = (Invoke-RestMethod @Parameters).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 - } - + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + UseBasicParsing = $true + } + $LatestRelease = (Invoke-RestMethod @Parameters).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 + } $Version = "LTSC2021" + } + else + { + Write-Verbose -Message "Windows version is not supported. Update your Windows" -Versbose + } + } + "19045" + { + if ($Host.Version.Major -eq 5) + { + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + UseBasicParsing = $true } - else - { - $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" - UseBasicParsing = $true - } - $LatestRelease = (Invoke-RestMethod @Parameters).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 - } - - $Version = "Windows_10_PowerShell_5.1" + $LatestRelease = (Invoke-RestMethod @Parameters).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 } + + $Version = "Windows_10_PowerShell_5.1" } else { @@ -145,11 +112,10 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) $Version = "Windows_10_PowerShell_7" } - } {$_ -ge 22000} { - if ($PSVersionTable.PSVersion.Major -eq 5) + if ($Host.Version.Major -eq 5) { $Parameters = @{ Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" @@ -198,10 +164,6 @@ Start-Sleep -Second 1 switch ($Version) { - "Wrapper" - { - Invoke-Item -Path "$DownloadsFolder\Sophia_Script_Wrapper_v$LatestRelease" - } "LTSC2019" { Invoke-Item -Path "$DownloadsFolder\Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease"