Browse Source

Removed unnecessary code

pull/712/head
Dmitry Nefedov 2 months ago
parent
commit
4de8af9c20
  1. 16
      Wrapper/Config/config_Windows_10_LTSC.json
  2. 28
      Wrapper/Config/config_Windows_11_LTSC.json
  3. 2
      src/Sophia_Script_for_Windows_10/Import-TabCompletion.ps1
  4. 34
      src/Sophia_Script_for_Windows_10/Module/Private/InitialActions.ps1
  5. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Import-TabCompletion.ps1
  6. 51
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Private/InitialActions.ps1
  7. 129
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  8. 8
      src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
  9. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Import-TabCompletion.ps1
  10. 51
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Private/InitialActions.ps1
  11. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Import-TabCompletion.ps1
  12. 34
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Private/InitialActions.ps1
  13. 2
      src/Sophia_Script_for_Windows_11/Import-TabCompletion.ps1
  14. 2
      src/Sophia_Script_for_Windows_11_ARM/Import-TabCompletion.ps1
  15. 2
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Import-TabCompletion.ps1
  16. 25
      src/Sophia_Script_for_Windows_11_LTSC_2024/Import-TabCompletion.ps1
  17. 49
      src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Private/InitialActions.ps1
  18. 502
      src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1
  19. 15
      src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1
  20. 2
      src/Sophia_Script_for_Windows_11_PowerShell_7/Import-TabCompletion.ps1

16
Wrapper/Config/config_Windows_10_LTSC.json

