Sabtu, 24 Desember 2016

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.
 

lamsim

About lamsim

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :