Browse Source

Code refactoring

master
Dmitry Nefedov 1 year ago
parent
commit
10f2cc11c1
  1. 6
      Wrapper/Config/config_Windows_11.json
  2. 10
      Wrapper/Localizations/de-DE/tooltip_Windows_11.json
  3. 6
      Wrapper/Localizations/en-US/tooltip_Windows_11.json
  4. 8
      Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
  5. 79
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 4
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  7. 79
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  8. 8
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

6
Wrapper/Config/config_Windows_11.json

@ -633,13 +633,13 @@
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "TaskbarChat",
"Function": "TeamsInstallation",
"Arg": {
"Zero": {
"Tag": "Hide"
"Tag": "Disable"
},
"One": {
"Tag": "Show"
"Tag": "Enable"
}
},
"Preset": "Zero",

10
Wrapper/Localizations/de-DE/tooltip_Windows_11.json

@ -557,15 +557,15 @@
{
"Id": 318,
"Region": "UI & Personalization",
"Function": "TaskbarChat",
"Function": "TeamsInstallation",
"Arg": {
"Zero": {
"Tag": "Hide",
"ToolTip": "Blendet das Chat-Symbol (Microsoft Teams) in der Taskleiste aus und verhindert die Installation von Microsoft Teams für neue Benutzer."
"Tag": "Disable",
"ToolTip": "Verhindern Sie die Installation von Chat (Microsoft Teams) für neue Benutzer."
},
"One": {
"Tag": "Show",
"ToolTip": "Zeigt das Chat-Symbol (Microsoft Teams) in der Taskleiste an und ermöglicht die Installation von Microsoft Teams für neue Benutzer (Standardeinstellung)."
"Tag": "Enable",
"ToolTip": "Verhindern Sie nicht, dass Microsoft Teams für neue Benutzer installiert wird (Standardeinstellung)."
}
}
},

6
Wrapper/Localizations/en-US/tooltip_Windows_11.json

@ -557,15 +557,15 @@
{
"Id": 318,
"Region": "UI & Personalization",
"Function": "TaskbarChat",
"Function": "TeamsInstallation",
"Arg": {
"Zero": {
"Tag": "Hide",
"ToolTip": "Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users."
"ToolTip": "Prevent Chat (Microsoft Teams) from installing for new users."
},
"One": {
"Tag": "Show",
"ToolTip": "Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users (default value)."
"ToolTip": "Do not prevent Microsoft Teams from installing for new users (default value)."
}
}
},

8
Wrapper/Localizations/ru-RU/tooltip_Windows_11.json

@ -557,14 +557,14 @@
{
"Id": 318,
"Region": "UI & Personalization",
"Function": "TaskbarChat",
"Function": "TeamsInstallation",
"Arg": {
"Zero": {
"Tag": "Hide",
"ToolTip": "Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей."
"Tag": "Disable",
"ToolTip": "Запретить установку Chat (Microsoft Teams) для новых пользователей."
},
"One": {
"Tag": "Show",
"Tag": "Enable",
"ToolTip": "Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)."
}
}

79
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -3242,58 +3242,54 @@ function TaskViewButton
<#
.SYNOPSIS
The Chat icon (Microsoft Teams) on the taskbar
Chat (Microsoft Teams) installation for new users
.PARAMETER Hide
Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users
.PARAMETER Disable
Prevent Chat (Microsoft Teams) from installing for new users
.PARAMETER Show
Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users
.PARAMETER Enable
Do not prevent Microsoft Teams from installing for new users
.EXAMPLE
TaskbarChat -Hide
TeamsInstallation -Disable
.EXAMPLE
TaskbarChat -Show
TeamsInstallation -Enable
.NOTES
Current user
#>
function TaskbarChat
function TeamsInstallation
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Hide"
ParameterSetName = "Disable"
)]
[switch]
$Hide,
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Show"
ParameterSetName = "Enable"
)]
[switch]
$Show
$Enable
)
Clear-Variable -Name Task -ErrorAction Ignore
switch ($PSCmdlet.ParameterSetName)
{
"Hide"
"Disable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarMn -PropertyType DWord -Value 0 -Force
# Save string to run it as "NT SERVICE\TrustedInstaller"
# Prevent Microsoft Teams from installing for new users
$Task = "New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications -Name ConfigureChatAutoInstall -Value 0 -Type Dword -Force"
}
"Show"
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarMn -PropertyType DWord -Value 1 -Force
# Save string to run it as "NT SERVICE\TrustedInstaller"
# Remove block from installing Microsoft Teams for new users
$Task = "Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications -Name ConfigureChatAutoInstall -Value 1 -Type Dword -Force"
@ -10729,37 +10725,32 @@ function UninstallUWPApps
$AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
# The Bundle packages contains no Microsoft Teams
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers)
{
# Temporarily hack: due to the fact that there are actually two Microsoft Teams packages, we need to choose the first one to display
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers | Select-Object -Index 0
}
# The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually
$Packages = @(
# Spotify
"SpotifyAB.SpotifyMusic",
# The Bundle packages contains no Spotify
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers)
{
$AppxPackages += Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers
}
# Disney+
"Disney.37853FC22B2CE",
# The Bundle packages contains no Disney+
if (Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers)
{
$AppxPackages += Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers
}
# Outlook
"Microsoft.OutlookForWindows",
# The Bundle packages contains no Outlook
if (Get-AppxPackage -Name Microsoft.OutlookForWindows -AllUsers:$AllUsers)
# Chat (Microsoft Teams)
"MicrosoftTeams"
)
foreach ($Package in $Packages)
{
$AppxPackages += Get-AppxPackage -Name Microsoft.OutlookForWindows -AllUsers:$AllUsers
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
@ -11101,15 +11092,7 @@ function RestoreUWPApps
# The Bundle packages contains no Microsoft Teams
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers)
{
# Temporarily hack: due to the fact that there are actually two Microsoft Teams packages, we need to choose the first one to display
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Select-Object -Index 0
}
# The Bundle packages contains no Spotify
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers)
{
# Temporarily hack: due to the fact that there are actually two Spotify packages, we need to choose the first one to display
$AppxPackages += Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Select-Object -Index 0
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"}
}
$PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName

