From e24c3080a2dfc0f702d6987f7dde0fc268223c4e Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sun, 8 Jan 2023 01:07:40 +0300 Subject: [PATCH] small fixes --- .../Module/Sophia.psm1 | 3 +- .../Module/Sophia.psm1 | 21 ++++++------ .../Module/Sophia.psm1 | 32 ++++++++++--------- .../Module/Sophia.psm1 | 31 ++++++++++-------- .../Localizations/en-US/Sophia.psd1 | 4 +-- .../Localizations/ru-RU/Sophia.psd1 | 3 +- .../Module/Sophia.psm1 | 1 + .../Module/Sophia.psm1 | 2 ++ 8 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index c73e3c2b..7daac37f 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -275,7 +275,6 @@ function Checks } } - # Checking services try { @@ -317,7 +316,7 @@ function Checks $Script:DefenderproductState = $false } - # Specifies whether Antispyware protection is enabled + # Specify whether Antispyware protection is enabled if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG") { if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled) diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index 64c31ca6..082cbd24 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -69,10 +69,10 @@ function Checks { $true { - # Check whether the OS minor build version is 3770 minimum - # https://docs.microsoft.com/en-us/windows/release-health/release-information if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 3770) { + # Check whether the OS minor build version is 3770 minimum + # https://docs.microsoft.com/en-us/windows/release-health/release-information $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR Write-Warning -Message ($Localization.UpdateWarning -f $Version) @@ -258,14 +258,9 @@ function Checks # Provider Load Failure exception Write-Warning -Message $Global:Error.Exception.Message | Select-Object -First 1 Write-Warning -Message $Localization.WindowsBroken - Start-Process -FilePath "https://t.me/sophia_chat" - exit - } - if ($null -eq (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Ignore)) - { - $Localization.WindowsBroken Start-Process -FilePath "https://t.me/sophia_chat" + exit } @@ -282,6 +277,13 @@ function Checks } $Script:DefenderServices = ($Services | Where-Object -FilterScript {$_.Status -ne "running"} | Measure-Object).Count -lt $Services.Count + if ($null -eq (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Ignore)) + { + $Localization.WindowsBroken + Start-Process -FilePath "https://t.me/sophia_chat" + exit + } + # Check Microsoft Defender state $productState = (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName Antivirusproduct | Where-Object -FilterScript {$_.instanceGuid -eq "{D68DDC3A-831F-4fae-9E44-DA132C1ACF46}"}).productState $DefenderState = ('0x{0:x}' -f $productState).Substring(3, 2) @@ -294,7 +296,7 @@ function Checks $Script:DefenderproductState = $false } - # Specifies whether Antispyware protection is enabled + # Specify whether Antispyware protection is enabled if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled) { $Script:DefenderAntispywareEnabled = $true @@ -10114,6 +10116,7 @@ function UpdateLGPEPolicies { return } + Get-Partition | Where-Object -FilterScript{$_. DriveLetter -eq "C"} | Get-Disk | Get-PhysicalDisk | ForEach-Object -Process { Write-Verbose -Message ([string]($_.FriendlyName, '|', $_.MediaType, '|', $_.BusType)) -Verbose } diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index 0d22f4d5..633a2ba1 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -258,11 +258,25 @@ function Checks # Provider Load Failure exception Write-Warning -Message $Global:Error.Exception.Message | Select-Object -First 1 Write-Warning -Message $Localization.WindowsBroken + Start-Process -FilePath "https://t.me/sophia_chat" + exit } - # Check Microsoft Defender state + # Checking services + try + { + $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop + } + catch [Microsoft.PowerShell.Commands.ServiceCommandException] + { + $Localization.WindowsBroken + Start-Process -FilePath "https://t.me/sophia_chat" + exit + } + $Script:DefenderServices = ($Services | Where-Object -FilterScript {$_.Status -ne "running"} | Measure-Object).Count -lt $Services.Count + if ($null -eq (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Ignore)) { $Localization.WindowsBroken @@ -270,6 +284,7 @@ function Checks exit } + # Check Microsoft Defender state $productState = (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName Antivirusproduct | Where-Object -FilterScript {$_.instanceGuid -eq "{D68DDC3A-831F-4fae-9E44-DA132C1ACF46}"}).productState $DefenderState = ('0x{0:x}' -f $productState).Substring(3, 2) if ($DefenderState -notmatch "00|01") @@ -281,20 +296,7 @@ function Checks $Script:DefenderproductState = $false } - # Checking services - try - { - $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop - } - catch [Microsoft.PowerShell.Commands.ServiceCommandException] - { - $Localization.WindowsBroken - Start-Process -FilePath "https://t.me/sophia_chat" - exit - } - $Script:DefenderServices = ($Services | Where-Object -FilterScript {$_.Status -ne "running"} | Measure-Object).Count -lt $Services.Count - - # Specifies whether Antispyware protection is enabled + # Specify whether Antispyware protection is enabled if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled) { $Script:DefenderAntispywareEnabled = $true diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index e9e4d706..a343a054 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -87,6 +87,9 @@ function Checks Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod # Open the "Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate" + + # Check for updates Start-Process -FilePath "ms-settings:windowsupdate-action" Start-Sleep -Seconds 1 @@ -272,6 +275,19 @@ function Checks } } + # Checking services + try + { + $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop + } + catch [Microsoft.PowerShell.Commands.ServiceCommandException] + { + $Localization.WindowsBroken + Start-Process -FilePath "https://t.me/sophia_chat" + exit + } + $Script:DefenderServices = ($Services | Where-Object -FilterScript {$_.Status -ne "running"} | Measure-Object).Count -lt $Services.Count + # Check Microsoft Defender state # The Enterprise G edition doesn't has a built-in Defender if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG") @@ -300,20 +316,7 @@ function Checks $Script:DefenderproductState = $false } - # Checking services - try - { - $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop - } - catch [Microsoft.PowerShell.Commands.ServiceCommandException] - { - $Localization.WindowsBroken - Start-Process -FilePath "https://t.me/sophia_chat" - exit - } - $Script:DefenderServices = ($Services | Where-Object -FilterScript {$_.Status -ne "running"} | Measure-Object).Count -lt $Services.Count - - # Specifies whether Antispyware protection is enabled + # Specify whether Antispyware protection is enabled if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG") { if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled) diff --git a/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 index ca1ed792..ef3e8cb4 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 @@ -1,6 +1,6 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBuild = The script supports Windows 11 21H2 version and higher -UpdateWarning = Your Windows 11 build: {0}.{1}. Supported builds: 22000.1335, 22621.963 and higher +UpdateWarning = Your Windows 11 build: {0}.{1}. Supported builds: 22000.1335, 22621.963 and higher. Run Windows Update and try again UnsupportedLanguageMode = The PowerShell session in running in a limited language mode LoggedInUserNotAdmin = The logged-on user doesn't have admin rights UnsupportedPowerShell = You're trying to run script via PowerShell {0}.{1}. Run the script in the appropriate PowerShell version @@ -13,7 +13,7 @@ RebootPending = The PC is waiting to be restarted UnsupportedRelease = A new version found CustomizationWarning = \nHave you customized every function in the {0} preset file before running Sophia Script? WindowsBroken = Some Windows components may have been broken -UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update +UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again ControlledFolderAccessDisabled = Controlled folder access disabled ScheduledTasks = Scheduled tasks OneDriveUninstalling = Uninstalling OneDrive... diff --git a/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 index bac93827..60852455 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 @@ -1,6 +1,6 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBuild = Скрипт поддерживает только Windows 11 21H2 и выше -UpdateWarning = Ваш билд Windows 11: {0}.{1}. Поддерживаемые сборки: 22000.1335, 22621.963 и выше +UpdateWarning = Ваш билд Windows 11: {0}.{1}. Поддерживаемые сборки: 22000.1335, 22621.963 и выше. Запустите обновление Windows и попробуйте заново UnsupportedLanguageMode = Сессия PowerShell работает в ограниченном режиме LoggedInUserNotAdmin = Текущий вошедший пользователь не обладает правами администратора UnsupportedPowerShell = Вы пытаетесь запустить скрипт в PowerShell {0}.{1}. Запустите скрипт в соответствующей версии PowerShell @@ -13,6 +13,7 @@ RebootPending = Компьютер ожидает п UnsupportedRelease = Обнаружена новая версия CustomizationWarning = \nВы настроили все функции в пресет-файле {0} перед запуском Sophia Script? WindowsBroken = Некоторые компоненты Windows могли быть повреждены +UpdateDefender = Определения Microsoft Defender устарели. Запустите обновление Windows ControlledFolderAccessDisabled = Контролируемый доступ к папкам выключен ScheduledTasks = Запланированные задания OneDriveUninstalling = Удаление OneDrive... diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index d9cbd167..2d3aa10e 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -295,6 +295,7 @@ function Checks exit } + # Check Microsoft Defender state if ($null -eq (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Ignore)) { $Localization.WindowsBroken diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index 934a4d2a..cc4ef67c 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -487,6 +487,8 @@ function Checks Start-Sleep -Seconds 5 Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + exit } "1"