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. 152
      Download_Sophia.ps1

152
Download_Sophia.ps1

@ -9,20 +9,9 @@
.EXAMPLE Download and expand Sophia Script archive .EXAMPLE Download and expand Sophia Script archive
iwr script.sophia.team -useb | iex iwr script.sophia.team -useb | iex
.EXAMPLE Download and expand Wrapper archive
iex "& {$(irm script.sophi.app -useb)} -Wrapper"
.NOTES .NOTES
Current user Current user
#> #>
[CmdletBinding()]
param
(
[Parameter(Mandatory = $false)]
[switch]
$Wrapper
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if ($Host.Version.Major -eq 5) if ($Host.Version.Major -eq 5)
@ -33,101 +22,79 @@ if ($Host.Version.Major -eq 5)
} }
$Parameters = @{ $Parameters = @{
Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest" Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest"
UseBasicParsing = $true UseBasicParsing = $true
} }
$LatestGitHubRelease = (Invoke-RestMethod @Parameters).tag_name $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}" $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) switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
{ {
"17763" "17763"
{ {
$Parameters = @{ # Check if Windows 10 is an LTSC 2019
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2019")
UseBasicParsing = $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_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 else
$Parameters = @{ {
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" Write-Verbose -Message "Windows version is not supported. Update your Windows" -Versbose
OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true
Verbose = $true
} }
$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 $Parameters = @{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -eq "Windows 10 Enterprise LTSC 2021") Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
{ UseBasicParsing = $true
$Parameters = @{ }
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021
UseBasicParsing = $true $Parameters = @{
} Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip"
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021 OutFile = "$DownloadsFolder\Sophia.Script.zip"
$Parameters = @{ UseBasicParsing = $true
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" Verbose = $true
OutFile = "$DownloadsFolder\Sophia.Script.zip" }
UseBasicParsing = $true
Verbose = $true
}
$Version = "LTSC2021" $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 $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1
{ $Parameters = @{
$Parameters = @{ Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.v$LatestRelease.zip"
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" OutFile = "$DownloadsFolder\Sophia.Script.zip"
UseBasicParsing = $true UseBasicParsing = $true
} Verbose = $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"
} }
$Version = "Windows_10_PowerShell_5.1"
} }
else else
{ {
@ -145,11 +112,10 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
$Version = "Windows_10_PowerShell_7" $Version = "Windows_10_PowerShell_7"
} }
} }
{$_ -ge 22000} {$_ -ge 22000}
{ {
if ($PSVersionTable.PSVersion.Major -eq 5) if ($Host.Version.Major -eq 5)
{ {
$Parameters = @{ $Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" 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) switch ($Version)
{ {
"Wrapper"
{
Invoke-Item -Path "$DownloadsFolder\Sophia_Script_Wrapper_v$LatestRelease"
}
"LTSC2019" "LTSC2019"
{ {
Invoke-Item -Path "$DownloadsFolder\Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease" Invoke-Item -Path "$DownloadsFolder\Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease"

Loading…
Cancel
Save