4
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -407,11 +407,11 @@ TaskViewButton -Hide
# Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users
# Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей
TaskbarChat -Hide
PreventTeamsInstallation -Hide
# Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users (default value)
# Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)
# TaskbarChat -Show
# PreventTeamsInstallation -Show
# Show seconds on the taskbar clock
# Показывать секунды на часах на панели задач

79
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -3243,58 +3243,54 @@ function TaskViewButton
<#
.SYNOPSIS
The Chat icon (Microsoft Teams) on the taskbar
Chat (Microsoft Teams) installation for new users
.PARAMETER Hide
Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users
.PARAMETER Disable
Prevent Chat (Microsoft Teams) from installing for new users
.PARAMETER Show
Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users
.PARAMETER Enable
Do not prevent Microsoft Teams from installing for new users
.EXAMPLE
TaskbarChat -Hide
TeamsInstallation -Disable
.EXAMPLE
TaskbarChat -Show
TeamsInstallation -Enable
.NOTES
Current user
#>
function TaskbarChat
function TeamsInstallation
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Hide"
ParameterSetName = "Disable"
)]
[switch]
$Hide,
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Show"
ParameterSetName = "Enable"
)]
[switch]
$Show
$Enable
)
Clear-Variable -Name Task -ErrorAction Ignore
switch ($PSCmdlet.ParameterSetName)
{
"Hide"
"Disable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarMn -PropertyType DWord -Value 0 -Force
# Save string to run it as "NT SERVICE\TrustedInstaller"
# Prevent Microsoft Teams from installing for new users
$Task = "New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications -Name ConfigureChatAutoInstall -Value 0 -Type Dword -Force"
}
"Show"
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarMn -PropertyType DWord -Value 1 -Force
# Save string to run it as "NT SERVICE\TrustedInstaller"
# Remove block from installing Microsoft Teams for new users
$Task = "Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications -Name ConfigureChatAutoInstall -Value 1 -Type Dword -Force"
@ -10740,37 +10736,32 @@ function UninstallUWPApps
$AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
# The Bundle packages contains no Microsoft Teams
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers)
{
# Temporarily hack: due to the fact that there are actually two Microsoft Teams packages, we need to choose the first one to display
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers | Select-Object -Index 0
}
# The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually
$Packages = @(
# Spotify
"SpotifyAB.SpotifyMusic",
# The Bundle packages contains no Spotify
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers)
{
$AppxPackages += Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers
}
# Disney+
"Disney.37853FC22B2CE",
# The Bundle packages contains no Disney+
if (Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers)
{
$AppxPackages += Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers
}
# Outlook
"Microsoft.OutlookForWindows",
# The Bundle packages contains no Outlook
if (Get-AppxPackage -Name Microsoft.OutlookForWindows -AllUsers:$AllUsers)
# Chat (Microsoft Teams)
"MicrosoftTeams"
)
foreach ($Package in $Packages)
{
$AppxPackages += Get-AppxPackage -Name Microsoft.OutlookForWindows -AllUsers:$AllUsers
if (Get-AppxPackage -Name $Package -AllUsers:$AllUsers)
{
$AppxPackages += Get-AppxPackage -Name $Package -AllUsers:$AllUsers
}
}
$PackagesIds = [Windows.Management.Deployment.PackageManager]::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
@ -11122,15 +11113,7 @@ function RestoreUWPApps
# The Bundle packages contains no Microsoft Teams
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers)
{
# Temporarily hack: due to the fact that there are actually two Microsoft Teams packages, we need to choose the first one to display
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Select-Object -Index 0
}
# The Bundle packages contains no Spotify
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers)
{
# Temporarily hack: due to the fact that there are actually two Spotify packages, we need to choose the first one to display
$AppxPackages += Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Select-Object -Index 0
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"}
}
$PackagesIds = [Windows.Management.Deployment.PackageManager]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName

8
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -414,13 +414,13 @@ TaskViewButton -Hide
# Отобразить кнопку "Представление задач" на панели задач (значение по умолчанию)
# TaskViewButton -Show
# Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users
# Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей
TaskbarChat -Hide
# Prevent Chat (Microsoft Teams) from installing for new users
# Запретить установку Chat (Microsoft Teams) для новых пользователей
TeamsInstallation -Hide
# Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users (default value)
# Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)
# TaskbarChat -Show
# TeamsInstallation -Show
# Show seconds on the taskbar clock
# Показывать секунды на часах на панели задач

Loading…
Cancel
Save