categories/Desktop.ps1
|
# Desktop category: desktop icon visibility + shortcut arrow overlay. All HKCU, no elevation. # research.md -> desktop category table. function Get-OctaDesktopCategory { [CmdletBinding()] param() return [pscustomobject]@{ Id = 'desktop' DisplayName = 'Desktop' Description = 'Desktop icon visibility, shortcut arrow overlay' RequiresElevation = $false ContainsIrreversibleActions = $false GetActionsFunction = 'Get-OctaDesktopActions' ApplyActionFunction = 'Set-OctaDesktopAction' } } $script:OctaDesktopIcons = @( @{ Guid = '{20D04FE0-3AEA-1069-A2D8-08002B30309D}'; Label = 'This PC' } @{ Guid = '{645FF040-5081-101B-9F08-00AA002F954E}'; Label = 'Recycle Bin' } @{ Guid = '{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}'; Label = 'Network' } @{ Guid = '{59031a47-3f72-44a7-89c5-5595fe6b30ee}'; Label = "User's Files" } @{ Guid = '{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}'; Label = 'Control Panel' } ) function Get-OctaDesktopActions { [CmdletBinding()] param() $actions = @() $iconsKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' foreach ($icon in $script:OctaDesktopIcons) { $current = (Get-ItemProperty -Path $iconsKey -Name $icon.Guid -ErrorAction SilentlyContinue).($icon.Guid) if ($null -eq $current -or $current -ne 0) { $displayCurrent = if ($null -eq $current) { '(not set)' } else { $current } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$iconsKey|$($icon.Guid)" ` -CurrentValue $displayCurrent -PlannedValue 0 -Reversible $true -RiskLevel Safe } } $shellIconsKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons' $currentArrow = (Get-ItemProperty -Path $shellIconsKey -Name '29' -ErrorAction SilentlyContinue).'29' $blankIcon = '%SystemRoot%\System32\shell32.dll,-50' if ($currentArrow -ne $blankIcon) { $displayCurrent = if ($null -eq $currentArrow) { '(not set)' } else { $currentArrow } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$shellIconsKey|29" ` -CurrentValue $displayCurrent -PlannedValue $blankIcon -Reversible $true -RiskLevel Safe } return $actions } function Set-OctaDesktopAction { [CmdletBinding()] param([Parameter(Mandatory)]$Action) $keyPath, $valueName = $Action.TargetIdentifier -split '\|', 2 if (-not (Test-Path $keyPath)) { New-Item -Path $keyPath -Force | Out-Null } $type = if ($valueName -eq '29') { 'String' } else { 'DWord' } Set-ItemProperty -Path $keyPath -Name $valueName -Value $Action.PlannedValue -Type $type } |