diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Functions.ps1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Functions.ps1 index 18150ead..72633c96 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Functions.ps1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.3.2 - Date: 16.07.2022 + Version: v5.3.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -54,7 +54,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.3.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.3.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Manifest/Sophia.psd1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Manifest/Sophia.psd1 index 3b5940a5..3548a0d4 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Manifest/Sophia.psd1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.3.2' + ModuleVersion = '5.3.3' GUID = 'a36a65ca-70f9-43df-856c-3048fc5e7f01' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved' diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Module/Sophia.psm1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Module/Sophia.psm1 index 0378dc4e..ec5ee2bf 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Module/Sophia.psm1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.3.2 - Date: 16.07.2022 + Version: v5.3.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -74,51 +74,40 @@ function Checkings { Write-Warning -Message $Localization.UnsupportedOSBuild - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" exit } - } - - # Check whether the OS minor build version is 3046 minimum - # https://docs.microsoft.com/en-us/windows/release-health/release-information - # https://support.microsoft.com/en-us/topic/windows-10-and-windows-server-2019-update-history-725fc2e1-4443-6831-a5ca-51ff5cbcb059 - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 3046) - { - $false + $true { - $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR - Write-Warning -Message ($Localization.UpdateWarning -f $Version) + if (-not ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 3046)) + { + # Check whether the OS minor build version is 3046 minimum + # https://docs.microsoft.com/en-us/windows/release-health/release-information + # https://support.microsoft.com/en-us/topic/windows-10-and-windows-server-2019-update-history-725fc2e1-4443-6831-a5ca-51ff5cbcb059 + $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR + Write-Warning -Message ($Localization.UpdateWarning -f $Version) - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") + Start-Process -FilePath "https://t.me/sophia_chat" - Start-Sleep -Seconds 1 + # Enable receiving updates for other Microsoft products when you update Windows + (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" + Start-Sleep -Seconds 1 - Start-Sleep -Seconds 1 + # Check for UWP apps updates + Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() + # Open the "Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate-action" - Start-Process -FilePath "https://t.me/sophia_chat" + Start-Sleep -Seconds 1 - exit + # Trigger Windows Update for detecting new updates + (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() + + exit + } } } @@ -292,6 +281,7 @@ function Checkings catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception + $Localization.DefenderBroken $Global:Error.Exception[-1] Start-Process -FilePath "https://t.me/sophia_chat" @@ -319,7 +309,7 @@ function Checkings } else { - if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") + if ((Get-Service -Name $_).Status -eq "running") { $Script:DefenderServices = $true } @@ -9453,9 +9443,7 @@ function MultipleInvokeContext #> function UpdateLGPEPolicies { - if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript { - ($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*") -or ($_.Edition -eq "Education") - })) + if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } @@ -9482,9 +9470,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_LOCAL_MACHINE\", "HKLM:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { @@ -9530,9 +9521,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_CURRENT_USER\", "HKCU:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Sophia.ps1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Sophia.ps1 index 7418095c..459f90a9 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Sophia.ps1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2019/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10 LTSC 2019" - Version: v5.3.2 - Date: 16.07.2022 + Version: v5.3.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -71,7 +71,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.3.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.3.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Functions.ps1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Functions.ps1 index abea68a4..5f5dc239 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Functions.ps1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -54,7 +54,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.13.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.13.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Manifest/Sophia.psd1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Manifest/Sophia.psd1 index a762e994..0cd5ac2d 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Manifest/Sophia.psd1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.13.2' + ModuleVersion = '5.13.3' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved' diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Module/Sophia.psm1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Module/Sophia.psm1 index 0190c70e..72f048e6 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Module/Sophia.psm1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -74,51 +74,40 @@ function Checkings { Write-Warning -Message $Localization.UnsupportedOSBuild - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" exit } - } - - # Check whether the OS minor build version is 1766 minimum - # https://docs.microsoft.com/en-us/windows/release-health/release-information - # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014699-os-builds-19042-1766-19043-1766-and-19044-1766-5c81d49d-0b6e-4808-9485-1f54e5d1bb15 - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1766) - { - $false + $true { - $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR - Write-Warning -Message ($Localization.UpdateWarning -f $Version) + # Check whether the OS minor build version is 1766 minimum + # https://docs.microsoft.com/en-us/windows/release-health/release-information + # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014699-os-builds-19042-1766-19043-1766-and-19044-1766-5c81d49d-0b6e-4808-9485-1f54e5d1bb15 + if (-not ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1766)) + { + $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR + Write-Warning -Message ($Localization.UpdateWarning -f $Version) - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") + Start-Process -FilePath "https://t.me/sophia_chat" - Start-Sleep -Seconds 1 + # Enable receiving updates for other Microsoft products when you update Windows + (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" + Start-Sleep -Seconds 1 - Start-Sleep -Seconds 1 + # Check for UWP apps updates + Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() + # Open the "Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate-action" - Start-Process -FilePath "https://t.me/sophia_chat" + Start-Sleep -Seconds 1 - exit + # Trigger Windows Update for detecting new updates + (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() + + exit + } } } @@ -292,6 +281,7 @@ function Checkings catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception + $Localization.DefenderBroken $Global:Error.Exception[-1] Start-Process -FilePath "https://t.me/sophia_chat" @@ -319,7 +309,7 @@ function Checkings } else { - if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") + if ((Get-Service -Name $_).Status -eq "running") { $Script:DefenderServices = $true } @@ -8980,14 +8970,14 @@ function NetworkProtection { "Enable" { - if ((Get-MpComputerStatus).AntivirusEnabled) + if ($Script:DefenderEnabled) { Set-MpPreference -EnableNetworkProtection Enabled } } "Disable" { - if ((Get-MpComputerStatus).AntivirusEnabled) + if ($Script:DefenderEnabled) { Set-MpPreference -EnableNetworkProtection Disabled } @@ -10610,9 +10600,7 @@ function MultipleInvokeContext #> function UpdateLGPEPolicies { - if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript { - ($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*") -or ($_.Edition -eq "Education") - })) + if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } @@ -10639,9 +10627,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_LOCAL_MACHINE\", "HKLM:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { @@ -10687,9 +10678,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_CURRENT_USER\", "HKCU:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { diff --git a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Sophia.ps1 b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Sophia.ps1 index 3742c20d..158ea745 100644 --- a/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Sophia.ps1 +++ b/Sophia Script/Sophia Script for Windows 10 LTSC 2021/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10 LTSC 2021" - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -71,7 +71,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.13.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.13.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Functions.ps1 b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Functions.ps1 index 62d70da0..0e2a72f4 100644 --- a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Functions.ps1 +++ b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -54,7 +54,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.2 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.3 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Manifest/Sophia.psd1 b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Manifest/Sophia.psd1 index 60336a57..2115e316 100644 --- a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Manifest/Sophia.psd1 +++ b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.13.2' + ModuleVersion = '5.13.3' GUID = 'aa0b47a7-1770-4b5d-8c9f-cc6c505bcc7a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved' diff --git a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Module/Sophia.psm1 b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Module/Sophia.psm1 index ecf21db5..d5b10a1c 100644 --- a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Module/Sophia.psm1 +++ b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -74,57 +74,40 @@ function Checkings { Write-Warning -Message $Localization.UnsupportedOSBuild - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Check for UWP apps updates - 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-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" exit } - } - - # Check whether the OS minor build version is 1766 minimum - # https://docs.microsoft.com/en-us/windows/release-health/release-information - # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014699-os-builds-19042-1766-19043-1766-and-19044-1766-5c81d49d-0b6e-4808-9485-1f54e5d1bb15 - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1766) - { - $false + $true { - $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR - Write-Warning -Message ($Localization.UpdateWarning -f $Version) + if (-not ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1766)) + { + # Check whether the OS minor build version is 1766 minimum + # https://docs.microsoft.com/en-us/windows/release-health/release-information + # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014699-os-builds-19042-1766-19043-1766-and-19044-1766-5c81d49d-0b6e-4808-9485-1f54e5d1bb15 + $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR + Write-Warning -Message ($Localization.UpdateWarning -f $Version) - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") + Start-Process -FilePath "https://t.me/sophia_chat" - Start-Sleep -Seconds 1 + # Enable receiving updates for other Microsoft products when you update Windows + (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - # Check for UWP apps updates - Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod + Start-Sleep -Seconds 1 - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" + # Check for UWP apps updates + Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod - Start-Sleep -Seconds 1 + # Open the "Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate-action" - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() + Start-Sleep -Seconds 1 - Start-Process -FilePath "https://t.me/sophia_chat" + # Trigger Windows Update for detecting new updates + (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - exit + exit + } } } @@ -300,6 +283,7 @@ function Checkings catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception + $Localization.DefenderBroken $Global:Error.Exception[-1] Start-Process -FilePath "https://t.me/sophia_chat" @@ -327,7 +311,7 @@ function Checkings } else { - if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") + if ((Get-Service -Name $_).Status -eq "running") { $Script:DefenderServices = $true } @@ -494,16 +478,12 @@ function CreateRestorePoint $SystemDriveUniqueID = (Get-Volume | Where-Object -FilterScript {$_.DriveLetter -eq "$($env:SystemDrive[0])"}).UniqueID $SystemProtection = ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients" -ErrorAction Ignore)."{09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}") | Where-Object -FilterScript {$_ -match [regex]::Escape($SystemDriveUniqueID)} - $ComputerRestorePoint = $false - - switch ($null -eq $SystemProtection) - { - $true - { - $ComputerRestorePoint = $true + $Script:ComputerRestorePoint = $false + $SystemProtection ?? (& { + $Script:ComputerRestorePoint = $true Enable-ComputerRestore -Drive $env:SystemDrive } - } + ) # Never skip creating a restore point New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 0 -Force @@ -514,7 +494,7 @@ function CreateRestorePoint New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 1440 -Force # Turn off System Protection for the system drive if it was turned off before without deleting the existing restore points - if ($ComputerRestorePoint) + if ($Script:ComputerRestorePoint) { Disable-ComputerRestore -Drive $env:SystemDrive } @@ -10506,7 +10486,7 @@ function CheckUWPAppsUpdates XboxGameBar -Enable .NOTES - To prevent popping up the "You'll need a new app to open this `ms-gamingoverlay`" warning, you need to disable the `Xbox Game Bar` app, even if you uninstalled it before. + To prevent popping up the "You'll need a new app to open this ms-gamingoverlay" warning, you need to disable the `Xbox Game Bar` app, even if you uninstalled it before. .NOTES Current user @@ -13041,9 +13021,7 @@ function UseStoreOpenWith #> function UpdateLGPEPolicies { - if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript { - ($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*") -or ($_.Edition -eq "Education") - })) + if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } @@ -13070,9 +13048,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_LOCAL_MACHINE\", "HKLM:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { @@ -13118,9 +13099,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_CURRENT_USER\", "HKCU:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { diff --git a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Sophia.ps1 b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Sophia.ps1 index ed019082..0c77eb3f 100644 --- a/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Sophia.ps1 +++ b/Sophia Script/Sophia Script for Windows 10 PowerShell 7/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10 (PowerShell 7)" - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -71,7 +71,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.2 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.3 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10/Functions.ps1 b/Sophia Script/Sophia Script for Windows 10/Functions.ps1 index 66af35b1..005b02bc 100644 --- a/Sophia Script/Sophia Script for Windows 10/Functions.ps1 +++ b/Sophia Script/Sophia Script for Windows 10/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -54,7 +54,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 10/Manifest/Sophia.psd1 b/Sophia Script/Sophia Script for Windows 10/Manifest/Sophia.psd1 index 8ce537ca..d941c9c4 100644 --- a/Sophia Script/Sophia Script for Windows 10/Manifest/Sophia.psd1 +++ b/Sophia Script/Sophia Script for Windows 10/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.13.2' + ModuleVersion = '5.13.3' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved' diff --git a/Sophia Script/Sophia Script for Windows 10/Module/Sophia.psm1 b/Sophia Script/Sophia Script for Windows 10/Module/Sophia.psm1 index 9cd5c9a6..5a5b0731 100644 --- a/Sophia Script/Sophia Script for Windows 10/Module/Sophia.psm1 +++ b/Sophia Script/Sophia Script for Windows 10/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -74,57 +74,40 @@ function Checkings { Write-Warning -Message $Localization.UnsupportedOSBuild - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Check for UWP apps updates - 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-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" exit } - } - - # Check whether the OS minor build version is 1766 minimum - # https://docs.microsoft.com/en-us/windows/release-health/release-information - # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014699-os-builds-19042-1766-19043-1766-and-19044-1766-5c81d49d-0b6e-4808-9485-1f54e5d1bb15 - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1766) - { - $false + $true { - $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR - Write-Warning -Message ($Localization.UpdateWarning -f $Version) + # Check whether the OS minor build version is 1766 minimum + # https://docs.microsoft.com/en-us/windows/release-health/release-information + # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014699-os-builds-19042-1766-19043-1766-and-19044-1766-5c81d49d-0b6e-4808-9485-1f54e5d1bb15 + if (-not ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1766)) + { + $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR + Write-Warning -Message ($Localization.UpdateWarning -f $Version) - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") + Start-Process -FilePath "https://t.me/sophia_chat" - Start-Sleep -Seconds 1 + # Enable receiving updates for other Microsoft products when you update Windows + (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - # Check for UWP apps updates - Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod + Start-Sleep -Seconds 1 - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" + # Check for UWP apps updates + Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod - Start-Sleep -Seconds 1 + # Open the "Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate-action" - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() + Start-Sleep -Seconds 1 - Start-Process -FilePath "https://t.me/sophia_chat" + # Trigger Windows Update for detecting new updates + (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - exit + exit + } } } @@ -298,6 +281,7 @@ function Checkings catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception + $Localization.DefenderBroken $Global:Error.Exception[-1] Start-Process -FilePath "https://t.me/sophia_chat" @@ -325,7 +309,7 @@ function Checkings } else { - if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") + if ((Get-Service -Name $_).Status -eq "running") { $Script:DefenderServices = $true } @@ -10465,7 +10449,7 @@ function CheckUWPAppsUpdates XboxGameBar -Enable .NOTES - To prevent popping up the "You'll need a new app to open this `ms-gamingoverlay`" warning, you need to disable the `Xbox Game Bar` app, even if you uninstalled it before. + To prevent popping up the "You'll need a new app to open this ms-gamingoverlay" warning, you need to disable the `Xbox Game Bar` app, even if you uninstalled it before. .NOTES Current user @@ -12998,9 +12982,7 @@ function UseStoreOpenWith #> function UpdateLGPEPolicies { - if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript { - ($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*") -or ($_.Edition -eq "Education") - })) + if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } @@ -13027,9 +13009,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_LOCAL_MACHINE\", "HKLM:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { @@ -13075,9 +13060,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_CURRENT_USER\", "HKCU:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { diff --git a/Sophia Script/Sophia Script for Windows 10/Sophia.ps1 b/Sophia Script/Sophia Script for Windows 10/Sophia.ps1 index 59fb3fa3..dd9fa976 100644 --- a/Sophia Script/Sophia Script for Windows 10/Sophia.ps1 +++ b/Sophia Script/Sophia Script for Windows 10/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10" - Version: v5.13.2 - Date: 16.07.2022 + Version: v5.13.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -71,7 +71,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.13.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Functions.ps1 b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Functions.ps1 index 5404acd5..67372e80 100644 --- a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Functions.ps1 +++ b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v6.1.2 - Date: 16.07.2022 + Version: v6.1.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -54,7 +54,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Manifest/Sophia.psd1 b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Manifest/Sophia.psd1 index 7f60aba0..f9d28a7c 100644 --- a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Manifest/Sophia.psd1 +++ b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '6.1.2' + ModuleVersion = '6.1.3' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved' diff --git a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Module/Sophia.psm1 b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Module/Sophia.psm1 index b7f0d9cf..e3ad4c88 100644 --- a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Module/Sophia.psm1 +++ b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v6.1.2 - Date: 16.07.2022 + Version: v6.1.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -63,40 +63,22 @@ function Checkings { Write-Warning -Message $Localization.UnsupportedOSBuild - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Check for UWP apps updates - 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-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" exit } - } - - # Check whether the OS minor build version is 739 minimum - # https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information - # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014697-os-build-22000-739-cd3aaa0b-a8da-44a0-a778-dfb6f1d9ea11 - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 739) - { - $false + $true { - if ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber -eq 22000) + # Check whether the OS minor build version is 739 minimum + # https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information + # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014697-os-build-22000-739-cd3aaa0b-a8da-44a0-a778-dfb6f1d9ea11 + if (-not ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 739)) { $Version = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" Write-Warning -Message ($Localization.UpdateWarning -f $Version.CurrentBuild, $Version.UBR) + Start-Process -FilePath "https://t.me/sophia_chat" + # Enable receiving updates for other Microsoft products when you update Windows (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") @@ -113,8 +95,6 @@ function Checkings # Trigger Windows Update for detecting new updates (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" - exit } } @@ -293,6 +273,7 @@ function Checkings catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception + $Localization.DefenderBroken $Global:Error.Exception[-1] Start-Process -FilePath "https://t.me/sophia_chat" @@ -320,7 +301,7 @@ function Checkings } else { - if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") + if ((Get-Service -Name $_).Status -eq "running") { $Script:DefenderServices = $true } @@ -487,16 +468,12 @@ function CreateRestorePoint $SystemDriveUniqueID = (Get-Volume | Where-Object -FilterScript {$_.DriveLetter -eq "$($env:SystemDrive[0])"}).UniqueID $SystemProtection = ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients" -ErrorAction Ignore)."{09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}") | Where-Object -FilterScript {$_ -match [regex]::Escape($SystemDriveUniqueID)} - $ComputerRestorePoint = $false - - switch ($null -eq $SystemProtection) - { - $true - { - $ComputerRestorePoint = $true + $Script:ComputerRestorePoint = $false + $SystemProtection ?? (& { + $Script:ComputerRestorePoint = $true Enable-ComputerRestore -Drive $env:SystemDrive } - } + ) # Never skip creating a restore point New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 0 -Force @@ -507,7 +484,7 @@ function CreateRestorePoint New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 1440 -Force # Turn off System Protection for the system drive if it was turned off before without deleting the existing restore points - if ($ComputerRestorePoint) + if ($Script:ComputerRestorePoint) { Disable-ComputerRestore -Drive $env:SystemDrive } @@ -12463,9 +12440,7 @@ function Windows10ContextMenu #> function UpdateLGPEPolicies { - if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript { - ($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*") -or ($_.Edition -eq "Education") - })) + if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } @@ -12492,9 +12467,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_LOCAL_MACHINE\", "HKLM:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { @@ -12540,9 +12518,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_CURRENT_USER\", "HKCU:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { diff --git a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Sophia.ps1 b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Sophia.ps1 index 4ce9d42b..d0ddff2f 100644 --- a/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Sophia.ps1 +++ b/Sophia Script/Sophia Script for Windows 11 PowerShell 7/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 11 (PowerShell 7)" - Version: v6.1.2 - Date: 16.07.2022 + Version: v6.1.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -70,7 +70,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.2 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.3 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 11/Functions.ps1 b/Sophia Script/Sophia Script for Windows 11/Functions.ps1 index aff8300c..34d9d5b0 100644 --- a/Sophia Script/Sophia Script for Windows 11/Functions.ps1 +++ b/Sophia Script/Sophia Script for Windows 11/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v6.1.2 - Date: 16.07.2022 + Version: v6.1.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -54,7 +54,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Sophia Script/Sophia Script for Windows 11/Manifest/Sophia.psd1 b/Sophia Script/Sophia Script for Windows 11/Manifest/Sophia.psd1 index 4eea6040..2a6f96bb 100644 --- a/Sophia Script/Sophia Script for Windows 11/Manifest/Sophia.psd1 +++ b/Sophia Script/Sophia Script for Windows 11/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '6.1.2' + ModuleVersion = '6.1.3' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved' diff --git a/Sophia Script/Sophia Script for Windows 11/Module/Sophia.psm1 b/Sophia Script/Sophia Script for Windows 11/Module/Sophia.psm1 index 0d38175a..0e5ec560 100644 --- a/Sophia Script/Sophia Script for Windows 11/Module/Sophia.psm1 +++ b/Sophia Script/Sophia Script for Windows 11/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v6.1.2 - Date: 16.07.2022 + Version: v6.1.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -63,40 +63,22 @@ function Checkings { Write-Warning -Message $Localization.UnsupportedOSBuild - # Enable receiving updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Check for UWP apps updates - 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-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" exit } - } - - # Check whether the OS minor build version is 739 minimum - # https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information - # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014697-os-build-22000-739-cd3aaa0b-a8da-44a0-a778-dfb6f1d9ea11 - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 739) - { - $false + $true { - if ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber -eq 22000) + # Check whether the OS minor build version is 739 minimum + # https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information + # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014697-os-build-22000-739-cd3aaa0b-a8da-44a0-a778-dfb6f1d9ea11 + if (-not ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 739)) { $Version = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" Write-Warning -Message ($Localization.UpdateWarning -f $Version.CurrentBuild, $Version.UBR) + Start-Process -FilePath "https://t.me/sophia_chat" + # Enable receiving updates for other Microsoft products when you update Windows (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") @@ -113,8 +95,6 @@ function Checkings # Trigger Windows Update for detecting new updates (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - Start-Process -FilePath "https://t.me/sophia_chat" - exit } } @@ -291,6 +271,7 @@ function Checkings catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception + $Localization.DefenderBroken $Global:Error.Exception[-1] Start-Process -FilePath "https://t.me/sophia_chat" @@ -318,7 +299,7 @@ function Checkings } else { - if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") + if ((Get-Service -Name $_).Status -eq "running") { $Script:DefenderServices = $true } @@ -12422,9 +12403,7 @@ function Windows10ContextMenu #> function UpdateLGPEPolicies { - if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript { - ($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*") -or ($_.Edition -eq "Education") - })) + if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } @@ -12451,9 +12430,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_LOCAL_MACHINE\", "HKLM:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { @@ -12499,9 +12481,12 @@ function UpdateLGPEPolicies [xml]$config = Get-Content -Path $admx.FullName -Encoding UTF8 $SplitPath = Split-Path -Path $Path.Name.Replace("HKEY_CURRENT_USER\", "HKCU:") -NoQualifier - if ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + if (($config.policyDefinitions.policies.policy | Where-Object -FilterScript { ($_.key -eq $SplitPath) -and ($_.valueName -eq $Item) -or (($_.key -eq $SplitPath) -and ($_.Name -eq $Item)) - }) + }) -or + ($config.policyDefinitions.policies.policy | Where-Object -FilterScript { + ($_.key -eq $SplitPath) + } | Where-Object -FilterScript {$_.elements.enum.valueName -eq $Item})) { try { diff --git a/Sophia Script/Sophia Script for Windows 11/Sophia.ps1 b/Sophia Script/Sophia Script for Windows 11/Sophia.ps1 index bce8e191..4af0d2c2 100644 --- a/Sophia Script/Sophia Script for Windows 11/Sophia.ps1 +++ b/Sophia Script/Sophia Script for Windows 11/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 11" - Version: v6.1.2 - Date: 16.07.2022 + Version: v6.1.3 + Date: 26.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 farag & Inestic @@ -70,7 +70,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.1.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force diff --git a/Wrapper/SophiaScriptWrapper.exe b/Wrapper/SophiaScriptWrapper.exe index 3682d25e..8793106a 100644 Binary files a/Wrapper/SophiaScriptWrapper.exe and b/Wrapper/SophiaScriptWrapper.exe differ