Browse Source

Update scripts to download Sophia Script

pull/694/head
Dmitry Nefedov 4 months ago
parent
commit
023f9ec658
  1. 56
      Download_Latest_Sophia.ps1
  2. 38
      Download_Sophia.ps1

56
Download_Latest_Sophia.ps1

@ -8,27 +8,12 @@
.EXAMPLE .EXAMPLE
iwr sl.sophia.team -useb | iex iwr sl.sophia.team -useb | iex
#> #>
Clear-Host Clear-Host
$Global:Error.Clear()
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Checking whether the logged-in user is an admin
$CurrentUserName = (Get-CimInstance -ClassName Win32_Process -Filter ProcessId=$PID | Invoke-CimMethod -MethodName GetOwner | Select-Object -First 1).User
$LoginUserName = (Get-CimInstance -ClassName Win32_Process -Filter "name='explorer.exe'" | Invoke-CimMethod -MethodName GetOwner | Select-Object -First 1).User
if ($CurrentUserName -ne $LoginUserName)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message "The logged-on user doesn't have admin rights."
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
pause
exit
}
if ($Host.Version.Major -eq 5) if ($Host.Version.Major -eq 5)
{ {
# Progress bar can significantly impact cmdlet performance # Progress bar can significantly impact cmdlet performance
@ -42,6 +27,9 @@ $Script:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollecti
$Script:CompilerParameters.GenerateInMemory = $true $Script:CompilerParameters.GenerateInMemory = $true
$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}"
try
{
$Parameters = @{ $Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/archive/refs/heads/master.zip" Uri = "https://github.com/farag2/Sophia-Script-for-Windows/archive/refs/heads/master.zip"
OutFile = "$DownloadsFolder\master.zip" OutFile = "$DownloadsFolder\master.zip"
@ -49,6 +37,25 @@ $Parameters = @{
Verbose = $true Verbose = $true
} }
Invoke-RestMethod @Parameters Invoke-RestMethod @Parameters
}
catch [System.Net.WebException]
{
Write-Warning -Message "github.com is unreachable. Please fix connection or change your DNS records."
Write-Information -MessageData "" -InformationAction Continue
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
$DNS = (Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses
}
else
{
$DNS = (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses ###
}
Write-Warning -Message "You're using DNS $(if ($DNS.Count -gt 1) {$DNS -join ', '} else {$DNS})"
pause
exit
}
switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
{ {
@ -58,7 +65,6 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2019") if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2019")
{ {
$Version = "Sophia_Script_for_Windows_10_LTSC_2019" $Version = "Sophia_Script_for_Windows_10_LTSC_2019"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
else else
{ {
@ -68,7 +74,7 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open the "Windows Update" page # Open the "Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"
@ -83,7 +89,6 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2021") if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -match "LTSC 2021")
{ {
$Version = "Sophia_Script_for_Windows_10_LTSC_2021" $Version = "Sophia_Script_for_Windows_10_LTSC_2021"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
else else
{ {
@ -93,7 +98,7 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open the "Windows Update" page # Open the "Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"
@ -107,12 +112,10 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
if ($Host.Version.Major -eq 5) if ($Host.Version.Major -eq 5)
{ {
$Version = "Sophia_Script_for_Windows_10" $Version = "Sophia_Script_for_Windows_10"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
else else
{ {
$Version = "Sophia_Script_for_Windows_10_PowerShell_7" $Version = "Sophia_Script_for_Windows_10_PowerShell_7"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 PowerShell 7 | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
} }
{$_ -ge 26100} {$_ -ge 26100}
@ -125,12 +128,10 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
if ((Get-CimInstance -ClassName CIM_Processor).Caption -match "ARM") if ((Get-CimInstance -ClassName CIM_Processor).Caption -match "ARM")
{ {
$Version = "Sophia_Script_for_Windows_11_ARM" $Version = "Sophia_Script_for_Windows_11_ARM"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 (Arm) | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
else else
{ {
$Version = "Sophia_Script_for_Windows_11" $Version = "Sophia_Script_for_Windows_11"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
} }
else else
@ -138,19 +139,16 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
if ((Get-CimInstance -ClassName CIM_Processor).Caption -match "ARM") if ((Get-CimInstance -ClassName CIM_Processor).Caption -match "ARM")
{ {
$Version = "Sophia_Script_for_Windows_11_ARM_PowerShell_7" $Version = "Sophia_Script_for_Windows_11_ARM_PowerShell_7"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 (Arm | PowerShell 7) | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
else else
{ {
$Version = "Sophia_Script_for_Windows_11_PowerShell_7" $Version = "Sophia_Script_for_Windows_11_PowerShell_7"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 (PowerShell) | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
} }
} }
else else
{ {
$Version = "Sophia_Script_for_Windows_11_LTSC_2024" $Version = "Sophia_Script_for_Windows_11_LTSC_2024"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 LTSC 2024 | Latest | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag, Inestic & lowl1f3, 2014$([System.Char]0x2013)2025"
} }
} }
} }
@ -184,7 +182,7 @@ catch
Write-Verbose -Message "Archive cannot be expanded. Probably, this was caused by your antivirus. Please update its definitions and try again." -Verbose Write-Verbose -Message "Archive cannot be expanded. Probably, this was caused by your antivirus. Please update its definitions and try again." -Verbose
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open t"Windows Update" page # Open t"Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"

38
Download_Sophia.ps1

@ -10,26 +10,10 @@
#> #>
Clear-Host Clear-Host
$Global:Error.Clear()
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Checking whether the logged-in user is an admin
$CurrentUserName = (Get-CimInstance -ClassName Win32_Process -Filter ProcessId=$PID | Invoke-CimMethod -MethodName GetOwner | Select-Object -First 1).User
$LoginUserName = (Get-CimInstance -ClassName Win32_Process -Filter "name='explorer.exe'" | Invoke-CimMethod -MethodName GetOwner | Select-Object -First 1).User
if ($CurrentUserName -ne $LoginUserName)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message "The logged-on user doesn't have admin rights."
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
pause
exit
}
if ($Host.Version.Major -eq 5) if ($Host.Version.Major -eq 5)
{ {
# Progress bar can significantly impact cmdlet performance # Progress bar can significantly impact cmdlet performance
@ -42,24 +26,26 @@ $Script:CompilerParameters = [System.CodeDom.Compiler.CompilerP
$Script:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false) $Script:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
$Script:CompilerParameters.GenerateInMemory = $true $Script:CompilerParameters.GenerateInMemory = $true
try
{
$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
}
if (-not $LatestGitHubRelease) catch [System.Net.WebException]
{ {
Write-Warning -Message "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest is unreachable. Please fix connection or change your DNS records." Write-Warning -Message "api.github.com is unreachable. Please fix connection or change your DNS records."
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{ {
$DNS = (Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses $DNS = (Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses
} }
else else
{ {
$DNS = (Get-NetAdapter -Physical | Get-NetIPInterface -AddressFamily IPv4 | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses $DNS = (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses
} }
Write-Warning -Message "You're using DNS $(if ($DNS.Count -gt 1) {$DNS -join ', '} else {$DNS})" Write-Warning -Message "You're using DNS $(if ($DNS.Count -gt 1) {$DNS -join ', '} else {$DNS})"
@ -101,7 +87,7 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open the "Windows Update" page # Open the "Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"
@ -134,7 +120,7 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber)
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open the "Windows Update" page # Open the "Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"
@ -261,7 +247,7 @@ if (-not (Test-Path -Path "$DownloadsFolder\Sophia.Script.zip"))
Write-Verbose -Message "Your Windows build is unsupported. Run Windows Update and try again." -Verbose Write-Verbose -Message "Your Windows build is unsupported. Run Windows Update and try again." -Verbose
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open t"Windows Update" page # Open t"Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"
@ -285,7 +271,7 @@ catch
Write-Verbose -Message "Archive cannot be expanded. Probably, this was caused by your antivirus. Please update its definitions and try again." -Verbose Write-Verbose -Message "Archive cannot be expanded. Probably, this was caused by your antivirus. Please update its definitions and try again." -Verbose
# Check for updates # Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan & "$env:SystemRoot\System32\UsoClient.exe" StartInteractiveScan
# Open t"Windows Update" page # Open t"Windows Update" page
Start-Process -FilePath "ms-settings:windowsupdate" Start-Process -FilePath "ms-settings:windowsupdate"

Loading…
Cancel
Save