@ -369,7 +369,7 @@
},
"Preset": "Zero",
"WindowsDefault": "One",
"LTSC2019": "false",
"LTSC2019": "true",
"LTSC2021": "true"
},
{
@ -541,7 +541,7 @@
"Preset": "Zero",
"WindowsDefault": "One",
"LTSC2019": "true",
"LTSC2021": "false"
"LTSC2021": "true"
},
{
"Region": "UI & Personalization",
@ -1031,7 +1031,9 @@
}
},
"Preset": "Zero",
"WindowsDefault": "Zero"
"WindowsDefault": "Zero",
"LTSC2019": "false",
"LTSC2021": "true"
},
{
"Region": "UI & Personalization",
@ -1724,7 +1726,9 @@
}
},
"Preset": "",
"WindowsDefault": ""
"WindowsDefault": "",
"LTSC2019": "true",
"LTSC2021": "true"
},
{
"Region": "System",
@ -1799,7 +1803,9 @@
"Preset": "Zero",
"WindowsDefault": "One",
"Preset2": "0123",
"WindowsDefault2": ""
"WindowsDefault2": "",
"LTSC2019": "false",
"LTSC2021": "true"
},
{
"Region": "System",

28
Wrapper/Config/config_Windows_11_LTSC.json

@ -630,7 +630,8 @@
}
},
"Preset": "Zero",
"WindowsDefault": "One"
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "UI & Personalization",
@ -1492,7 +1493,8 @@
}
},
"Preset": "Zero",
"WindowsDefault": "One"
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "System",
@ -1582,7 +1584,8 @@
}
},
"Preset": "",
"WindowsDefault": ""
"WindowsDefault": "",
"LTSC2024": "true"
},
{
"Region": "System",
@ -1689,22 +1692,6 @@
"WindowsDefault": "",
"LTSC2024": "true"
},
{
"Region": "UWP apps",
"Control": "chkchkalter",
"Required": "false",
"Separate": "true",
"Function": "Uninstall-UWPApps",
"Function2": "Uninstall-UWPApps -ForAllUsers",
"Arg": {
"Zero": {
"Tag": ""
}
},
"Preset": "Zero",
"WindowsDefault": "",
"LTSC2024": "true"
},
{
"Region": "Gaming",
"Control": "cmb",
@ -1958,7 +1945,8 @@
}
},
"Preset": "Zero",
"WindowsDefault": "One"
"WindowsDefault": "One",
"LTSC2024": "true"
},
{
"Region": "Microsoft Defender & Security",

2
src/Sophia_Script_for_Windows_10/Import-TabCompletion.ps1

@ -259,5 +259,5 @@ Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

34
src/Sophia_Script_for_Windows_10/Module/Private/InitialActions.ps1

@ -778,40 +778,6 @@ public extern static string BrandingFormatString(string sFormat);
exit
}
# Checking whether current terminal is Windows Terminal
if ($env:WT_SESSION)
{
# Checking whether Windows Terminal version is higher than 1.23
# Get Windows Terminal process PID
$ParentProcessID = (Get-CimInstance -ClassName Win32_Process -Filter ProcessID=$PID).ParentProcessID
$WindowsTerminalVersion = (Get-Process -Id $ParentProcessID).FileVersion
# FileVersion has four properties while $WindowsTerminalVersion has only three, unless the [System.Version] accelerator fails
$WindowsTerminalVersion = "{0}.{1}.{2}" -f $WindowsTerminalVersion.Split(".")
if ([System.Version]$WindowsTerminalVersion -lt [System.Version]"1.23.0")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.UnsupportedWindowsTerminal
Write-Information -MessageData "" -InformationAction Continue
Start-Process -FilePath "ms-windows-store://pdp/?productid=9N0DX20HK701"
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
# Check for UWP apps updates
Get-CimInstance -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 -Namespace root/CIMV2/mdm/dmmap | Invoke-CimMethod -MethodName UpdateScanMethod
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
$Global:Failed = $true
exit
}
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{

2
src/Sophia_Script_for_Windows_10_LTSC_2019/Import-TabCompletion.ps1

@ -154,6 +154,6 @@ Register-ArgumentCompleter @Parameters
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal'" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

51
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Private/InitialActions.ps1

@ -481,23 +481,14 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
# Checking whether the Microsoft Store and Windows Feature Experience Pack was removed
$UWPComponents = [Array]::TrueForAll(@(
"Microsoft.WindowsStore",
"MicrosoftWindows.Client.CBS"
),
[Predicate[string]]{
param($UWPComponent)
(Get-AppxPackage -Name $UWPComponent).Status -eq "OK"
})
if (-not $UWPComponents)
# Checking whether Windows Feature Experience Pack was removed
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message ($Localization.WindowsComponentBroken -f "UWP")
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose
Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
@ -779,40 +770,6 @@ public extern static string BrandingFormatString(string sFormat);
exit
}
# Checking whether current terminal is Windows Terminal
if ($env:WT_SESSION)
{
# Checking whether Windows Terminal version is higher than 1.23
# Get Windows Terminal process PID
$ParentProcessID = (Get-CimInstance -ClassName Win32_Process -Filter ProcessID=$PID).ParentProcessID
$WindowsTerminalVersion = (Get-Process -Id $ParentProcessID).FileVersion
# FileVersion has four properties while $WindowsTerminalVersion has only three, unless the [System.Version] accelerator fails
$WindowsTerminalVersion = "{0}.{1}.{2}" -f $WindowsTerminalVersion.Split(".")
if ([System.Version]$WindowsTerminalVersion -lt [System.Version]"1.23.0")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.UnsupportedWindowsTerminal
Write-Information -MessageData "" -InformationAction Continue
Start-Process -FilePath "ms-windows-store://pdp/?productid=9N0DX20HK701"
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
# Check for UWP apps updates
Get-CimInstance -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 -Namespace root/CIMV2/mdm/dmmap | Invoke-CimMethod -MethodName UpdateScanMethod
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
$Global:Failed = $true
exit
}
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{

129
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -6568,135 +6568,6 @@ public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntP
[WinAPI.wininet]::InternetSetOption(0, $INTERNET_OPTION_REFRESH, 0, 0)
}
<#
.SYNOPSIS
Desktop shortcut creation upon Microsoft Edge update
.PARAMETER Channels
List Microsoft Edge channels to prevent desktop shortcut creation upon its update
.PARAMETER Disable
Do not prevent desktop shortcut creation upon Microsoft Edge update
.EXAMPLE
PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
.EXAMPLE
PreventEdgeShortcutCreation -Disable
.NOTES
Machine-wide
#>
function PreventEdgeShortcutCreation
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
)]
[ValidateSet("Stable", "Beta", "Dev", "Canary")]
[string[]]
$Channels,
[Parameter(
Mandatory = $false,
ParameterSetName = "Disable"
)]
[switch]
$Disable
)
if (-not (Get-Package -Name "Microsoft Edge" -ErrorAction Ignore))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message (($Localization.PackageNotInstalled -f "Microsoft Edge"), ($Localization.Skipped -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message (($Localization.PackageNotInstalled -f "Microsoft Edge"), ($Localization.Skipped -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
return
}
if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate))
{
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force
}
foreach ($Channel in $Channels)
{
switch ($Channel)
{
Stable
{
if (Get-Package -Name "Microsoft Edge" -ErrorAction Ignore)
{
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force
# msedgeupdate.admx is not a default ADMX template
if (Test-Path -Path "$env:SystemRoot\PolicyDefinitions\msedgeupdate.admx")
{
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3
}
}
}
Beta
{
if (Get-Package -Name "Microsoft Edge Beta" -ErrorAction Ignore)
{
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force
# msedgeupdate.admx is not a default ADMX template
if (Test-Path -Path "$env:SystemRoot\PolicyDefinitions\msedgeupdate.admx")
{
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type DWORD -Value 3
}
}
}
Dev
{
if (Get-Package -Name "Microsoft Edge Dev" -ErrorAction Ignore)
{
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force
# msedgeupdate.admx is not a default ADMX template
if (Test-Path -Path "$env:SystemRoot\PolicyDefinitions\msedgeupdate.admx")
{
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type DWORD -Value 3
}
}
}
Canary
{
if (Get-Package -Name "Microsoft Edge Canary" -ErrorAction Ignore)
{
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force
# msedgeupdate.admx is not a default ADMX template
if (Test-Path -Path "$env:SystemRoot\PolicyDefinitions\msedgeupdate.admx")
{
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type DWORD -Value 3
}
}
}
}
}
if ($Disable)
{
$Names = @(
"CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}",
"CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}",
"CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}",
"CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}"
)
Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore
if (Test-Path -Path "$env:SystemRoot\PolicyDefinitions\msedgeupdate.admx")
{
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR
}
}
}
<#
.SYNOPSIS
Back up the system registry to %SystemRoot%\System32\config\RegBack folder when PC restarts and create a RegIdleBackup in the Task Scheduler task to manage subsequent backups

