categories/Widgets.ps1
|
# Widgets category: AllowNewsAndInterests policy value (disables the taskbar Widgets button). function Get-OctaWidgetsCategory { [CmdletBinding()] param() return [pscustomobject]@{ Id = 'widgets' DisplayName = 'Widgets' Description = 'Disable the taskbar Widgets panel' RequiresElevation = $true ContainsIrreversibleActions = $false GetActionsFunction = 'Get-OctaWidgetsActions' ApplyActionFunction = 'Set-OctaWidgetsAction' } } function Get-OctaWidgetsActions { [CmdletBinding()] param() $regPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Dsh' $current = $null if (Test-Path $regPath) { $current = (Get-ItemProperty -Path $regPath -Name 'AllowNewsAndInterests' -ErrorAction SilentlyContinue).AllowNewsAndInterests } if ($null -ne $current -and $current -eq 0) { return @() } $displayCurrent = if ($null -eq $current) { '(not set)' } else { $current } return @( New-OctaAction -TargetType Registry -TargetIdentifier "$regPath|AllowNewsAndInterests" ` -CurrentValue $displayCurrent -PlannedValue 0 -Reversible $true ) } function Set-OctaWidgetsAction { [CmdletBinding()] param([Parameter(Mandatory)]$Action) $keyPath, $valueName = $Action.TargetIdentifier -split '\|', 2 if (-not (Test-Path $keyPath)) { New-Item -Path $keyPath -Force | Out-Null } # PlannedValue, not a hardcoded 0 - see the same note in categories/Copilot.ps1. Set-ItemProperty -Path $keyPath -Name $valueName -Value $Action.PlannedValue -Type DWord } |