@ -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 . 3
Date : 21 . 11 . 2022
Version : v6 . 2 . 4
Date : 26 . 11 . 2022
Copyright ( c ) 2014 — 2022 farag
Copyright ( c ) 2019 — 2022 farag & Inestic
@ -3752,7 +3752,7 @@ function OneDrive
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . OneDriveUninstalling -Verbose
Stop-Process -Name OneDrive , FileCoAuth -Force -ErrorAction Ignore
Stop-Process -Name OneDrive , OneDriveSetup , FileCoAuth -Force -ErrorAction Ignore
# Getting link to the OneDriveSetup.exe and its' argument(s)
[string[]] $OneDriveSetup = ( $UninstallString -Replace ( " \s*/ " , " ,/ " ) ) . Split ( " , " ) . Trim ( )
@ -3768,7 +3768,7 @@ function OneDrive
# Get the OneDrive user folder path and remove it if it doesn't contain any user files
if ( Test-Path -Path $env:OneDrive )
{
if ( ( Get-ChildItem -Path $env:OneDrive | Measure-Object ) . Count -eq 0 )
if ( ( Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object ) . Count -eq 0 )
{
Remove-Item -Path $env:OneDrive -Recurse -Force -ErrorAction Ignore
@ -4246,7 +4246,7 @@ function TempFolder
# Cleaning up folders
Remove-Item -Path $env:SystemRoot \ Temp -Recurse -Force -ErrorAction Ignore
Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript { $_ . LinkType -ne " SymbolicLink " } | Remove-Item -Recurse -Force -ErrorAction Ignore
Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript { $_ . LinkType -ne " SymbolicLink " } | Remove-Item -Recurse -Force -ErrorAction Ignore
if ( -not ( Test-Path -Path $env:LOCALAPPDATA \ Temp ) )
{
@ -10690,6 +10690,16 @@ function CleanupTask
{
" Register "
{
# Checking if notifications and Action Center are disabled
if
(
( ( Get-ItemProperty -Path HKCU : \ Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -ErrorAction Ignore ) . DisableNotificationCenter -eq 1 ) -or
( ( Get-ItemProperty -Path HKLM : \ Software \ Policies \ Microsoft \ Windows \ Explorer -Name DisableNotificationCenter -ErrorAction Ignore ) . DisableNotificationCenter -eq 1 )
)
{
return
}
# 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 folders do not exist
@ -11001,12 +11011,7 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For
< toast duration = " "" Long "" " >
< visual >
< binding template = " "" ToastGeneric "" " >
< text > $ ( $Localization . TaskNotificationTitle ) < / text >
< group >
< subgroup >
< text hint-style = " "" body "" " hint-wrap = " "" true "" " > $ ( $Localization . SoftwareDistributionTaskNotificationEvent ) < / text >
< / subgroup >
< / group >
< text > $ ( $Localization . SoftwareDistributionTaskNotificationEvent ) < / text >
< / binding >
< / visual >
< audio src = " "" ms-winsoundevent:notification.default "" " / >
@ -11154,12 +11159,7 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_
< toast duration = " "" Long "" " >
< visual >
< binding template = " "" ToastGeneric "" " >
< text > $ ( $Localization . TaskNotificationTitle ) < / text >
< group >
< subgroup >
< text hint-style = " "" body "" " hint-wrap = " "" true "" " > $ ( $Localization . TempTaskNotificationEvent ) < / text >
< / subgroup >
< / group >
< text > $ ( $Localization . TempTaskNotificationEvent ) < / text >
< / binding >
< / visual >
< audio src = " "" ms-winsoundevent:notification.default "" " / >
@ -12339,6 +12339,64 @@ function ShareContext
}
}
<#
. SYNOPSIS
The " Edit with Clipchamp " item in the media files context menu
. PARAMETER Hide
Hide the " Edit with Clipchamp " item from the media files context menu
. PARAMETER Show
Show the " Edit with Clipchamp " item in the media files context menu
. EXAMPLE
EditWithClipchampContext -Hide
. EXAMPLE
EditWithClipchampContext -Show
. NOTES
Current user
#>
function EditWithClipchampContext
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
if ( ( ( Get-CimInstance -ClassName Win32_OperatingSystem ) . BuildNumber -ge 22621 ) -and ( Get-AppxPackage -Name Clipchamp . Clipchamp ) )
{
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
if ( -not ( Test-Path -Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked " ) )
{
New-Item -Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked " -Force
}
New-ItemProperty -Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked " -Name " {8AB635F8-9A67-4698-AB99-784AD929F3B4} " -PropertyType String -Value " Play to menu " -Force
}
" Show "
{
Remove-ItemProperty -Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked " -Name " {8AB635F8-9A67-4698-AB99-784AD929F3B4} " -Force -ErrorAction Ignore
}
}
}
}
<#
. SYNOPSIS
The " Print " item in the . bat and . cmd context menu
@ -12919,12 +12977,12 @@ function UpdateLGPEPolicies
{
# Parse every ADMX template searching if it contains full path and registry key simultaneously
[xml] $config = Get-Content -Path $admx . FullName -Encoding UTF8
$config . SelectNodes ( " //@* " ) | ForEach-Object { $_ . value = $_ . value . ToLower ( ) }
$config . SelectNodes ( " //@* " ) | ForEach-Object -Process { $_ . value = $_ . value . ToLower ( ) }
$SplitPath = $Path . Name . Replace ( " HKEY_LOCAL_MACHINE\ " , " " )
if ( $config . SelectSingleNode ( " //*[local-name()='policy' and @key=' $( $SplitPath . ToLower ( ) ) ' and (@valueName=' $( $Item . ToLower ( ) ) ' or @Name=' $( $Item . ToLower ( ) ) ' or .//*[local-name()='enum' and @valueName=' $( $Item . ToLower ( ) ) '])] " ) )
{
Write-Verbose -Message $Item . Replace ( " {} " , " " ) -Verbose
Write-Verbose -Message ( [string] ( ( $SplitPath , " | " , $Item . Replace ( " {} " , " " ) ) ) ) -Verbose
$Type = switch ( ( Get-Item -Path $Path . PSPath ) . GetValueKind ( $Item ) )
{
@ -12974,12 +13032,12 @@ function UpdateLGPEPolicies
{
# Parse every ADMX template searching if it contains full path and registry key simultaneously
[xml] $config = Get-Content -Path $admx . FullName -Encoding UTF8
$config . SelectNodes ( " //@* " ) | ForEach-Object { $_ . value = $_ . value . ToLower ( ) }
$config . SelectNodes ( " //@* " ) | ForEach-Object -Process { $_ . value = $_ . value . ToLower ( ) }
$SplitPath = $Path . Name . Replace ( " HKEY_CURRENT_USER\ " , " " )
if ( $config . SelectSingleNode ( " //*[local-name()='policy' and @key=' $( $SplitPath . ToLower ( ) ) ' and (@valueName=' $( $Item . ToLower ( ) ) ' or @Name=' $( $Item . ToLower ( ) ) ' or .//*[local-name()='enum' and @valueName=' $( $Item . ToLower ( ) ) '])] " ) )
{
Write-Verbose -Message $Item . Replace ( " {} " , " " ) -Verbose
Write-Verbose -Message ( [string] ( ( $SplitPath , " | " , $Item . Replace ( " {} " , " " ) ) ) ) -Verbose
$Type = switch ( ( Get-Item -Path $Path . PSPath ) . GetValueKind ( $Item ) )
{
@ -13087,6 +13145,12 @@ public static void PostMessage()
}
}
if ( $Script:RegionChanged )
{
# Set the original region ID
Set-WinHomeLocation -GeoId $Script:Region
}
# Persist Sophia notifications to prevent to immediately disappear from Action Center
if ( -not ( Test-Path -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Sophia ) )
{
@ -13201,16 +13265,6 @@ public static void PostMessage()
gpupdate / force
}
# [WinAPI.UpdateEnvironment]::Refresh() makes so that Meet Now icon returns even if was hid before, so we need to check which function was called previously
if ( $Script:MeetNow )
{
MeetNow -Show
}
elseif ( $Script:MeetNow -eq $false )
{
MeetNow -Hide
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path " $ env:TEMP\Computer.txt " , " $ env:TEMP\User.txt " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore