diff --git a/README.md b/README.md index aae1b51f..50482a47 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Made with [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -if ($Host.Version.Major -eq 5) -{ - # Progress bar can significantly impact cmdlet performance - # https://github.com/PowerShell/PowerShell/issues/2138 - $Script:ProgressPreference = "SilentlyContinue" -} - $Parameters = @{ Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest" UseBasicParsing = $true @@ -46,6 +44,9 @@ $Parameters = @{ } $JSONVersions = Invoke-RestMethod @Parameters +$null = $packageParameters +$packageParameters = $env:chocolateyPackageParameters + switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) { "17763" @@ -55,15 +56,6 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) { $LatestRelease = $JSONVersions.Sophia_Script_Windows_10_LTSC2019 $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true - } - Invoke-WebRequest @Parameters - - $Version = "Windows_10_LTSC2019" } else { @@ -89,13 +81,6 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) { $LatestRelease = $JSONVersions.Sophia_Script_Windows_10_LTSC2021 $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true - } - Invoke-WebRequest @Parameters } else { @@ -116,72 +101,43 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) } "19045" { - if ($Host.Version.Major -eq 5) + if ($packageParameters) { - $LatestRelease = $JSONVersions.Sophia_Script_Windows_10_PowerShell_5_1 - $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true + if ($packageParameters.Contains('PS7')) + { + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7 + $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" } - Invoke-WebRequest @Parameters } else { - $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7 - $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true - } - Invoke-WebRequest @Parameters + $LatestRelease = $JSONVersions.Sophia_Script_Windows_10_PowerShell_5_1 + $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.v$LatestRelease.zip" } } - {$_ -ge 22631} + {$_ -ge 26100} { # Check for Windows 11 LTSC 2024 if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -notmatch "LTSC 2024") { - if ($Host.Version.Major -eq 5) + if ($packageParameters) { - $LatestRelease = $JSONVersions.Sophia_Script_Windows_11_PowerShell_5_1 - $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true + if ($packageParameters.Contains('PS7')) + { + $LatestRelease = $JSONVersions.Sophia_Script_Windows_11_PowerShell_7 + $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" } - Invoke-WebRequest @Parameters } else { - $LatestRelease = $JSONVersions.Sophia_Script_Windows_11_PowerShell_7 - $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true - } - Invoke-WebRequest @Parameters + $LatestRelease = $JSONVersions.Sophia_Script_Windows_11_PowerShell_5_1 + $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.v$LatestRelease.zip" } } else { $LatestRelease = $JSONVersions.Sophia_Script_Windows_11_LTSC2024 $URL = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.LTSC.2024.v$LatestRelease.zip" - $Parameters = @{ - Uri = $URL - OutFile = "$DownloadsFolder\Sophia.Script.zip" - UseBasicParsing = $true - Verbose = $true - } - Invoke-WebRequest @Parameters } } } diff --git a/docs/README_de-de.md b/docs/README_de-de.md index d42686a4..7dc6e146 100644 --- a/docs/README_de-de.md +++ b/docs/README_de-de.md @@ -49,6 +49,7 @@ Mit > `Sophia Script для Windows` може не працювати на "самопальних" збірках Windows. Особливо, якщо збірка була створена так, що в ній спеціально було зламано Microsoft Defender і вимкнено телеметрію, вирізавши системні компоненти. -## Завантажити через PowerShell +### Завантажити через PowerShell Команда завантажить і розпакує останній архів Sophia Script (`без запуску`) відповідно до того, під якою версією Windows і PowerShell він запускається. Якщо запустити її, наприклад, в Windows 11 через PowerShell 5.1, вона завантажить Sophia Script для `Windows 11 PowerShell 5.1`. @@ -85,6 +86,20 @@ iwr script.sophia.team -useb | iex iwr sl.sophia.team -useb | iex ``` +### Завантажити через Chocolatey + +TКоманда завантажить і розпакує останню версію архіву Sophia Script (`без подальшого запуску`) згідно з версією Windows, на якій вона запускалася. Припустимо, якщо ви запустите її на Windows 11, то завантажиться Sophia Script для `Windows 11`. За замовчуванням для `PowerShell 5.1`, якщо не вказано зворотне. + +```powershell +choco install sophia --force -y +``` + +Завантажити `Sophia Script for Windows` для `PowerShell 7`. + +```powershell +choco install sophia --params "/PS7" --force -y +``` + ### Вручну * Завантажити [архів](https://github.com/farag2/Sophia-Script-for-Windows/releases/latest) згідно з вашою версією Windows і PowerShell;