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", "Region": "UI & Personalization",
"Control": "cmb", "Control": "cmb",
"Required": "false", "Required": "false",
"Function": "TaskbarChat", "Function": "TeamsInstallation",
"Arg": { "Arg": {
"Zero": { "Zero": {
"Tag": "Hide" "Tag": "Disable"
}, },
"One": { "One": {
"Tag": "Show" "Tag": "Enable"
} }
}, },
"Preset": "Zero", "Preset": "Zero",

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

@ -557,15 +557,15 @@
{ {
"Id": 318, "Id": 318,
"Region": "UI & Personalization", "Region": "UI & Personalization",
"Function": "TaskbarChat", "Function": "TeamsInstallation",
"Arg": { "Arg": {
"Zero": { "Zero": {
"Tag": "Hide", "Tag": "Disable",
"ToolTip": "Blendet das Chat-Symbol (Microsoft Teams) in der Taskleiste aus und verhindert die Installation von Microsoft Teams für neue Benutzer." "ToolTip": "Verhindern Sie die Installation von Chat (Microsoft Teams) für neue Benutzer."
}, },
"One": { "One": {
"Tag": "Show", "Tag": "Enable",
"ToolTip": "Zeigt das Chat-Symbol (Microsoft Teams) in der Taskleiste an und ermöglicht die Installation von Microsoft Teams für neue Benutzer (Standardeinstellung)." "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, "Id": 318,
"Region": "UI & Personalization", "Region": "UI & Personalization",
"Function": "TaskbarChat", "Function": "TeamsInstallation",
"Arg": { "Arg": {
"Zero": { "Zero": {
"Tag": "Hide", "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": { "One": {
"Tag": "Show", "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, "Id": 318,
"Region": "UI & Personalization", "Region": "UI & Personalization",
"Function": "TaskbarChat", "Function": "TeamsInstallation",
"Arg": { "Arg": {
"Zero": { "Zero": {
"Tag": "Hide", "Tag": "Disable",
"ToolTip": "Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей." "ToolTip": "Запретить установку Chat (Microsoft Teams) для новых пользователей."
}, },
"One": { "One": {
"Tag": "Show", "Tag": "Enable",
"ToolTip": "Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)." "ToolTip": "Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)."
} }
} }

79
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -3242,58 +3242,54 @@ function TaskViewButton
<# <#
.SYNOPSIS .SYNOPSIS
The Chat icon (Microsoft Teams) on the taskbar Chat (Microsoft Teams) installation for new users
.PARAMETER Hide .PARAMETER Disable
Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users Prevent Chat (Microsoft Teams) from installing for new users
.PARAMETER Show .PARAMETER Enable
Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users Do not prevent Microsoft Teams from installing for new users
.EXAMPLE .EXAMPLE
TaskbarChat -Hide TeamsInstallation -Disable
.EXAMPLE .EXAMPLE
TaskbarChat -Show TeamsInstallation -Enable
.NOTES .NOTES
Current user Current user
#> #>
function TaskbarChat function TeamsInstallation
{ {
param param
( (
[Parameter( [Parameter(
Mandatory = $true, Mandatory = $true,
ParameterSetName = "Hide" ParameterSetName = "Disable"
)] )]
[switch] [switch]
$Hide, $Disable,
[Parameter( [Parameter(
Mandatory = $true, Mandatory = $true,
ParameterSetName = "Show" ParameterSetName = "Enable"
)] )]
[switch] [switch]
$Show $Enable
) )
Clear-Variable -Name Task -ErrorAction Ignore Clear-Variable -Name Task -ErrorAction Ignore
switch ($PSCmdlet.ParameterSetName) 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" # Save string to run it as "NT SERVICE\TrustedInstaller"
# Prevent Microsoft Teams from installing for new users # 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" $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" # Save string to run it as "NT SERVICE\TrustedInstaller"
# Remove block from installing Microsoft Teams for new users # 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" $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}) $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
# The Bundle packages contains no Microsoft Teams # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers) $Packages = @(
{ # Spotify
# Temporarily hack: due to the fact that there are actually two Microsoft Teams packages, we need to choose the first one to display "SpotifyAB.SpotifyMusic",
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers | Select-Object -Index 0
}
# The Bundle packages contains no Spotify # Disney+
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers) "Disney.37853FC22B2CE",
{
$AppxPackages += Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers
}
# The Bundle packages contains no Disney+ # Outlook
if (Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers) "Microsoft.OutlookForWindows",
{
$AppxPackages += Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers
}
# The Bundle packages contains no Outlook # Chat (Microsoft Teams)
if (Get-AppxPackage -Name Microsoft.OutlookForWindows -AllUsers:$AllUsers) "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 $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) foreach ($AppxPackage in $AppxPackages)
{ {
$PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name} $PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
if (-not $PackageId) if (-not $PackageId)
{ {
continue continue
@ -11101,15 +11092,7 @@ function RestoreUWPApps
# The Bundle packages contains no Microsoft Teams # The Bundle packages contains no Microsoft Teams
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers) 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"}
$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
} }
$PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName $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 # Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users
# Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей # Скрыть кнопку чата (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) # 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 для новых пользователей (значение по умолчанию) # Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)
# TaskbarChat -Show # PreventTeamsInstallation -Show
# Show seconds on the taskbar clock # 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 .SYNOPSIS
The Chat icon (Microsoft Teams) on the taskbar Chat (Microsoft Teams) installation for new users
.PARAMETER Hide .PARAMETER Disable
Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users Prevent Chat (Microsoft Teams) from installing for new users
.PARAMETER Show .PARAMETER Enable
Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users Do not prevent Microsoft Teams from installing for new users
.EXAMPLE .EXAMPLE
TaskbarChat -Hide TeamsInstallation -Disable
.EXAMPLE .EXAMPLE
TaskbarChat -Show TeamsInstallation -Enable
.NOTES .NOTES
Current user Current user
#> #>
function TaskbarChat function TeamsInstallation
{ {
param param
( (
[Parameter( [Parameter(
Mandatory = $true, Mandatory = $true,
ParameterSetName = "Hide" ParameterSetName = "Disable"
)] )]
[switch] [switch]
$Hide, $Disable,
[Parameter( [Parameter(
Mandatory = $true, Mandatory = $true,
ParameterSetName = "Show" ParameterSetName = "Enable"
)] )]
[switch] [switch]
$Show $Enable
) )
Clear-Variable -Name Task -ErrorAction Ignore Clear-Variable -Name Task -ErrorAction Ignore
switch ($PSCmdlet.ParameterSetName) 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" # Save string to run it as "NT SERVICE\TrustedInstaller"
# Prevent Microsoft Teams from installing for new users # 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" $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" # Save string to run it as "NT SERVICE\TrustedInstaller"
# Remove block from installing Microsoft Teams for new users # 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" $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}) $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
# The Bundle packages contains no Microsoft Teams # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers) $Packages = @(
{ # Spotify
# Temporarily hack: due to the fact that there are actually two Microsoft Teams packages, we need to choose the first one to display "SpotifyAB.SpotifyMusic",
$AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers:$AllUsers | Select-Object -Index 0
}
# The Bundle packages contains no Spotify # Disney+
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers) "Disney.37853FC22B2CE",
{
$AppxPackages += Get-AppxPackage -Name SpotifyAB.SpotifyMusic -AllUsers:$AllUsers
}
# The Bundle packages contains no Disney+ # Outlook
if (Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers) "Microsoft.OutlookForWindows",
{
$AppxPackages += Get-AppxPackage -Name Disney.37853FC22B2CE -AllUsers:$AllUsers
}
# The Bundle packages contains no Outlook # Chat (Microsoft Teams)
if (Get-AppxPackage -Name Microsoft.OutlookForWindows -AllUsers:$AllUsers) "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 $PackagesIds = [Windows.Management.Deployment.PackageManager]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
foreach ($AppxPackage in $AppxPackages) foreach ($AppxPackage in $AppxPackages)
{ {
$PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name} $PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
if (-not $PackageId) if (-not $PackageId)
{ {
continue continue
@ -11122,15 +11113,7 @@ function RestoreUWPApps
# The Bundle packages contains no Microsoft Teams # The Bundle packages contains no Microsoft Teams
if (Get-AppxPackage -Name MicrosoftTeams -AllUsers) 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"}
$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
} }
$PackagesIds = [Windows.Management.Deployment.PackageManager]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName $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 # TaskViewButton -Show
# Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users # Prevent Chat (Microsoft Teams) from installing for new users
# Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей # Запретить установку Chat (Microsoft Teams) для новых пользователей
TaskbarChat -Hide TeamsInstallation -Hide
# Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users (default value) # 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 для новых пользователей (значение по умолчанию) # Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию)
# TaskbarChat -Show # TeamsInstallation -Show
# Show seconds on the taskbar clock # Show seconds on the taskbar clock
# Показывать секунды на часах на панели задач # Показывать секунды на часах на панели задач

Loading…
Cancel
Save