Browse Source

Update Download_Sophia.ps1

master
Dmitry Nefedov 9 months ago
committed by GitHub
parent
commit
da5f98ded6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 72
      Download_Sophia.ps1

72
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)
@ -40,40 +29,12 @@ $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"
{
# 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"
@ -88,15 +49,16 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
}
$Version = "LTSC2019"
break
}
{($_ -ge 19044) -and ($_ -le 19048)}
else
{
if ($PSVersionTable.PSVersion.Major -eq 5)
Write-Verbose -Message "Windows version is not supported. Update your Windows" -Versbose
}
}
"19044"
{
# 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")
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2021")
{
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
@ -109,10 +71,16 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
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"
@ -128,7 +96,6 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
$Version = "Windows_10_PowerShell_5.1"
}
}
else
{
$Parameters = @{
@ -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"

Loading…
Cancel
Save