diff --git a/Sophia/PowerShell 7/Functions.ps1 b/Sophia/PowerShell 7/Functions.ps1 index 83d6058f..28a1eaf5 100644 --- a/Sophia/PowerShell 7/Functions.ps1 +++ b/Sophia/PowerShell 7/Functions.ps1 @@ -2,9 +2,11 @@ .SYNOPSIS Run the specific function, using the TAB completion - Version: v5.10 - Date: 09.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.10.1 + Date: 14.04.2021 + + Copyright (c) 2014–2021 farag + Copyright (c) 2019–2021 farag & oZ-Zo Thanks to all https://forum.ru-board.com members involved @@ -71,7 +73,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script v5.10 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" +$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script v5.10.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force @@ -95,25 +97,69 @@ $Parameters = @{ $Commands = (Get-Module -Name Sophia).ExportedCommands.Keys foreach ($Command in $Commands) { - $UnnecessaryParameters = @("Verbose", "Debug", "ErrorAction", "WarningAction", "InformationAction", "ErrorVariable", "WarningVariable", "InformationVariable", "OutVariable", "OutBuffer", "PipelineVariable") - $ParameterSets = ((Get-Command -Name $Command).Parameters | Where-Object -FilterScript {$_.Keys}).Keys | Where-Object -FilterScript {$_ -notin $UnnecessaryParameters} - foreach ($ParameterSet in $ParameterSets) + $ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames} + + # If module command is PinToStart + if ($Command -eq "PinToStart") + { + # Get all command arguments, excluding defaults + foreach ($ParameterSet in $ParameterSets.Name) + { + # If Argument is PinToStart + if ($ParameterSet -eq "Tiles") + { + $ValidValues = ((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues + foreach ($ValidValue in $ValidValues) + { + # "PinToStart -Tites ControlPanel" construction + # "PinToStart -Tites DevicesPrinters" construction + # "PinToStart -Tites PowerShell" construction + "PinToStart" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + # "PinToStart -Tites ControlPanel, DevicesPrinters, PowerShell" construction + "PinToStart" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + continue + } + } + + # If module command is UninstallUWPApps + if ($Command -eq "UninstallUWPApps") + { + (Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} + + # Get all command arguments, excluding defaults + foreach ($ParameterSet in $ParameterSets.Name) + { + # If Argument is ForAllUsers + if ($ParameterSet -eq "ForAllUsers") + { + # "UninstallUWPApps -ForAllUsers" construction + "UninstallUWPApps" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + continue + } + } + + foreach ($ParameterSet in $ParameterSets.Name) { # "Function -Argument" construction - $Command + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -match $wordToComplete} | ForEach-Object -Process {"`"$_`""} + $Command + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } - continue + # Get functions list without arguments to complete + Get-Command -Name $Command | Where-Object -FilterScript {$null -eq $_.Parametersets.Parameters} | Where-Object -FilterScript {$_.Name -like "*$wordToComplete*"} } - - # Get functions list without arguments to complete - (Get-Command -Name @((Get-Module -Name Sophia).ExportedCommands.Keys)) | Where-Object -FilterScript { - $_.CmdletBinding -eq $false - } | Where-Object -FilterScript {$_.Name -match $wordToComplete} } } Register-ArgumentCompleter @Parameters +Write-Information -MessageData "`n" -InformationAction Continue Write-Verbose -Message "Sophia -Functions " -Verbose Write-Verbose -Message "Sophia -Functions temp" -Verbose Write-Verbose -Message "Sophia -Functions `"DiagTrackService -Disable`", `"DiagnosticDataLevel -Minimal`", UninstallUWPApps" -Verbose +Write-Information -MessageData "`n" -InformationAction Continue +Write-Verbose -Message "UninstallUWPApps, `"PinToStart -UnpinAll`"" -Verbose diff --git a/Sophia/PowerShell 7/Sophia.ps1 b/Sophia/PowerShell 7/Sophia.ps1 index fc6ad13e..4f389e35 100644 --- a/Sophia/PowerShell 7/Sophia.ps1 +++ b/Sophia/PowerShell 7/Sophia.ps1 @@ -2,29 +2,34 @@ .SYNOPSIS Default preset file for "Windows 10 Sophia Script" - Version: v5.10 - Date: 09.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.10.1 + Date: 14.04.2021 + + Copyright (c) 2014–2021 farag + Copyright (c) 2019–2021 farag & oZ-Zo Thanks to all https://forum.ru-board.com members involved .DESCRIPTION Read carefully and configure the preset file before running - Comment out function with the "#" char if you don't want it to be run - Uncomment function by removing the "#" char if you want it to be run + Comment out function with the "#" char if you don't want it to be run + Uncomment function by removing the "#" char if you want it to be run Every tweak in the preset file has its' corresponding function to restore the default settings Running the script is best done on a fresh install because running it on wrong tweaked system may result in errors occurring - To be able to call the specific function using autocompletion enter ". .\Functions.ps1" (with a dot at the beginning) - Read more in the Functions.ps1 file + To be able to call the specific function using autocompletion invoke the Functions.ps1: + . .\Functions.ps1 (with a dot at the beginning). Read more in the Functions.ps1 file .EXAMPLE Run the whole script .\Sophia.ps1 + .EXAMPLE Run the script by specifying the module functions as an argument + .\Sophia.ps1 -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", UninstallUWPApps + .NOTES Supported Windows 10 versions - Versions: 2004 (20H1)/20H2 (2009)/21H1 + Versions: 2004/20H2/21H1 Builds: 19041/19042/19043 Editions: Home/Pro/Enterprise Architecture: x64 @@ -54,15 +59,50 @@ #Requires -RunAsAdministrator #Requires -Version 7.1 +[CmdletBinding()] +param +( + [Parameter(Mandatory = $false)] + [string[]] + $Functions +) + Clear-Host -$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script v5.10 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" +$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script v5.10.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2014–2021" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia +<# + .SYNOPSIS + Run the script by specifying the module functions as an argument + Запустить скрипт, указав в качестве аргумента функции модуля + + .EXAMPLE + .\Sophia.ps1 -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", UninstallUWPApps + + .NOTES + Separate functions with a comma +#> +if ($Functions) +{ + # Regardless of the functions entered as an argument, the "Checkings" function will be executed first, + # and the "Refresh" and "Errors" functions will be executed at the end + Invoke-Command -ScriptBlock {Checkings} + + foreach ($Function in $Functions) + { + Invoke-Expression -Command $Function + } + + Invoke-Command -ScriptBlock {Refresh; Errors} + + exit +} + #region Protection <# Checkings @@ -88,12 +128,12 @@ CreateRestorePoint #endregion Protection #region Privacy & Telemetry -# Disable the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and block connection -# Отключить службу DiagTrack, правила брандмауэра для исходящего трафик клиента единой телеметрии и заблокировать соединение +# Disable the DiagTrack service, and block connection for the Unified Telemetry Client Outbound Traffic +# Отключить службу DiagTrack и заблокировать соединение для исходящего трафик клиента единой телеметрии DiagTrackService -Disable -# Enable the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and allow connection -# Включить службу DiagTrack, правила брандмауэра для исходящего трафик клиента единой телеметрии и разрешить соединение +# Enable the DiagTrack service, and allow connection for the Unified Telemetry Client Outbound Traffic +# Включить службу DiagTrack и разрешить соединение для исходящего трафик клиента единой телеметрии # DiagTrackService -Enable # Set the OS level of diagnostic data gathering to minimum @@ -105,7 +145,7 @@ DiagnosticDataLevel -Minimal # DiagnosticDataLevel -Default # Turn off the Windows Error Reporting -# Отключить отчеты об ошибках Windows +# Отключить запись отчетов об ошибках Windows ErrorReporting -Disable # Turn on the Windows Error Reporting (default value) @@ -262,7 +302,7 @@ MergeConflicts -Show # Открывать проводник для: "Этот компьютер" OpenFileExplorerTo -ThisPC -# Open File Explorer to: "Quick access" (default value) +# Open File Explorer to: Quick access (default value) # Открывать проводник для: "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess @@ -311,15 +351,15 @@ SecondsInSystemClock -Show SnapAssist -Disable # When I snap a window, show what I can snap next to it (default value) -# При прикреплении окна не показывать/показывать, что можно прикрепить рядом с ним (значение по умолчанию) +# При прикреплении окна показывать, что можно прикрепить рядом с ним (значение по умолчанию) # SnapAssist -Enable -# Always open the file transfer dialog box in the detailed mode -# Всегда открывать диалоговое окно передачи файлов в развернутом виде +# Show the file transfer dialog box in the detailed mode +# Отображать диалоговое окно передачи файлов в развернутом виде FileTransferDialog -Detailed -# Always open the file transfer dialog box in the compact mode (default value) -# Всегда открывать диалоговое окно передачи файлов в свернутом виде (значение по умолчанию) +# Show the file transfer dialog box in the compact mode (default value) +# Отображать диалоговое окно передачи файлов в свернутом виде (значение по умолчанию) # FileTransferDialog -Compact # Expand the File Explorer ribbon @@ -330,28 +370,28 @@ FileExplorerRibbon -Expanded # Свернуть ленту проводника (значение по умолчанию) # FileExplorerRibbon -Minimized -# Display the recycle bin files delete confirmation +# Display the recycle bin files delete confirmation dialog # Запрашивать подтверждение на удаление файлов в корзину RecycleBinDeleteConfirmation -Enable -# Do not display the recycle bin files delete confirmation (default value) +# Do not display the recycle bin files delete confirmation dialog (default value) # Не запрашивать подтверждение на удаление файлов в корзину (значение по умолчанию) # RecycleBinDeleteConfirmation -Disable -# Hide the "3D Objects" folder in "This PC" and "Quick access" +# Hide the "3D Objects" folder in "This PC" and Quick access # Скрыть папку "Объемные объекты" в "Этот компьютер" и панели быстрого доступа 3DObjects -Hide -# Show the "3D Objects" folder in "This PC" and "Quick access" (default value) +# Show the "3D Objects" folder in "This PC" and Quick access (default value) # Отобразить папку "Объемные объекты" в "Этот компьютер" и панели быстрого доступа (значение по умолчанию) # 3DObjects -Show -# Hide frequently used folders in "Quick access" +# Hide frequently used folders in Quick access # Скрыть недавно используемые папки на панели быстрого доступа QuickAccessFrequentFolders -Hide -# Show frequently used folders in "Quick access" (default value) -# Показать недавно используемые папки на панели быстрого доступа (значение по умолчанию) +# Show frequently used folders in Quick access (default value) +# Показать часто используемые папки на панели быстрого доступа (значение по умолчанию) # QuickAccessFrequentFolders -Show # Do not show recently used files in Quick access @@ -374,11 +414,11 @@ TaskbarSearch -Hide # Показать поле поиска на панели задач (значение по умолчанию) # TaskbarSearch -SearchBox -# Do not show the "Windows Ink Workspace" button on the taskbar +# Do not show the Windows Ink Workspace button on the taskbar # Не показывать кнопку Windows Ink Workspace на панели задач WindowsInkWorkspace -Hide -# Show the "Windows Ink Workspace" button in taskbar (default value) +# Show Windows Ink Workspace button on the taskbar (default value) # Показать кнопку Windows Ink Workspace на панели задач (значение по умолчанию) # WindowsInkWorkspace -Show @@ -411,7 +451,7 @@ ControlPanelView -LargeIcons # ControlPanelView -SmallIcons # View the Control Panel icons by: category (default value) -# Просмотр значки Панели управления как "категория" (значение по умолчанию) +# Просмотр значки Панели управления как: категория (значение по умолчанию) # ControlPanelView -Category # Set the Windows mode color scheme to the dark @@ -422,12 +462,12 @@ WindowsColorScheme -Dark # Установить режим цвета для Windows на светлый # WindowsColorScheme -Light -# Set the default app mode color scheme to the dark -# Установить цвет режима приложений по умолчанию на темный +# Set the app mode color scheme to the dark +# Установить цвет режима приложений на темный AppMode -Dark -# Set the default app mode color scheme to the light -# Установить цвет режима приложений по умолчанию на светлый +# Set the app mode color scheme to the light +# Установить цвет режима приложений на светлый # AppMode -Light # Do not show the "New App Installed" indicator diff --git a/Sophia/PowerShell 7/Sophia.psd1 b/Sophia/PowerShell 7/Sophia.psd1 index 7121e35e..62453fd1 100644 --- a/Sophia/PowerShell 7/Sophia.psd1 +++ b/Sophia/PowerShell 7/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'Sophia.psm1' - ModuleVersion = '5.10' + ModuleVersion = '5.10.1' GUID = 'aa0b47a7-1770-4b5d-8c9f-cc6c505bcc7a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2015–2021 farag & oZ-Zo. All rights reserved.' diff --git a/Sophia/PowerShell 7/Sophia.psm1 b/Sophia/PowerShell 7/Sophia.psm1 index d83dbaf2..455f4dc1 100644 --- a/Sophia/PowerShell 7/Sophia.psm1 +++ b/Sophia/PowerShell 7/Sophia.psm1 @@ -2,9 +2,11 @@ .SYNOPSIS "Windows 10 Sophia Script" is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks - Version: v5.10 - Date: 09.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.10.1 + Date: 14.04.2021 + + Copyright (c) 2014–2021 farag + Copyright (c) 2019–2021 farag & oZ-Zo Thanks to all https://forum.ru-board.com members involved @@ -13,7 +15,7 @@ .NOTES Supported Windows 10 versions - Versions: 2004 (20H1)/20H2 (2009)/21H1 + Versions: 2004/20H2/21H1 Builds: 19041/19042/19043 Editions: Home/Pro/Enterprise Architecture: x64 @@ -164,13 +166,13 @@ function CreateRestorePoint #region Privacy & Telemetry <# .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 - 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 - 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 DiagTrackService -Disable @@ -207,7 +209,7 @@ function DiagTrackService Get-Service -Name DiagTrack | Set-Service -StartupType Automatic 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 } "Disable" @@ -215,7 +217,7 @@ function DiagTrackService Get-Service -Name DiagTrack | Stop-Service -Force 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 } } @@ -1525,7 +1527,7 @@ function MergeConflicts Open File Explorer to "This PC" .PARAMETER QuickAccess - Open File Explorer to "Quick access" + Open File Explorer to Quick access .EXAMPLE OpenFileExplorerTo -ThisPC @@ -1884,13 +1886,13 @@ function SnapAssist <# .SYNOPSIS - Configure the file transfer dialog box + Configure the file transfer dialog box mode .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 - Always open the file transfer dialog box in the compact mode + Show the file transfer dialog box in the compact mode .EXAMPLE FileTransferDialog -Detailed @@ -2002,13 +2004,13 @@ function FileExplorerRibbon <# .SYNOPSIS - Configure the recycle bin files delete confirmation + Configure the recycle bin files delete confirmation dialog .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 - Display/do not display the recycle bin files delete confirmation + Display/do not display the recycle bin files delete confirmation dialog .EXAMPLE RecycleBinDeleteConfirmation -Disable @@ -2084,13 +2086,13 @@ public static void PostMessage() <# .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 - Show the "3D Objects" folder in "This PC" and "Quick access" + Show the "3D Objects" folder in "This PC" and Quick access .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 3DObjects -Show @@ -2157,13 +2159,13 @@ function 3DObjects <# .SYNOPSIS - Configure frequently used folders in "Quick access" + Configure frequently used folders in Quick access .PARAMETER Show - Show frequently used folders in "Quick access" + Show frequently used folders in Quick access .PARAMETER Hide - Hide frequently used folders in "Quick access" + Hide frequently used folders in Quick access .EXAMPLE QuickAccessFrequentFolders -Show @@ -2327,13 +2329,13 @@ function TaskbarSearch <# .SYNOPSIS - Configure the "Windows Ink Workspace" button on the taskbar + Configure the Windows Ink Workspace button on the taskbar .PARAMETER Show - Show the "Windows Ink Workspace" button on the taskbar + Show the Windows Ink Workspace button on the taskbar .PARAMETER Hide - Hide the "Windows Ink Workspace" button on the taskbar + Hide the Windows Ink Workspace button on the taskbar .EXAMPLE WindowsInkWorkspace -Show @@ -2692,10 +2694,10 @@ function WindowsColorScheme Configure the default app mode color scheme .PARAMETER Light - Set the default app mode color scheme to the light + Set the app mode color scheme to the light .PARAMETER Dark - Set the default app mode color scheme to the dark + Set the app mode color scheme to the dark .EXAMPLE AppMode -Light @@ -3864,7 +3866,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false 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 { Copy-Item $_.FullName -Destination $env:LOCALAPPDATA\Temp -Recurse -Force } @@ -7779,25 +7781,24 @@ function PinToStart $UnpinAll, [Parameter( - Mandatory = $true, + Mandatory = $false, Position = 1 )] [ValidateSet("ControlPanel", "DevicesPrinters", "PowerShell")] [string[]] - $Tiles, - - [string] - $StartLayout = "$PSScriptRoot\StartLayout.xml" + $Tiles ) begin { + $Script:StartLayout = "$PSScriptRoot\StartLayout.xml" + # Unpin all the Start tiles if ($UnpinAll) { - Export-StartLayout -Path $StartLayout -UseDesktopApplicationID + Export-StartLayout -Path $Script:StartLayout -UseDesktopApplicationID - [xml]$XML = Get-Content -Path $StartLayout -Encoding UTF8 -Force + [xml]$XML = Get-Content -Path $Script:StartLayout -Encoding UTF8 -Force $Groups = $XML.LayoutModificationTemplate.DefaultLayoutOverride.StartLayoutCollection.StartLayout.Group foreach ($Group in $Groups) @@ -7806,7 +7807,7 @@ function PinToStart $Group.ParentNode.RemoveChild($Group) | Out-Null } - $XML.Save($StartLayout) + $XML.Save($Script:StartLayout) } } @@ -7841,8 +7842,22 @@ public static string GetString(uint strId) # Extract the localized "Devices and Printers" string from shell32.dll $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 - $Script:DevicesPrintersAppID = (Get-StartApps | Where-Object -FilterScript {$_.Name -eq $DevicesPrinters}).AppID + $DevicesPrintersAppID = (Get-StartApps | Where-Object -FilterScript {$_.Name -eq $DevicesPrinters}).AppID $Parameters = @( # Control Panel hash table @@ -7861,7 +7876,7 @@ public static string GetString(uint strId) Size = "2x2" Column = 2 Row = 0 - AppID = $Script:DevicesPrintersAppID + AppID = $DevicesPrintersAppID }, # Windows PowerShell hash table @{ @@ -7906,13 +7921,13 @@ public static string GetString(uint strId) $Table } - if (-not (Test-Path -Path $StartLayout)) + if (-not (Test-Path -Path $Script:StartLayout)) { # Export the current Start layout - Export-StartLayout -Path $StartLayout -UseDesktopApplicationID + Export-StartLayout -Path $Script:StartLayout -UseDesktopApplicationID } - [xml]$XML = Get-Content -Path $StartLayout -Encoding UTF8 -Force + [xml]$XML = Get-Content -Path $Script:StartLayout -Encoding UTF8 -Force foreach ($Tile in $Tiles) { @@ -7926,16 +7941,6 @@ public static string GetString(uint strId) DevicesPrinters { 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 { @@ -7975,7 +7980,7 @@ public static string GetString(uint strId) } } - $XML.Save($StartLayout) + $XML.Save($Script:StartLayout) } end @@ -7986,7 +7991,7 @@ public static string GetString(uint strId) 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 StartLayoutFile -Value $StartLayout -Force + New-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name StartLayoutFile -Value $Script:StartLayout -Force 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 StartLayoutFile -Force -ErrorAction Ignore - Remove-Item -Path $StartLayout -Force + Remove-Item -Path $Script:StartLayout -Force Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore @@ -8033,9 +8038,9 @@ public static string GetString(uint strId) UninstallUWPApps -ForAllUsers .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 - CsWinRT v1.1.4 - Microsoft.Windows.SDK.NET 10.0.19041.15 + 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 @@ -8154,7 +8159,7 @@ function UninstallUWPApps xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="Window" - MinHeight="400" MinWidth="410" + MinHeight="400" MinWidth="415" SizeToContent="Width" WindowStartupLocation="CenterScreen" TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True" FontFamily="Candara" FontSize="16" ShowInTaskbar="True"> @@ -8445,6 +8450,15 @@ function UninstallUWPApps .NOTES 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 A pop-up dialog box enables the user to select packages Current user @@ -8541,7 +8555,7 @@ function RestoreUWPApps #region Functions function Get-AppxManifest { - Write-Verbose -Message "Patient" -Verbose + Write-Verbose -Message $Localization.Patient -Verbose # Тут нельзя напрямую вписать -PackageTypeFilter Bundle, так как иначе не выдается нужное свойство InstallLocation. Только сравнивать с $Bundles $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name @@ -11813,6 +11827,15 @@ public static void PostMessage() 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\Microsoft.Windows.SDK.NET.dll"