diff --git a/README.md b/README.md
index 58da88b5..1b9479e3 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ Sophia Script for Windows is the largest PowerShell module on `GitHub` for `Wind
## Screenshots
-### The TAB autocomplete. Read more [here](#how-to-run-the-specific-functions)
+### The TAB autocomplete. Read more [here](#how-to-run-the-specific-functions)

@@ -136,7 +136,7 @@ Sophia Script for Windows is the largest PowerShell module on `GitHub` for `Wind
* Set up UI & Personalization;
* Uninstall OneDrive "correctly";
* Interactive [prompts](#change-user-folders-location-programmatically-using-the-interactive-menu);
-* The [TAB](#the-tab-autocomplete-read-more-here) completion for functions and their arguments (if using the Functions.ps1 file);
+* The TAB [completion](#the-tab-autocomplete-read-more-here) for functions and their arguments (if using the Functions.ps1 file);
* Change %TEMP% environment variable path to %SystemDrive%\Temp
* Change location of the user folders programmatically (without moving user files) within interactive menu using arrows to select a drive
* "Desktop";
@@ -216,10 +216,10 @@ To run the specific function(s) [dot source](https://docs.microsoft.com/ru-ru/po
* Now you can do like this (the quotation marks required)
```powershell
-Sophia -Functions
-Sophia -Functions temp
-Sophia -Functions unin
-Sophia -Functions uwp
+Sophia -FunctionsTAB
+Sophia -Functions tempTAB
+Sophia -Functions uninTAB
+Sophia -Functions uwpTAB
Sophia -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", UninstallUWPApps
UninstallUWPApps, "PinToStart -UnpinAll"
diff --git a/src/Sophia_Script_for_Windows_10/Functions.ps1 b/src/Sophia_Script_for_Windows_10/Functions.ps1
index afc12139..7a613995 100644
--- a/src/Sophia_Script_for_Windows_10/Functions.ps1
+++ b/src/Sophia_Script_for_Windows_10/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v5.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.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.14.0 | 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.14.1 | 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/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1
index d02aa8fd..b47c43a9 100644
--- a/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1
+++ b/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1
@@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
- ModuleVersion = '5.14.0'
+ ModuleVersion = '5.14.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
index f9000f77..ef923102 100644
--- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
+++ b/src/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.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -11279,14 +11279,19 @@ function CleanupTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
@@ -11477,15 +11482,37 @@ while (`$true)
}
"Delete"
{
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
+
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
}
-
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -Force -ErrorAction Ignore
-
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
-
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Recurse -Force -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11535,14 +11562,19 @@ function SoftwareDistributionTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
# Persist the Settings notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"))
@@ -11599,7 +11631,31 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11649,14 +11705,19 @@ function TempTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
$TempTask = @"
Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force
@@ -11705,7 +11766,31 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -13499,6 +13584,7 @@ function UpdateLGPEPolicies
}
Write-Verbose -Message $Localization.Patient -Verbose
+ Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Local Machine policies paths to scan recursively
diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1
index b54af5d4..4b3886cd 100644
--- a/src/Sophia_Script_for_Windows_10/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 10"
- Version: v5.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -74,7 +74,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.14.0 | 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.14.1 | 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/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
index d496e867..bf889ca0 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v5.4.0
- Date: 22.10.2022
+ Version: v5.4.1
+ Date: 29.10.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.4.0 | 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.4.1 | 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/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1
index d1df0fe0..f17bbd71 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1
@@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
- ModuleVersion = '5.4.0'
+ ModuleVersion = '5.4.1'
GUID = 'a36a65ca-70f9-43df-856c-3048fc5e7f01'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
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 8960ee8e..213f1298 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
@@ -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.4.0
- Date: 22.10.2022
+ Version: v5.4.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -7913,14 +7913,19 @@ function CleanupTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
@@ -8111,15 +8116,37 @@ while (`$true)
}
"Delete"
{
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
+
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
}
-
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -Force -ErrorAction Ignore
-
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
-
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Recurse -Force -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -8169,14 +8196,19 @@ function SoftwareDistributionTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
# Persist the Settings notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"))
@@ -8233,7 +8265,31 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -8283,14 +8339,19 @@ function TempTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
$TempTask = @"
Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force
@@ -8339,7 +8400,31 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -9911,6 +9996,7 @@ function UpdateLGPEPolicies
}
Write-Verbose -Message $Localization.Patient -Verbose
+ Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Local Machine policies paths to scan recursively
diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
index 27c2b267..01767201 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
+++ b/src/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.4.0
- Date: 22.10.2022
+ Version: v5.4.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -74,7 +74,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.4.0 | 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.4.1 | 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/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
index d190dae2..e98c2d5a 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v5.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.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.14.0 | 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.14.1 | 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/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1
index d02aa8fd..b47c43a9 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1
@@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
- ModuleVersion = '5.14.0'
+ ModuleVersion = '5.14.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
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 d0650de5..c761c9ae 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
@@ -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.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -9080,14 +9080,19 @@ function CleanupTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
@@ -9278,15 +9283,37 @@ while (`$true)
}
"Delete"
{
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
+
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
}
-
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -Force -ErrorAction Ignore
-
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
-
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Recurse -Force -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -9336,14 +9363,19 @@ function SoftwareDistributionTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
# Persist the Settings notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"))
@@ -9400,7 +9432,31 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -9450,14 +9506,19 @@ function TempTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
$TempTask = @"
Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force
@@ -9506,7 +9567,31 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11132,6 +11217,7 @@ function UpdateLGPEPolicies
}
Write-Verbose -Message $Localization.Patient -Verbose
+ Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Local Machine policies paths to scan recursively
diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
index 2b8599bc..f34b0cfc 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
+++ b/src/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.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -74,7 +74,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.14.0 | 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.14.1 | 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/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
index 714b0aa4..29ec2731 100644
--- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
+++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v5.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.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.14.0 (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.14.1 (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/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1
index 9ed024aa..8612ac3b 100644
--- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1
+++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1
@@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
- ModuleVersion = '5.14.0'
+ ModuleVersion = '5.14.1'
GUID = 'aa0b47a7-1770-4b5d-8c9f-cc6c505bcc7a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
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 7691c673..b56cd536 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
@@ -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.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -11317,14 +11317,19 @@ function CleanupTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
@@ -11515,15 +11520,37 @@ while (`$true)
}
"Delete"
{
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
+
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
}
-
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -Force -ErrorAction Ignore
-
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
-
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Recurse -Force -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11573,14 +11600,19 @@ function SoftwareDistributionTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
# Persist the Settings notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"))
@@ -11637,7 +11669,31 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11687,14 +11743,19 @@ function TempTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
$TempTask = @"
Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force
@@ -11743,7 +11804,31 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -13539,6 +13624,7 @@ function UpdateLGPEPolicies
}
Write-Verbose -Message $Localization.Patient -Verbose
+ Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Local Machine policies paths to scan recursively
diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
index 3e0c9a79..65bd53a8 100644
--- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
+++ b/src/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.14.0
- Date: 22.10.2022
+ Version: v5.14.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -74,7 +74,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.14.0 (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.14.1 (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/src/Sophia_Script_for_Windows_11/Functions.ps1 b/src/Sophia_Script_for_Windows_11/Functions.ps1
index 08c3edde..a5c2ba7f 100644
--- a/src/Sophia_Script_for_Windows_11/Functions.ps1
+++ b/src/Sophia_Script_for_Windows_11/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v6.2.0
- Date: 22.10.2022
+ Version: v6.2.1
+ Date: 29.10.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.2.0 | 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.2.1 | 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/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1
index 6393f861..bceb022f 100644
--- a/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1
+++ b/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1
@@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
- ModuleVersion = '6.2.0'
+ ModuleVersion = '6.2.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
index 581c3e25..a952bb76 100644
--- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
+++ b/src/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.2.0
- Date: 22.10.2022
+ Version: v6.2.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -10662,14 +10662,19 @@ function CleanupTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
@@ -10860,15 +10865,37 @@ while (`$true)
}
"Delete"
{
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
+
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
}
-
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -Force -ErrorAction Ignore
-
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
-
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Recurse -Force -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -10918,14 +10945,19 @@ function SoftwareDistributionTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
# Persist the Settings notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"))
@@ -10982,7 +11014,31 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11032,14 +11088,19 @@ function TempTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
$TempTask = @"
Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force
@@ -11088,7 +11149,31 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1
index ffff4135..029a5d9f 100644
--- a/src/Sophia_Script_for_Windows_11/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 11"
- Version: v6.2.0
- Date: 22.10.2022
+ Version: v6.2.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -73,7 +73,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.2.0 | 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.2.1 | 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/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
index 1c605980..b6b5d485 100644
--- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
+++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v6.2.0
- Date: 22.10.2022
+ Version: v6.2.1
+ Date: 29.10.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.2.0 | 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.2.1 | 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/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1
index 072213b3..d5cf400e 100644
--- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1
+++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1
@@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
- ModuleVersion = '6.2.0'
+ ModuleVersion = '6.2.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
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 5840e303..7cbf65a1 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
@@ -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.2.0
- Date: 22.10.2022
+ Version: v6.2.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -1571,13 +1571,13 @@ function AppsSilentInstalling
<#
.SYNOPSIS
- Suggestions on how I can set up my device
+ Ways to get the most out of Windows and finish setting up this device
.PARAMETER Disable
- Disable suggestions on how I can set up my device
+ Do not suggest ways to get the most out of Windows and finish setting up this device
.PARAMETER Enable
- Offer suggestions on how I can set up my device
+ Suggest ways to get the most out of Windows and finish setting up this device
.EXAMPLE
WhatsNewInWindows -Disable
@@ -3591,7 +3591,6 @@ function Cursors
}
$ZIP.Dispose()
-
Remove-Item -Path "$DownloadsFolder\Cursors.zip" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name "(default)" -PropertyType String -Value "W11 Cursor Light HD v2.2 by Jepri Creations" -Force
@@ -10701,14 +10700,19 @@ function CleanupTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
@@ -10899,15 +10903,37 @@ while (`$true)
}
"Delete"
{
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
+
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches | ForEach-Object -Process {
Remove-ItemProperty -Path $_.PsPath -Name StateFlags1337 -Force -ErrorAction Ignore
}
-
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -Force -ErrorAction Ignore
-
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName "Windows Cleanup", "Windows Cleanup Notification" -Confirm:$false -ErrorAction Ignore
-
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Recurse -Force -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -10957,14 +10983,19 @@ function SoftwareDistributionTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
# Persist the Settings notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"))
@@ -11021,7 +11052,31 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -11071,14 +11126,19 @@ function TempTask
{
"Register"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
- $Items = @(
- "$env:SystemRoot\System32\Tasks\SophiApp",
- "$env:SystemRoot\System32\Tasks\Sophia Script",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp",
- "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script"
- )
- Remove-Item -Path $Items -Recurse -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
$TempTask = @"
Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force
@@ -11127,7 +11187,31 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
}
"Delete"
{
- Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\", "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+ # Remove all old tasks
+ Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
+ # Remove folder in Task Scheduler if there is no tasks left there. We cannot remove all old folders explicitly and not get errors if any of folder do not exist
+ $ScheduleService = New-Object -ComObject Schedule.Service
+ $ScheduleService.Connect()
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia Script")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia Script", $null)
+ }
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SophiApp")
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("SophiApp", $null)
+ }
+
+ # Removing current task
+ Unregister-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -Confirm:$false -ErrorAction Ignore
+
+ # Remove folder in Task Scheduler if there is no tasks left there
+ if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Sophia")
+ {
+ if (($ScheduleService.GetFolder("Sophia").GetTasks(0) | Select-Object -Property Name).Name.Count -eq 0)
+ {
+ $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null)
+ }
+ }
}
}
}
@@ -12916,6 +13000,7 @@ function UpdateLGPEPolicies
}
Write-Verbose -Message $Localization.Patient -Verbose
+ Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Local Machine policies paths to scan recursively
diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1
index 7e51862e..def80a0d 100644
--- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1
+++ b/src/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.2.0
- Date: 22.10.2022
+ Version: v6.2.1
+ Date: 29.10.2022
Copyright (c) 2014—2022 farag
Copyright (c) 2019—2022 farag & Inestic
@@ -73,7 +73,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.2.0 (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.2.1 (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
@@ -89,7 +89,6 @@ catch
Import-LocalizedData -BindingVariable Global:Localization -UICulture en-US -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia
}
-
<#
.SYNOPSIS
Run the script by specifying functions as an argument
@@ -243,12 +242,12 @@ AppsSilentInstalling -Disable
# Включить автоматическую установку рекомендованных приложений (значение по умолчанию)
# AppsSilentInstalling -Enable
-# Disable suggestions on how I can set up my device
-# Не показывать предложения по настройке устройства
+# Do not suggest ways to get the most out of Windows and finish setting up this device
+# Не предлагать способы завершения настройки этого устройства для наиболее эффективного использования Windows
WhatsNewInWindows -Disable
-# Let Microsoft offer you tailored experiences based on the diagnostic data setting you have chosen (default value)
-# Разрешите корпорации Майкософт использовать ваши диагностические данные для улучшения вашей работы со службами Майкрософт с помощью персонализированных советов, рекламы и рекомендаций (значение по умолчанию)
+# Suggest ways to get the most out of Windows and finish setting up this device
+# Предложить способы завершения настройки этого устройства для наиболее эффективного использования Windows
# WhatsNewInWindows -Enable
# Don't let Microsoft use your diagnostic data for personalized tips, ads, and recommendations