8
src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1

@ -707,14 +707,6 @@ AntizapretProxy -Enable
# https://antizapret.prostovpn.org
# AntizapretProxy -Disable
# List Microsoft Edge channels to prevent desktop shortcut creation upon its update
# Перечислите каналы Microsoft Edge для предотвращения создания ярлыков на рабочем столе после его обновления
PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary
# Do not prevent desktop shortcut creation upon Microsoft Edge update (default value)
# Не предотвращать создание ярлыков на рабочем столе при обновлении Microsoft Edge (значение по умолчанию)
# PreventEdgeShortcutCreation -Disable
# Back up the system registry to %SystemRoot%\System32\config\RegBack folder when PC restarts and create a RegIdleBackup in the Task Scheduler task to manage subsequent backups
# Создавать копии реестра при перезагрузке ПК и задание RegIdleBackup в Планировщике для управления последующими резервными копиями
RegistryBackup -Enable

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Import-TabCompletion.ps1

@ -195,6 +195,6 @@ Register-ArgumentCompleter @Parameters
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal'" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

51
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Private/InitialActions.ps1

@ -481,23 +481,14 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
# Checking whether the Microsoft Store and Windows Feature Experience Pack was removed
$UWPComponents = [Array]::TrueForAll(@(
"Microsoft.WindowsStore",
"MicrosoftWindows.Client.CBS"
),
[Predicate[string]]{
param($UWPComponent)
(Get-AppxPackage -Name $UWPComponent).Status -eq "OK"
})
if (-not $UWPComponents)
# Checking whether Windows Feature Experience Pack was removed
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message ($Localization.WindowsComponentBroken -f "UWP")
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose
Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
@ -779,40 +770,6 @@ public extern static string BrandingFormatString(string sFormat);
exit
}
# Checking whether current terminal is Windows Terminal
if ($env:WT_SESSION)
{
# Checking whether Windows Terminal version is higher than 1.23
# Get Windows Terminal process PID
$ParentProcessID = (Get-CimInstance -ClassName Win32_Process -Filter ProcessID=$PID).ParentProcessID
$WindowsTerminalVersion = (Get-Process -Id $ParentProcessID).FileVersion
# FileVersion has four properties while $WindowsTerminalVersion has only three, unless the [System.Version] accelerator fails
$WindowsTerminalVersion = "{0}.{1}.{2}" -f $WindowsTerminalVersion.Split(".")
if ([System.Version]$WindowsTerminalVersion -lt [System.Version]"1.23.0")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.UnsupportedWindowsTerminal
Write-Information -MessageData "" -InformationAction Continue
Start-Process -FilePath "ms-windows-store://pdp/?productid=9N0DX20HK701"
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
# Check for UWP apps updates
Get-CimInstance -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 -Namespace root/CIMV2/mdm/dmmap | Invoke-CimMethod -MethodName UpdateScanMethod
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
$Global:Failed = $true
exit
}
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Import-TabCompletion.ps1

