@ -2,9 +2,11 @@
. SYNOPSIS
. SYNOPSIS
" Windows 10 Sophia Script " is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks
" Windows 10 Sophia Script " is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks
Version : v5 . 10
Version : v5 . 10 . 1
Date : 09 . 04 . 2021
Date : 14 . 04 . 2021
Copyright ( c ) 2015 – 2021 farag & oZ-Zo
Copyright ( c ) 2014 – 2021 farag
Copyright ( c ) 2019 – 2021 farag & oZ-Zo
Thanks to all https : / / forum . ru-board . com members involved
Thanks to all https : / / forum . ru-board . com members involved
@ -13,7 +15,7 @@
. NOTES
. NOTES
Supported Windows 10 versions
Supported Windows 10 versions
Versions : 2004 ( 20H1 ) / 20H2 ( 2009 ) / 21H1
Versions : 2004 / 20H2 / 21H1
Builds : 19041 / 19042 / 19043
Builds : 19041 / 19042 / 19043
Editions : Home / Pro / Enterprise
Editions : Home / Pro / Enterprise
Architecture : x64
Architecture : x64
@ -164,13 +166,13 @@ function CreateRestorePoint
#region Privacy & Telemetry
#region Privacy & Telemetry
<#
<#
. SYNOPSIS
. SYNOPSIS
Configure the DiagTrack service , firewall rule for Unified Telemetry Client Outbound Traffic and block connection
Configure the DiagTrack service , and connection for the Unified Telemetry Client Outbound Traffic
. PARAMETER Disable
. PARAMETER Disable
Disable the DiagTrack service , firewall rule for Unified Telemetry Client Outbound Traffic and block connection
Disable the DiagTrack service , and block connection for the Unified Telemetry Client Outbound Traffic
. PARAMETER Enable
. PARAMETER Enable
Enable the DiagTrack service , firewall rule for Unified Telemetry Client Outbound Traffic and allow connection
Enable the DiagTrack service , and allow connection for the Unified Telemetry Client Outbound Traffic
. EXAMPLE
. EXAMPLE
DiagTrackService -Disable
DiagTrackService -Disable
@ -207,7 +209,7 @@ function DiagTrackService
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
Get-Service -Name DiagTrack | Start-Service
# Enable firewall rule for Unified Telemetry Client Outbound Traffic and allow connection
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
}
}
" Disable "
" Disable "
@ -215,7 +217,7 @@ function DiagTrackService
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Disable firewall rule for Unified Telemetry Client Outbound Traffic and block connection
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
}
}
}
}
@ -1525,7 +1527,7 @@ function MergeConflicts
Open File Explorer to " This PC "
Open File Explorer to " This PC "
. PARAMETER QuickAccess
. PARAMETER QuickAccess
Open File Explorer to " Quick access "
Open File Explorer to Quick access
. EXAMPLE
. EXAMPLE
OpenFileExplorerTo -ThisPC
OpenFileExplorerTo -ThisPC
@ -1884,13 +1886,13 @@ function SnapAssist
<#
<#
. SYNOPSIS
. SYNOPSIS
Configure the file transfer dialog box
Configure the file transfer dialog box mode
. PARAMETER Detailed
. PARAMETER Detailed
Always open the file transfer dialog box in the detailed mode
Show the file transfer dialog box in the detailed mode
. PARAMETER Compact
. PARAMETER Compact
Always open the file transfer dialog box in the compact mode
Show the file transfer dialog box in the compact mode
. EXAMPLE
. EXAMPLE
FileTransferDialog -Detailed
FileTransferDialog -Detailed
@ -2002,13 +2004,13 @@ function FileExplorerRibbon
<#
<#
. SYNOPSIS
. SYNOPSIS
Configure the recycle bin files delete confirmation
Configure the recycle bin files delete confirmation dialog
. PARAMETER Disable
. PARAMETER Disable
Display / do not display the recycle bin files delete confirmation
Display / do not display the recycle bin files delete confirmation dialog
. PARAMETER Enable
. PARAMETER Enable
Display / do not display the recycle bin files delete confirmation
Display / do not display the recycle bin files delete confirmation dialog
. EXAMPLE
. EXAMPLE
RecycleBinDeleteConfirmation -Disable
RecycleBinDeleteConfirmation -Disable
@ -2084,13 +2086,13 @@ public static void PostMessage()
<#
<#
. SYNOPSIS
. SYNOPSIS
Configure the " 3D Objects " folder in " This PC " and " Quick access "
Configure the " 3D Objects " folder in " This PC " and Quick access
. PARAMETER Show
. PARAMETER Show
Show the " 3D Objects " folder in " This PC " and " Quick access "
Show the " 3D Objects " folder in " This PC " and Quick access
. PARAMETER Hide
. PARAMETER Hide
Hide the " 3D Objects " folder in " This PC " and " Quick access "
Hide the " 3D Objects " folder in " This PC " and Quick access
. EXAMPLE
. EXAMPLE
3DObjects -Show
3DObjects -Show
@ -2157,13 +2159,13 @@ function 3DObjects
<#
<#
. SYNOPSIS
. SYNOPSIS
Configure frequently used folders in " Quick access "
Configure frequently used folders in Quick access
. PARAMETER Show
. PARAMETER Show
Show frequently used folders in " Quick access "
Show frequently used folders in Quick access
. PARAMETER Hide
. PARAMETER Hide
Hide frequently used folders in " Quick access "
Hide frequently used folders in Quick access
. EXAMPLE
. EXAMPLE
QuickAccessFrequentFolders -Show
QuickAccessFrequentFolders -Show
@ -2327,13 +2329,13 @@ function TaskbarSearch
<#
<#
. SYNOPSIS
. SYNOPSIS
Configure the " Windows Ink Workspace " button on the taskbar
Configure the Windows Ink Workspace button on the taskbar
. PARAMETER Show
. PARAMETER Show
Show the " Windows Ink Workspace " button on the taskbar
Show the Windows Ink Workspace button on the taskbar
. PARAMETER Hide
. PARAMETER Hide
Hide the " Windows Ink Workspace " button on the taskbar
Hide the Windows Ink Workspace button on the taskbar
. EXAMPLE
. EXAMPLE
WindowsInkWorkspace -Show
WindowsInkWorkspace -Show
@ -2692,10 +2694,10 @@ function WindowsColorScheme
Configure the default app mode color scheme
Configure the default app mode color scheme
. PARAMETER Light
. PARAMETER Light
Set the default app mode color scheme to the light
Set the app mode color scheme to the light
. PARAMETER Dark
. PARAMETER Dark
Set the default app mode color scheme to the dark
Set the app mode color scheme to the dark
. EXAMPLE
. EXAMPLE
AppMode -Light
AppMode -Light
@ -3864,7 +3866,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
New-Item -Path $env:LOCALAPPDATA \ Temp -ItemType Directory -Force
New-Item -Path $env:LOCALAPPDATA \ Temp -ItemType Directory -Force
}
}
# Copy all imported module folders to the new %TEMP% folder ###
# Copy all imported module folders to the new %TEMP% folder
Get-ChildItem -Path $env:TEMP -Force | Where-Object -FilterScript { $_ . Name -like " *remoteIpMoProxy* " } | ForEach-Object -Process {
Get-ChildItem -Path $env:TEMP -Force | Where-Object -FilterScript { $_ . Name -like " *remoteIpMoProxy* " } | ForEach-Object -Process {
Copy-Item $_ . FullName -Destination $env:LOCALAPPDATA \ Temp -Recurse -Force
Copy-Item $_ . FullName -Destination $env:LOCALAPPDATA \ Temp -Recurse -Force
}
}
@ -7779,25 +7781,24 @@ function PinToStart
$UnpinAll ,
$UnpinAll ,
[ Parameter (
[ Parameter (
Mandatory = $tru e ,
Mandatory = $fals e ,
Position = 1
Position = 1
) ]
) ]
[ ValidateSet ( " ControlPanel " , " DevicesPrinters " , " PowerShell " ) ]
[ ValidateSet ( " ControlPanel " , " DevicesPrinters " , " PowerShell " ) ]
[string[]]
[string[]]
$Tiles ,
$Tiles
[string]
$StartLayout = " $ PSScriptRoot\StartLayout.xml "
)
)
begin
begin
{
{
$Script:StartLayout = " $ PSScriptRoot\StartLayout.xml "
# Unpin all the Start tiles
# Unpin all the Start tiles
if ( $UnpinAll )
if ( $UnpinAll )
{
{
Export-StartLayout -Path $StartLayout -UseDesktopApplicationID
Export-StartLayout -Path $Script:S tartLayout -UseDesktopApplicationID
[xml] $XML = Get-Content -Path $StartLayout -Encoding UTF8 -Force
[xml] $XML = Get-Content -Path $Script:S tartLayout -Encoding UTF8 -Force
$Groups = $XML . LayoutModificationTemplate . DefaultLayoutOverride . StartLayoutCollection . StartLayout . Group
$Groups = $XML . LayoutModificationTemplate . DefaultLayoutOverride . StartLayoutCollection . StartLayout . Group
foreach ( $Group in $Groups )
foreach ( $Group in $Groups )
@ -7806,7 +7807,7 @@ function PinToStart
$Group . ParentNode . RemoveChild ( $Group ) | Out-Null
$Group . ParentNode . RemoveChild ( $Group ) | Out-Null
}
}
$XML . Save ( $StartLayout )
$XML . Save ( $Script:S tartLayout )
}
}
}
}
@ -7841,8 +7842,22 @@ public static string GetString(uint strId)
# Extract the localized "Devices and Printers" string from shell32.dll
# Extract the localized "Devices and Printers" string from shell32.dll
$DevicesPrinters = [WinAPI.GetStr] :: GetString ( 30493 )
$DevicesPrinters = [WinAPI.GetStr] :: GetString ( 30493 )
# Check if an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
if ( ( ( Get-Command -Name PinToStart ) . Parametersets . Parameters | Where-Object -FilterScript { $null -eq $_ . Attributes . AliasNames } ) . Attributes . ValidValues | Where-Object -FilterScript { $_ -match " DevicesPrinters " } )
{
# Create the old-style "Devices and Printers" shortcut in the Start menu
$Shell = New-Object -ComObject Wscript . Shell
$Shortcut = $Shell . CreateShortcut ( " $ env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\ $ DevicesPrinters.lnk " )
$Shortcut . TargetPath = " control "
$Shortcut . Arguments = " printers "
$Shortcut . IconLocation = " $ env:SystemRoot\system32\DeviceCenter.dll "
$Shortcut . Save ( )
Start-Sleep -Seconds 3
}
# Get the AppID because it's auto generated AppID for the "Devices and Printers" shortcut
# Get the AppID because it's auto generated AppID for the "Devices and Printers" shortcut
$Script:DevicesPrintersAppID = ( Get-StartApps | Where-Object -FilterScript { $_ . Name -eq $DevicesPrinters } ) . AppID
$DevicesPrintersAppID = ( Get-StartApps | Where-Object -FilterScript { $_ . Name -eq $DevicesPrinters } ) . AppID
$Parameters = @ (
$Parameters = @ (
# Control Panel hash table
# Control Panel hash table
@ -7861,7 +7876,7 @@ public static string GetString(uint strId)
Size = " 2x2 "
Size = " 2x2 "
Column = 2
Column = 2
Row = 0
Row = 0
AppID = $Script: DevicesPrintersAppID
AppID = $DevicesPrintersAppID
} ,
} ,
# Windows PowerShell hash table
# Windows PowerShell hash table
@ {
@ {
@ -7906,13 +7921,13 @@ public static string GetString(uint strId)
$Table
$Table
}
}
if ( -not ( Test-Path -Path $StartLayout ) )
if ( -not ( Test-Path -Path $Script:S tartLayout ) )
{
{
# Export the current Start layout
# Export the current Start layout
Export-StartLayout -Path $StartLayout -UseDesktopApplicationID
Export-StartLayout -Path $Script:S tartLayout -UseDesktopApplicationID
}
}
[xml] $XML = Get-Content -Path $StartLayout -Encoding UTF8 -Force
[xml] $XML = Get-Content -Path $Script:S tartLayout -Encoding UTF8 -Force
foreach ( $Tile in $Tiles )
foreach ( $Tile in $Tiles )
{
{
@ -7926,16 +7941,6 @@ public static string GetString(uint strId)
DevicesPrinters
DevicesPrinters
{
{
Write-Verbose -Message ( $Localization . ShortcutPinning -f $DevicesPrinters ) -Verbose
Write-Verbose -Message ( $Localization . ShortcutPinning -f $DevicesPrinters ) -Verbose
# Create the old-style "Devices and Printers" shortcut in the Start menu
$Shell = New-Object -ComObject Wscript . Shell
$Shortcut = $Shell . CreateShortcut ( " $ env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\ $ DevicesPrinters.lnk " )
$Shortcut . TargetPath = " control "
$Shortcut . Arguments = " printers "
$Shortcut . IconLocation = " $ env:SystemRoot\system32\DeviceCenter.dll "
$Shortcut . Save ( )
Start-Sleep -Seconds 3
}
}
PowerShell
PowerShell
{
{
@ -7975,7 +7980,7 @@ public static string GetString(uint strId)
}
}
}
}
$XML . Save ( $StartLayout )
$XML . Save ( $Script:S tartLayout )
}
}
end
end
@ -7986,7 +7991,7 @@ public static string GetString(uint strId)
New-Item -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Force
New-Item -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Force
}
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name LockedStartLayout -Value 1 -Force
New-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name LockedStartLayout -Value 1 -Force
New-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name StartLayoutFile -Value $StartLayout -Force
New-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name StartLayoutFile -Value $Script:S tartLayout -Force
Start-Sleep -Seconds 3
Start-Sleep -Seconds 3
@ -8005,7 +8010,7 @@ public static string GetString(uint strId)
Remove-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name LockedStartLayout -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name LockedStartLayout -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name StartLayoutFile -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name StartLayoutFile -Force -ErrorAction Ignore
Remove-Item -Path $StartLayout -Force
Remove-Item -Path $Script:S tartLayout -Force
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
@ -8033,9 +8038,9 @@ public static string GetString(uint strId)
UninstallUWPApps -ForAllUsers
UninstallUWPApps -ForAllUsers
. NOTES
. NOTES
The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies are being loaded to the current session to be able to load localized UWP apps names
Load The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies to the current session in order to get localized UWP apps names
CsWinRT v1 . 1 . 4
CsWinRT v1 . 2 . 2
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 15
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 16
. LINK
. LINK
https : / / github . com / microsoft / CsWinRT
https : / / github . com / microsoft / CsWinRT
@ -8154,7 +8159,7 @@ function UninstallUWPApps
xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns : x = " http://schemas.microsoft.com/winfx/2006/xaml "
xmlns : x = " http://schemas.microsoft.com/winfx/2006/xaml "
Name = " Window "
Name = " Window "
MinHeight = " 400 " MinWidth = " 410 "
MinHeight = " 400 " MinWidth = " 415 "
SizeToContent = " Width " WindowStartupLocation = " CenterScreen "
SizeToContent = " Width " WindowStartupLocation = " CenterScreen "
TextOptions . TextFormattingMode = " Display " SnapsToDevicePixels = " True "
TextOptions . TextFormattingMode = " Display " SnapsToDevicePixels = " True "
FontFamily = " Candara " FontSize = " 16 " ShowInTaskbar = " True " >
FontFamily = " Candara " FontSize = " 16 " ShowInTaskbar = " True " >
@ -8445,6 +8450,15 @@ function UninstallUWPApps
. NOTES
. NOTES
UWP apps can be restored only if they were uninstalled only for the current user
UWP apps can be restored only if they were uninstalled only for the current user
. NOTES
Load The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies to the current session in order to get localized UWP apps names
CsWinRT v1 . 2 . 2
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 16
. LINK
https : / / github . com / microsoft / CsWinRT
https : / / www . nuget . org / packages / Microsoft . Windows . SDK . NET . Ref
. NOTES
. NOTES
A pop-up dialog box enables the user to select packages
A pop-up dialog box enables the user to select packages
Current user
Current user
@ -8541,7 +8555,7 @@ function RestoreUWPApps
#region Functions
#region Functions
function Get-AppxManifest
function Get-AppxManifest
{
{
Write-Verbose -Message " Patient " -Verbose
Write-Verbose -Message $Localization . Patient -Verbose
# Тут нельзя напрямую вписать -PackageTypeFilter Bundle, так как иначе не выдается нужное свойство InstallLocation. Только сравнивать с $Bundles
# Тут нельзя напрямую вписать -PackageTypeFilter Bundle, так как иначе не выдается нужное свойство InstallLocation. Только сравнивать с $Bundles
$Bundles = ( Get-AppXPackage -PackageTypeFilter Bundle -AllUsers ) . Name
$Bundles = ( Get-AppXPackage -PackageTypeFilter Bundle -AllUsers ) . Name
@ -11813,6 +11827,15 @@ public static void PostMessage()
Write-Warning -Message $Localization . RestartWarning
Write-Warning -Message $Localization . RestartWarning
. NOTES
Load The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies to the current session in order to get localized UWP apps names
CsWinRT v1 . 2 . 1
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 15
. LINK
https : / / github . com / microsoft / CsWinRT
https : / / www . nuget . org / packages / Microsoft . Windows . SDK . NET . Ref
Add-Type -AssemblyName " $ PSScriptRoot\Libraries\WinRT.Runtime.dll "
Add-Type -AssemblyName " $ PSScriptRoot\Libraries\WinRT.Runtime.dll "
Add-Type -AssemblyName " $ PSScriptRoot\Libraries\Microsoft.Windows.SDK.NET.dll "
Add-Type -AssemblyName " $ PSScriptRoot\Libraries\Microsoft.Windows.SDK.NET.dll "