@ -67,7 +67,21 @@ function InitialActions
[Net.ServicePointManager] :: SecurityProtocol = [Net.SecurityProtocolType] :: Tls12
# Import PowerShell 5.1 modules
Import-Module -Name Microsoft . PowerShell . Management , PackageManagement , Appx , DISM -UseWindowsPowerShell
try
{
Import-Module -Name Microsoft . PowerShell . Management , PackageManagement , Appx , DISM -UseWindowsPowerShell -Force -ErrorAction Stop
}
catch
{
Write-Information -MessageData " " -InformationAction Continue
Write-Warning -Message $Localization . PowerShellImportFailed
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message " https://t.me/sophia_chat " -Verbose
Write-Verbose -Message " https://discord.gg/sSryhaEv79 " -Verbose
exit
}
# https://github.com/PowerShell/PowerShell/issues/21070
$Script:CompilerOptions = [System.CodeDom.Compiler.CompilerParameters] :: new ( " System.dll " )
@ -509,16 +523,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
# Checking whether WMI is corrupted
try
{
Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root / Microsoft / Windows / Defender -ErrorAction Stop | Out-Null
}
catch [Microsoft.Management.Infrastructure.CimException]
# Check Microsoft Defender state
if ( $null -eq ( Get-CimInstance -ClassName AntiVirusProduct -Namespace root / SecurityCenter2 -ErrorAction Ignore ) )
{
# Provider Load Failure exception
Write-Information -MessageData " " -InformationAction Continue
Write-Warning -Message ( $Global:Error . Exception . Message | Select-Object -First 1 )
Write-Warning -Message ( $Localization . WindowsComponentBroken -f " Microsoft Defender " )
Write-Information -MessageData " " -InformationAction Continue
@ -530,9 +538,21 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
}
# Check Microsoft Defender state
if ( $null -eq ( Ge t-CimInstance -ClassName AntiVi rusProduct -Namespace root / Securit yCenter2 -ErrorAction Ignore ) )
try
{
$productState = ( Get-CimInstance -ClassName AntiVirusProduct -Namespace root / SecurityCenter2 | Where-Object -FilterScript { $_ . instanceGuid -eq " {D68DDC3A-831F-4fae-9E44-DA132C1ACF46} " } ) . productState
$DefenderState = ( '0x{0:x}' -f $productState ) . Substring ( 3 , 2 )
# Defender is a currently used AV. Continue...
if ( $DefenderState -notmatch " 00|01 " )
{
Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root / Microsoft / Windows / Defender -ErrorAction Stop | Out-Null
}
}
catch [Microsoft.Management.Infrastructure.CimException]
{
# Provider Load Failure exception
Write-Information -MessageData " " -InformationAction Continue
Write-Warning -Message ( $Global:Error . Exception . Message | Select-Object -First 1 )
Write-Warning -Message ( $Localization . WindowsComponentBroken -f " Microsoft Defender " )
Write-Information -MessageData " " -InformationAction Continue
@ -567,7 +587,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
try
{
$Script:DefenderMpPreferenceBroken = $false
( Get-MpPreference -ErrorAction Stop ) . EnableControlledFolderAccess
( Get-MpPreference -ErrorAction Stop ) . EnableControlledFolderAccess
}
catch [System.Management.Automation.RemoteException]
{
@ -3074,7 +3094,7 @@ function QuickAccessRecentFiles
# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer , HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Policies \ Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name NoRecentDocsHistory -Type CLEAR
Set-Policy -Scope User -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name NoRecentDocsHistory -Type CLEAR
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name NoRecentDocsHistory -Type CLEAR
switch ( $PSCmdlet . ParameterSetName )
{
@ -4691,14 +4711,14 @@ function StartRecommendedSection
New-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer -Name HideRecommendedSection -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path HKLM : \ SOFTWARE \ Microsoft \ PolicyManager \ current \ device \ Education -Name IsEducationEnvironment -PropertyType DWord -Value 1 -Force
Set-Policy -Scope User -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name HideRecommendedSection -Type DWORD -Value 1
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name HideRecommendedSection -Type DWORD -Value 1
}
" Show "
{
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer -Name HideRecommendedSection -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKLM : \ SOFTWARE \ Microsoft \ PolicyManager \ current \ device \ Education -Name IsEducationEnvironment -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKLM : \ SOFTWARE \ Microsoft \ PolicyManager \ current \ device \ Start -Name HideRecommendedSection -Force -ErrorAction Ignore
Set-Policy -Scope User -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name HideRecommendedSection -Type CLEAR
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name HideRecommendedSection -Type CLEAR
}
}
}
@ -5600,7 +5620,7 @@ function WindowsFeatures
[void] $Window . Close ( )
$SelectedFeatures | ForEach-Object -Process { Write-Verbose -Message $_ . DisplayName -Verbose }
$SelectedFeatures | Enable-WindowsOptionalFeature -Online -NoRestart
$SelectedFeatures | Enable-WindowsOptionalFeature -Online -All - NoRestart
}
function Add-FeatureControl
@ -9117,7 +9137,7 @@ public static long MakeLong(uint left, uint right)
New-ItemProperty -Path " HKCU:\Software\Classes\ $ ProgId\DefaultIcon " -Name " (default) " -PropertyType String -Value $Icon -Force
}
New-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ ApplicationAssociationToasts -Name " $( $ProgID ) _ $( $Extension ) " -Type DWord -Value 0 -Force
New-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ ApplicationAssociationToasts -Name " $( $ProgID ) _ $( $Extension ) " -Property Type DWord -Value 0 -Force
if ( $Extension . Contains ( " . " ) )
{
@ -10102,7 +10122,7 @@ function RegistryBackup
{
" Enable "
{
New-ItemProperty -Path " HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Configuration Manager " -Name EnablePeriodicBackup -Type DWord -Value 1 -Force
New-ItemProperty -Path " HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Configuration Manager " -Name EnablePeriodicBackup -Property Type DWord -Value 1 -Force
}
" Disable "
{
@ -11217,17 +11237,14 @@ function CleanupTask
{
" Register "
{
# Enable notifications in Action Center
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path " HKCU:\Software\Microsoft\Windows Script Host\Settings " , " HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings " -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Windows . ActionCenter . SmartOptOut -Name Enable -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia -Name ShowBanner , ShowInActionCenter , Enabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ SystemSettings \ AccountNotifications -Name EnableAccountNotifications -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Checking whether VBS engine is enabled
@ -11678,17 +11695,14 @@ function SoftwareDistributionTask
{
" Register "
{
# Enable notifications in Action Center
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path " HKCU:\Software\Microsoft\Windows Script Host\Settings " , " HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings " -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Windows . ActionCenter . SmartOptOut -Name Enable -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia -Name ShowBanner , ShowInActionCenter , Enabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ SystemSettings \ AccountNotifications -Name EnableAccountNotifications -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Checking whether VBS engine is enabled
@ -12017,17 +12031,14 @@ function TempTask
{
" Register "
{
# Enable notifications in Action Center
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path " HKCU:\Software\Microsoft\Windows Script Host\Settings " , " HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings " -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Windows . ActionCenter . SmartOptOut -Name Enable -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia -Name ShowBanner , ShowInActionCenter , Enabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ SystemSettings \ AccountNotifications -Name EnableAccountNotifications -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Checking whether VBS engine is enabled
@ -12210,7 +12221,8 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
( -join ( " `$ env:SystemDrive\ " , '`$Windows.~WS' ) ) ,
" `$ env:SystemDrive\ESD " ,
" `$ env:SystemDrive\Intel " ,
" `$ env:SystemDrive\PerfLogs "
" `$ env:SystemDrive\PerfLogs " ,
" `$ env:SystemRoot\ServiceProfiles\NetworkService\AppData\Local\Temp "
)
if ( ( Get-ChildItem -Path `$ env : SystemDrive \ Recovery -Force | Where-Object -FilterScript { `$ _ . Name -eq " ReAgentOld.xml " } ) . FullName )
@ -14279,23 +14291,16 @@ public static void PostMessage()
#endregion Other actions
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Enable notifications in Action Center
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
# Enable notifications
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Windows . ActionCenter . SmartOptOut -Name Enable -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia -Name ShowBanner , ShowInActionCenter , Enabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ SystemSettings \ AccountNotifications -Name EnableAccountNotifications -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer , HKLM : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ CurrentVersion \ PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
Set-Policy -Scope User -Path Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -Type CLEAR
if ( -not ( Test-Path -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia ) )
{
New-Item -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia -Force
}
New-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia -Name ShowInActionCenter -PropertyType DWord -Value 1 -Force
if ( -not ( Test-Path -Path Registry :: HKEY_CLASSES_ROOT \ AppUserModelId \ Sophia ) )
{
New-Item -Path Registry :: HKEY_CLASSES_ROOT \ AppUserModelId \ Sophia -Force