Browse Source

Small improvements

pull/429/head
Dmitry Nefedov 2 years ago
parent
commit
3f74a9bccb
  1. 6
      src/Sophia_Script_for_Windows_10/Functions.ps1
  2. 31
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  3. 6
      src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
  4. 31
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  5. 6
      src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
  6. 31
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  7. 6
      src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
  8. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1
  9. 31
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  10. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  11. 8
      src/Sophia_Script_for_Windows_11/Functions.ps1
  12. 31
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  13. 10
      src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
  14. 4
      src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1
  15. 31
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  16. 6
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

6
src/Sophia_Script_for_Windows_10/Functions.ps1

@ -146,6 +146,12 @@ $Parameters = @{
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{
continue
}
foreach ($ParameterSet in $ParameterSets.Name)
{
# The "Function -Argument" construction

31
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -11267,7 +11267,11 @@ function CleanupTask
}
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
@ -11456,7 +11460,10 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11536,7 +11543,10 @@ function SoftwareDistributionTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11610,7 +11620,10 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11685,7 +11698,10 @@ function TempTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11758,7 +11774,10 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service

6
src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1

@ -79,6 +79,12 @@ $Parameters = @{
{
$ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{
continue
}
foreach ($ParameterSet in $ParameterSets.Name)
{
# The "Function -Argument" construction

31
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -7915,7 +7915,11 @@ function CleanupTask
}
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
@ -8104,7 +8108,10 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -8184,7 +8191,10 @@ function SoftwareDistributionTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -8258,7 +8268,10 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -8333,7 +8346,10 @@ function TempTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -8406,7 +8422,10 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service

6
src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1

@ -103,6 +103,12 @@ $Parameters = @{
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{
continue
}
foreach ($ParameterSet in $ParameterSets.Name)
{
# The "Function -Argument" construction

31
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -9082,7 +9082,11 @@ function CleanupTask
}
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
@ -9271,7 +9275,10 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -9351,7 +9358,10 @@ function SoftwareDistributionTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -9425,7 +9435,10 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -9500,7 +9513,10 @@ function TempTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -9573,7 +9589,10 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service

6
src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1

@ -153,6 +153,12 @@ $Parameters = @{
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{
continue
}
foreach ($ParameterSet in $ParameterSets.Name)
{
# The "Function -Argument" construction

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1

@ -5,7 +5,7 @@
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
Description = 'Module for Windows fine-tuning and automating the routine tasks'
PowerShellVersion = '7.2'
PowerShellVersion = '7.3'
ProcessorArchitecture = 'AMD64'
FunctionsToExport = '*'

31
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -11295,7 +11295,11 @@ function CleanupTask
}
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
@ -11484,7 +11488,10 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11564,7 +11571,10 @@ function SoftwareDistributionTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11638,7 +11648,10 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11713,7 +11726,10 @@ function TempTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11786,7 +11802,10 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -76,7 +76,7 @@ Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
# PowerShell 7 doesn't load en-us localization automatically if there is no localization folder in user's language which is determined by $PSUICulture
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-localizeddata?view=powershell-7.2
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-localizeddata?view=powershell-7.3
try
{
Import-LocalizedData -BindingVariable Global:Localization -UICulture $PSUICulture -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia -ErrorAction Stop

8
src/Sophia_Script_for_Windows_11/Functions.ps1

@ -58,7 +58,7 @@ Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia -BaseDirectory $PSScriptRoot\Localizations
# The mandatory checks. Please, do not comment out this function
Checks
#Checks
$Parameters = @{
CommandName = "Sophia"
@ -141,6 +141,12 @@ $Parameters = @{
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{
continue
}
foreach ($ParameterSet in $ParameterSets.Name)
{
# The "Function -Argument" construction

31
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -10673,7 +10673,11 @@ function CleanupTask
}
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
@ -10862,7 +10866,10 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -10942,7 +10949,10 @@ function SoftwareDistributionTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11016,7 +11026,10 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11091,7 +11104,10 @@ function TempTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11164,7 +11180,10 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service

10
src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v6.2.3
Version: v6.2.4
Date: 04.12.2022
Copyright (c) 20142022 farag
@ -50,7 +50,7 @@ function Sophia
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.2.3 | 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.4 | 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
@ -148,6 +148,12 @@ $Parameters = @{
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{
continue
}
foreach ($ParameterSet in $ParameterSets.Name)
{
# The "Function -Argument" construction

4
src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1

@ -1,11 +1,11 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '6.2.3'
ModuleVersion = '6.2.4'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2022 farag & Inestic. All rights reserved'
Description = 'Module for Windows fine-tuning and automating the routine tasks'
PowerShellVersion = '7.2'
PowerShellVersion = '7.3'
ProcessorArchitecture = 'AMD64'
FunctionsToExport = '*'

31
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -10701,7 +10701,11 @@ function CleanupTask
}
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
@ -10890,7 +10894,10 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -10970,7 +10977,10 @@ function SoftwareDistributionTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11044,7 +11054,10 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11119,7 +11132,10 @@ function TempTask
"Register"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction Ignore
}
# Remove folders in Task Scheduler. We cannot remove all old folders explicitly and not get errors if any of folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11192,7 +11208,10 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
"Delete"
{
# Remove all old tasks
Unregister-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -TaskName "Windows Cleanup", "Windows Cleanup Notification", SoftwareDistribution, Temp -Confirm:$false -ErrorAction Ignore
# We have to use -ErrorAction Ignore in both cases, unless we get an error
Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process {
Unregister-ScheduledTask -TaskName $_.TaskName -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 folders do not exist
$ScheduleService = New-Object -ComObject Schedule.Service

6
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 11 (PowerShell 7)"
Version: v6.2.3
Version: v6.2.4
Date: 04.12.2022
Copyright (c) 20142022 farag
@ -69,13 +69,13 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.2.3 (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.4 (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
# PowerShell 7 doesn't load en-us localization automatically if there is no localization folder in user's language which is determined by $PSUICulture
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-localizeddata?view=powershell-7.2
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-localizeddata?view=powershell-7.3
try
{
Import-LocalizedData -BindingVariable Global:Localization -UICulture $PSUICulture -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia -ErrorAction Stop

Loading…
Cancel
Save