@ -259,5 +259,5 @@ Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

34
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Private/InitialActions.ps1

@ -816,40 +816,6 @@ public extern static string BrandingFormatString(string sFormat);
exit
}
# Checking whether current terminal is Windows Terminal
if ($env:WT_SESSION)
{
# Checking whether Windows Terminal version is higher than 1.23
# Get Windows Terminal process PID
$ParentProcessID = (Get-CimInstance -ClassName Win32_Process -Filter ProcessID=$PID).ParentProcessID
$WindowsTerminalVersion = (Get-Process -Id $ParentProcessID).FileVersion
# FileVersion has four properties while $WindowsTerminalVersion has only three, unless the [System.Version] accelerator fails
$WindowsTerminalVersion = "{0}.{1}.{2}" -f $WindowsTerminalVersion.Split(".")
if ([System.Version]$WindowsTerminalVersion -lt [System.Version]"1.23.0")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.UnsupportedWindowsTerminal
Write-Information -MessageData "" -InformationAction Continue
Start-Process -FilePath "ms-windows-store://pdp/?productid=9N0DX20HK701"
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
# Check for UWP apps updates
Get-CimInstance -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 -Namespace root/CIMV2/mdm/dmmap | Invoke-CimMethod -MethodName UpdateScanMethod
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
$Global:Failed = $true
exit
}
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{

2
src/Sophia_Script_for_Windows_11/Import-TabCompletion.ps1

@ -218,5 +218,5 @@ Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

2
src/Sophia_Script_for_Windows_11_ARM/Import-TabCompletion.ps1

@ -194,5 +194,5 @@ Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

2
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Import-TabCompletion.ps1

@ -194,5 +194,5 @@ Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

25
src/Sophia_Script_for_Windows_11_LTSC_2024/Import-TabCompletion.ps1

@ -18,7 +18,7 @@
.EXAMPLE
Sophia -Functions <tab>
Sophia -Functions temp<tab>
Sophia -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", Uninstall-UWPApps
Sophia -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal"
.NOTES
Use commas to separate funtions
@ -123,25 +123,6 @@ $Parameters = @{
}
}
# If a module command is Uninstall-UWPApps
if ($Command -eq "Uninstall-UWPApps")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is ForAllUsers
if ($ParameterSet -eq "ForAllUsers")
{
# The "Uninstall-UWPApps -ForAllUsers" construction
"Uninstall-UWPApps" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is Install-DotNetRuntimes
if ($Command -eq "Install-DotNetRuntimes")
{
@ -192,7 +173,7 @@ Register-ArgumentCompleter @Parameters
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal'" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

49
src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Private/InitialActions.ps1

@ -484,20 +484,11 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
# Checking whether the Microsoft Store and Windows Feature Experience Pack was removed
$UWPComponents = [Array]::TrueForAll(@(
"Microsoft.WindowsStore",
"MicrosoftWindows.Client.CBS"
),
[Predicate[string]]{
param($UWPComponent)
(Get-AppxPackage -Name $UWPComponent).Status -eq "OK"
})
if (-not $UWPComponents)
# Checking whether Windows Feature Experience Pack was removed
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message ($Localization.WindowsComponentBroken -f "UWP")
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose
@ -782,40 +773,6 @@ public extern static string BrandingFormatString(string sFormat);
exit
}
# Checking whether current terminal is Windows Terminal
if ($env:WT_SESSION)
{
# Checking whether Windows Terminal version is higher than 1.23
# Get Windows Terminal process PID
$ParentProcessID = (Get-CimInstance -ClassName Win32_Process -Filter ProcessID=$PID).ParentProcessID
$WindowsTerminalVersion = (Get-Process -Id $ParentProcessID).FileVersion
# FileVersion has four properties while $WindowsTerminalVersion has only three, unless the [System.Version] accelerator fails
$WindowsTerminalVersion = "{0}.{1}.{2}" -f $WindowsTerminalVersion.Split(".")
if ([System.Version]$WindowsTerminalVersion -lt [System.Version]"1.23.0")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.UnsupportedWindowsTerminal
Write-Information -MessageData "" -InformationAction Continue
Start-Process -FilePath "ms-windows-store://pdp/?productid=9N0DX20HK701"
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
# Check for UWP apps updates
Get-CimInstance -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 -Namespace root/CIMV2/mdm/dmmap | Invoke-CimMethod -MethodName UpdateScanMethod
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
$Global:Failed = $true
exit
}
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{

502
src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1

@ -7753,508 +7753,6 @@ function Install-WSL
}
#endregion WSL
#region UWP apps
<#
.SYNOPSIS
Uninstall UWP apps
.PARAMETER ForAllUsers
"ForAllUsers" argument sets a checkbox to unistall packages for all users
.EXAMPLE
Uninstall-UWPApps
.EXAMPLE
Uninstall-UWPApps -ForAllUsers
.NOTES
Current user
#>
function Uninstall-UWPApps
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $false)]
[switch]
$ForAllUsers
)
Add-Type -AssemblyName PresentationCore, PresentationFramework
#region Variables
# The following UWP apps will have their checkboxes unchecked
$UncheckedAppxPackages = @(
# Windows Media Player
"Microsoft.ZuneMusic",
# Screen Sketch
"Microsoft.ScreenSketch",
# Photos (and Video Editor)
"Microsoft.Windows.Photos",
"Microsoft.Photos.MediaEngineDLC",
# Calculator
"Microsoft.WindowsCalculator",
# Windows Advanced Settings
"Microsoft.Windows.DevHome",
# Windows Camera
"Microsoft.WindowsCamera",
# Xbox Identity Provider
"Microsoft.XboxIdentityProvider",
# Xbox Console Companion
"Microsoft.XboxApp",
# Xbox
"Microsoft.GamingApp",
"Microsoft.GamingServices",
# Paint
"Microsoft.Paint",
# Xbox TCUI
"Microsoft.Xbox.TCUI",
# Xbox Speech To Text Overlay
"Microsoft.XboxSpeechToTextOverlay",
# Xbox Game Bar
"Microsoft.XboxGamingOverlay",
# Xbox Game Bar Plugin
"Microsoft.XboxGameOverlay"
)
# The following UWP apps will be excluded from the display
$ExcludedAppxPackages = @(
# Dolby Access
"DolbyLaboratories.DolbyAccess",
"DolbyLaboratories.DolbyDigitalPlusDecoderOEM",
# AMD Radeon Software
"AdvancedMicroDevicesInc-2.AMDRadeonSoftware",
# Intel Graphics Control Center
"AppUp.IntelGraphicsControlPanel",
"AppUp.IntelGraphicsExperience",
# ELAN Touchpad
"ELANMicroelectronicsCorpo.ELANTouchpadforThinkpad",
"ELANMicroelectronicsCorpo.ELANTrackPointforThinkpa",
# Microsoft Application Compatibility Enhancements
"Microsoft.ApplicationCompatibilityEnhancements",
# AVC Encoder Video Extension
"Microsoft.AVCEncoderVideoExtension",
# Microsoft Desktop App Installer
"Microsoft.DesktopAppInstaller",
# Store Experience Host
"Microsoft.StorePurchaseApp",
# Cross Device Experience Host
"MicrosoftWindows.CrossDevice",
# Notepad
"Microsoft.WindowsNotepad",
# Microsoft Store
"Microsoft.WindowsStore",
# Windows Terminal
"Microsoft.WindowsTerminal",
"Microsoft.WindowsTerminalPreview",
# Web Media Extensions
"Microsoft.WebMediaExtensions",
# AV1 Video Extension
"Microsoft.AV1VideoExtension",
# Windows Subsystem for Linux
"MicrosoftCorporationII.WindowsSubsystemForLinux",
# HEVC Video Extensions from Device Manufacturer
"Microsoft.HEVCVideoExtension",
"Microsoft.HEVCVideoExtensions",
# Raw Image Extension
"Microsoft.RawImageExtension",
# HEIF Image Extensions
"Microsoft.HEIFImageExtension",
# MPEG-2 Video Extension
"Microsoft.MPEG2VideoExtension",
# VP9 Video Extensions
"Microsoft.VP9VideoExtensions",
# Webp Image Extensions
"Microsoft.WebpImageExtension",
# PowerShell
"Microsoft.PowerShell",
# NVIDIA Control Panel
"NVIDIACorp.NVIDIAControlPanel",
# Realtek Audio Console
"RealtekSemiconductorCorp.RealtekAudioControl",
# Synaptics
"SynapticsIncorporated.SynapticsControlPanel",
"SynapticsIncorporated.241916F58D6E7",
"ELANMicroelectronicsCorpo.ELANTrackPointforThinkpa",
"ELANMicroelectronicsCorpo.TrackPoint"
)
#region Variables
#region XAML Markup
# The section defines the design of the upcoming dialog box
[xml]$XAML = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Window"
MinHeight="400" MinWidth="415"
SizeToContent="Width" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="StackPanel">
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<Style TargetType="CheckBox">
<Setter Property="Margin" Value="10,13,10,13"/>
<Setter Property="IsChecked" Value="True"/>
</Style>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="0,10,10,10"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="20"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="IsEnabled" Value="False"/>
</Style>
<Style TargetType="Border">
<Setter Property="BorderThickness" Value="0,1,0,1"/>
<Setter Property="BorderBrush" Value="#000000"/>
</Style>
<Style TargetType="ScrollViewer">
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="BorderBrush" Value="#000000"/>
<Setter Property="BorderThickness" Value="0,1,0,1"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="PanelSelectAll" Grid.Column="0" HorizontalAlignment="Left">
<CheckBox x:Name="CheckBoxSelectAll" IsChecked="False"/>
<TextBlock x:Name="TextBlockSelectAll" Margin="10,10,0,10"/>
</StackPanel>
<StackPanel x:Name="PanelRemoveForAll" Grid.Column="1" HorizontalAlignment="Right">
<TextBlock x:Name="TextBlockRemoveForAll" Margin="10,10,0,10"/>
<CheckBox x:Name="CheckBoxForAllUsers" IsChecked="False"/>
</StackPanel>
</Grid>
<Border Grid.Row="1">
<ScrollViewer>
<StackPanel x:Name="PanelContainer" Orientation="Vertical"/>
</ScrollViewer>
</Border>
<Button x:Name="ButtonUninstall" Grid.Row="2"/>
</Grid>
</Window>
"@
#endregion XAML Markup
$Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
Set-Variable -Name $_.Name -Value $Form.FindName($_.Name)
}
$Window.Title = $Localization.UWPAppsTitle
$ButtonUninstall.Content = $Localization.Uninstall
$TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll
# Extract the localized "Select all" string from %SystemRoot%\System32\shell32.dll
$TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276)
$ButtonUninstall.Add_Click({ButtonUninstallClick})
$CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick})
$CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
#endregion Variables
#region Functions
function Get-AppxBundle
{
[CmdletBinding()]
param
(
[string[]]
$Exclude,
[switch]
$AllUsers
)
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from %SystemRoot%\System32\shell32.dll
Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
$AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
# The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually
$Packages = @(
# Outlook
"Microsoft.OutlookForWindows",
# Microsoft Teams
"MSTeams",
# Microsoft Edge Game Assist
"Microsoft.Edge.GameAssist"
)
foreach ($Package in $Packages)
{
if (Get-AppxPackage -Name $Package -AllUsers:$AllUsers)
{
$AppxPackages += Get-AppxPackage -Name $Package -AllUsers:$AllUsers
}
}
$PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
foreach ($AppxPackage in $AppxPackages)
{
$PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
if (-not $PackageId)
{
continue
}
[PSCustomObject]@{
Name = $AppxPackage.Name
PackageFullName = $AppxPackage.PackageFullName
# Sometimes there's more than one package presented in Windows with the same package name like {Microsoft Teams, Microsoft Teams} and we need to display the first one
DisplayName = $PackageId.DisplayName | Select-Object -First 1
}
}
}
function Add-Control
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true
)]
[ValidateNotNull()]
[PSCustomObject[]]
$Packages
)
process
{
foreach ($Package in $Packages)
{
$CheckBox = New-Object -TypeName System.Windows.Controls.CheckBox
$CheckBox.Tag = $Package.PackageFullName
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
if ($Package.DisplayName)
{
$TextBlock.Text = $Package.DisplayName
}
else
{
$TextBlock.Text = $Package.Name
}
$StackPanel = New-Object -TypeName System.Windows.Controls.StackPanel
$StackPanel.Children.Add($CheckBox) | Out-Null
$StackPanel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($StackPanel) | Out-Null
if ($UncheckedAppxPackages.Contains($Package.Name))
{
$CheckBox.IsChecked = $false
}
else
{
$CheckBox.IsChecked = $true
$PackagesToRemove.Add($Package.PackageFullName)
}
$CheckBox.Add_Click({CheckBoxClick})
}
}
}
function CheckBoxForAllUsersClick
{
$PanelContainer.Children.RemoveRange(0, $PanelContainer.Children.Count)
$PackagesToRemove.Clear()
$AppXPackages = Get-AppxBundle -Exclude $ExcludedAppxPackages -AllUsers:$CheckBoxForAllUsers.IsChecked
$AppXPackages | Add-Control
ButtonUninstallSetIsEnabled
}
function ButtonUninstallClick
{
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from %SystemRoot%\System32\shell32.dll
Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
$Window.Close() | Out-Null
# If MSTeams is selected to uninstall, delete quietly "Microsoft Teams Meeting Add-in for Microsoft Office" too
# & "$env:SystemRoot\System32\msiexec.exe" --% /x {A7AB73A3-CB10-4AA5-9D38-6AEFFBDE4C91} /qn
if ($PackagesToRemove -match "MSTeams")
{
Start-Process -FilePath "$env:SystemRoot\System32\msiexec.exe" -ArgumentList "/x {A7AB73A3-CB10-4AA5-9D38-6AEFFBDE4C91} /qn" -Wait
}
$PackagesToRemove | Remove-AppxPackage -AllUsers:$CheckBoxForAllUsers.IsChecked -Verbose
}
function CheckBoxClick
{
$CheckBox = $_.Source
if ($CheckBox.IsChecked)
{
$PackagesToRemove.Add($CheckBox.Tag) | Out-Null
}
else
{
$PackagesToRemove.Remove($CheckBox.Tag)
}
ButtonUninstallSetIsEnabled
}
function CheckBoxSelectAllClick
{
$CheckBox = $_.Source
if ($CheckBox.IsChecked)
{
$PackagesToRemove.Clear()
foreach ($Item in $PanelContainer.Children.Children)
{
if ($Item -is [System.Windows.Controls.CheckBox])
{
$Item.IsChecked = $true
$PackagesToRemove.Add($Item.Tag)
}
}
}
else
{
$PackagesToRemove.Clear()
foreach ($Item in $PanelContainer.Children.Children)
{
if ($Item -is [System.Windows.Controls.CheckBox])
{
$Item.IsChecked = $false
}
}
}
ButtonUninstallSetIsEnabled
}
function ButtonUninstallSetIsEnabled
{
if ($PackagesToRemove.Count -gt 0)
{
$ButtonUninstall.IsEnabled = $true
}
else
{
$ButtonUninstall.IsEnabled = $false
}
}
#endregion Functions
# Check "For all users" checkbox to uninstall packages from all accounts
if ($ForAllUsers)
{
$CheckBoxForAllUsers.IsChecked = $true
}
$PackagesToRemove = [Collections.Generic.List[string]]::new()
$AppXPackages = Get-AppxBundle -Exclude $ExcludedAppxPackages -AllUsers:$ForAllUsers
$AppXPackages | Add-Control
if ($AppxPackages.Count -eq 0)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message ($Localization.NoUWPApps, ($Localization.Skipped -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message ($Localization.NoUWPApps, ($Localization.Skipped -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
}
else
{
#region Sendkey function
# Emulate the Backspace key sending to prevent the console window to freeze
Start-Sleep -Milliseconds 500
Add-Type -AssemblyName System.Windows.Forms
# We cannot use Get-Process -Id $PID as script might be invoked via Terminal with different $PID
Get-Process -Name powershell, WindowsTerminal -ErrorAction Ignore | Where-Object -FilterScript {$_.MainWindowTitle -match "Sophia Script for Windows 11 LTSC 2024"} | ForEach-Object -Process {
# Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
Start-Sleep -Seconds 1
# Force move the console window to the foreground
[WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
Start-Sleep -Seconds 1
# Emulate the Backspace key sending to prevent the console window to freeze
[System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
}
#endregion Sendkey function
if ($PackagesToRemove.Count -gt 0)
{
$ButtonUninstall.IsEnabled = $true
}
# Force move the WPF form to the foreground
$Window.Add_Loaded({$Window.Activate()})
$Form.ShowDialog() | Out-Null
}
}
#endregion UWP apps
#region Gaming
<#
.SYNOPSIS

15
src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1

@ -888,21 +888,6 @@ RegistryBackup -Enable
# Install-WSL
#endregion WSL
#region UWP apps
# Uninstall UWP apps using the pop-up dialog box
# Удалить UWP-приложения, используя всплывающее диалоговое окно
Uninstall-UWPApps
<#
Uninstall UWP apps for all users using the pop-up dialog box
If the "For All Users" is checked apps packages will not be installed for new users
Удалить UWP-приложения для всех пользователей, используя всплывающее диалоговое окно
Пакеты приложений не будут установлены для новых пользователей, если отмечена галочка "Для всех пользователей"
#>
# Uninstall-UWPApps -ForAllUsers
#endregion UWP apps
#region Gaming
<#
Turn on hardware-accelerated GPU scheduling. Restart needed

2
src/Sophia_Script_for_Windows_11_PowerShell_7/Import-TabCompletion.ps1

@ -218,5 +218,5 @@ Write-Verbose -Message "Sophia -Functions <tab>" -Verbose
Write-Verbose -Message "Sophia -Functions temp<tab>" -Verbose
Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll' -Verbose"
Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose
Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose

Loading…
Cancel
Save