Sweetcade/scripts/ps/syscheck.ps1

75 lines
3.9 KiB
PowerShell

Write-Host "---Function Setup---"
function fSCCountTotalMemory
{
Write-Host "---Check Minimum Memory Requirements (8GB)---"
[Math]::Round ( ( Get-WmiObject -Class Win32_ComputerSystem -ComputerName localhost ) .TotalPhysicalMemory/1Mb )
$vSCTotalSystemMemoryMB = [Math]::Round ( ( Get-WmiObject -Class Win32_ComputerSystem -ComputerName localhost ) .TotalPhysicalMemory/1Mb )
if $vSCTotalSystemMemoryMB -lt 7000
then
{
Write-Host "SC-SYS-ERR001: NOT ENOUGH SYSTEM MEMORY"
Write-Host "This system does not have enough RAM to reliably run Sweetcade."
Write-Host "Please upgrade system memory or replace computer to run Sweetcade."
Write-Host "Sweetcade needs a minimum of 8GB of system RAM to run."
Write-Host "If this error has appeared on a system with more than 8GB of RAM please open a issue on Git https://git.sdf.org/camoy/Sweetcade"
Write-Host "This script will now terminate in 60 seconds."
Start-Sleep -Seconds 60
Exit 1
}
else
{
fSCOSVerification
}
}
function fSCOSVerification
{
Write-Host "---Check Windows OS Installation Version (Windows 10 LTSC)---"
(Get-WmiObject -Class Win32_OperatingSystem).Caption
$vSCOSEdition = (Get-WmiObject -Class Win32_OperatingSystem).Caption
if $vSCOSEdition -notlike "*LTSC*"
then
{
Write-Host "SC-SYS-ERR002: INCORRECT OS EDITION"
Write-Host "This system does not have Windows 10 LTSC installed."
Write-Host "Please reinstall Windows 10 with a LTSC build to run Sweetcade."
Write-Host "Sweetcade is only tested on LTSC builds of Windows 10 at this time."
Write-Host "If this error has appeared on a system with LTSC installed please open a issue on Git https://git.sdf.org/camoy/Sweetcade"
Write-Host "This script will now terminate in 60 seconds."
Start-Sleep -Seconds 60
Exit 1
}
else
{
function fSCLicenseKeyCheck
}
}
function fSCLicenseKeyCheck
{
Write-Host "---Check Windows OS License Key---"
Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" -ComputerName RemoteComp | where { $_.PartialProductKey } | select Description, LicenseStatus
$vSCLicensedStatus = (Get-WmiObject -Class Win32_OperatingSystem).Caption
if $vSCLicensedStatus -neq 1
then
{
Write-Host "SC-SYS-ERR003: WINDOWS NOT PERMANENTLY ACTIVATED"
Write-Host "This system does not have a valid permanent activation license."
Write-Host "Please activate your Windows installation in order guarantee Sweetcade reliability."
Write-Host "You may proceed without a permanent activation license, but it is recommended."
Write-Host "If this error has appeared on a system with a valid key installed please open a issue on Git https://git.sdf.org/camoy/Sweetcade"
Write-Host "If you want to [A]ctivate Windows and then have this script check again, connect a keyboard and type A."
Write-Host "If you want to [F]orcefully continue the installation without having the correct licenses, connect a keyboard and type F."
vSCLicensedStatusUserResponse = Read-Host "A / F?"
if ($vSCNextHopUserResponse -contains "F")
{
#PSUDEOCODE - Continue to next script (TODO)
}
else {
function fSCLicenseKeyCheck
}
}
}