PowerShell v3 Function Get UACControlSettings

Another of my current project functions. These settings correlate with slider definitions for the Control Panel | User Accounts | Change User Account Control Settings tick marks. Below is the basic function to read the settings:
function Get-UACControlSettings
{
       [CmdletBinding()]
       param()
      
       $ConsentPromptBehaviorAdmin = (Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem -Name ConsentPromptBehaviorAdmin).ConsentPromptBehaviorAdmin
       $PromptOnSecureDesktop = (Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem -Name PromptOnSecureDesktop).PromptOnSecureDesktop
      
       # ConsentPromptBehaviorAdmin = 0/PromptOnSecureDesktop = 0 - Never
       if(($ConsentPromptBehaviorAdmin -eq 0) -and ($PromptOnSecureDesktop -eq 0))
       {
             Write-Verbose "$(Get-TimeStamp): Never notify.";
             return Never
       }
      
       # ConsentPromptBehaviorAdmin = 3/PromptOnSecureDesktop = 0 - Notify - do not dim
       if(($ConsentPromptBehaviorAdmin -eq 3) -and ($PromptOnSecureDesktop -eq 0))
       {
             Write-Verbose "$(Get-TimeStamp): Notify only when programs try to make changes to computer (do not dim desktop).";
             return Notify - do not dim;
       }
      
       # ConsentPromptBehaviorAdmin = 0/PromptOnSecureDesktop = 1 - Default    
       if(($ConsentPromptBehaviorAdmin -eq 3) -and ($PromptOnSecureDesktop -eq 1))
       {
             Write-Verbose "$(Get-TimeStamp): Default - Notify only when programs try to make changes to computer.";
              return Default;
       }
      
       # ConsentPromptBehaviorAdmin = 0/PromptOnSecureDesktop = 0 - Never
       if(($ConsentPromptBehaviorAdmin -eq 2) -and ($PromptOnSecureDesktop -eq 1))
       {
             Write-Verbose "$(Get-TimeStamp): Always notify.";
             return Always;
       }
}

Related Posts by Categories

0 comments:

Post a Comment