PowerShell v3 Function Get ControlPanelView

Earlier this year I posted on how to track down registry tweaks with some incomplete information. After reworking the underlying function, I came up with this:
function Get-ControlPanelView
{
       [CmdletBinding()]
       param()
      
       Write-Verbose "$(Get-TimeStamp): Getting Control Panel View icon status.";
       $AllItemsIconView = (Get-ItemProperty -Path "HKCU:SoftwareMicrosoftWindowsCurrentVersionExplorerControlPanel" -Name AllItemsIconView).AllItemsIconView
       $StartupPage = (Get-ItemProperty -Path "HKCU:SoftwareMicrosoftWindowsCurrentVersionExplorerControlPanel" -Name StartupPage).StartupPage
      
       # $AllItemsIconView = 0/$StartupPage = 1 : Large Icons
       if(($AllItemsIconView -eq 0) -and ($StartupPage -eq 1))
       {
             Write-Verbose "$(Get-TimeStamp): Control Panel View set to `"Large Icons`"."
             return Large Icons;                  
       }

       # $AllItemsIconView = 1/$StartupPage = 0 : Category               
       if(($AllItemsIconView -eq 1) -and ($StartupPage -eq 0))
       {
             Write-Verbose "$(Get-TimeStamp): Control Panel View set to `"Category`"."
             return Category;
       }
      
       # $AllItemsIconView = 1/$StartupPage = 1 : Small Icons
       if(($AllItemsIconView -eq 1) -and ($StartupPage -eq 1))
       {
             Write-Verbose "$(Get-TimeStamp): Control Panel View set to `"Small Icons`"."
             return Small Icons;                  
       }
}
When I run this, it is a simple command which can use -Verbose to get more details.
 

Related Posts by Categories

0 comments:

Post a Comment