{"id":809291,"date":"2026-05-18T07:00:33","date_gmt":"2026-05-18T07:00:33","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=809291"},"modified":"2026-05-18T07:00:33","modified_gmt":"2026-05-18T07:00:33","slug":"configure-uac-settings-windows-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/configure-uac-settings-windows-powershell\/","title":{"rendered":"Como definir as configura\u00e7\u00f5es de UAC para o Windows (Script do PowerShell)"},"content":{"rendered":"<p><a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-user-account-control-uac\/\">O Controle de Conta de Usu\u00e1rio (UAC)<\/a> \u00e9 um recurso de seguran\u00e7a vital nos sistemas operacionais Windows. Ele atua como um guardi\u00e3o, impedindo altera\u00e7\u00f5es n\u00e3o autorizadas em seu computador. O UAC funciona definindo diferentes n\u00edveis de permiss\u00f5es de usu\u00e1rio, variando de sempre notificar sobre altera\u00e7\u00f5es a nunca notificar. Ao compreender esses n\u00edveis e como eles afetam as permiss\u00f5es de usu\u00e1rio, os profissionais de TI podem proteger melhor seus sistemas.<\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>Introduzido com o Windows Vista, o UAC tem sido uma pedra angular da seguran\u00e7a do Windows. Quando se tenta fazer determinadas altera\u00e7\u00f5es, o UAC solicita aos usu\u00e1rios permiss\u00e3o ou uma senha de administrador antes de permitir que a tarefa prossiga. Esse script, adaptado ao Windows 7 e ao Windows Server 2012 em diante, oferece uma maneira de <strong>configurar programaticamente essas defini\u00e7\u00f5es de UAC<\/strong>.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 2.0\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Configures UAC.\r\n.DESCRIPTION\r\n    Configures UAC to defaults if no parameters are specified.\r\n.EXAMPLE\r\n    No parameters needed.\r\n    Sets all UAC settings to Microsoft's defaults.\r\n.EXAMPLE\r\n     -ConsentPromptBehaviorAdmin 5\r\n    Sets ConsentPromptBehaviorAdmin to 5\r\n.EXAMPLE\r\n    PS C:&gt; Set-Uac.ps1\r\n    Sets all UAC settings to MS defaults.\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 7, Windows Server 2012\r\n    This script will show before and after UAC settings.\r\n    Release Notes:\r\n    Initial Release\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n.COMPONENT\r\n    LocalUserAccountManagement\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()][ValidateRange(0, 5)][int]$ConsentPromptBehaviorAdmin = 5,\r\n    [Parameter()][ValidateRange(0, 3)][int]$ConsentPromptBehaviorUser = 3,\r\n    [Parameter()][ValidateRange(0, 1)][int]$EnableInstallerDetection = 1,\r\n    [Parameter()][ValidateRange(0, 1)][int]$EnableLUA = 1,\r\n    [Parameter()][ValidateRange(0, 1)][int]$EnableVirtualization = 1,\r\n    [Parameter()][ValidateRange(0, 1)][int]$PromptOnSecureDesktop = 1,\r\n    [Parameter()][ValidateRange(0, 1)][int]$ValidateAdminCodeSignatures = 0,\r\n    [Parameter()][ValidateRange(0, 1)][int]$FilterAdministratorToken = 0\r\n)\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))\r\n        { Write-Output $true }\r\n        else\r\n        { Write-Output $false }\r\n    }\r\n    function Set-ItemProp {\r\n        param (\r\n            $Path,\r\n            $Name,\r\n            $Value,\r\n            [ValidateSet(\"DWord\", \"QWord\", \"String\", \"ExpandedString\", \"Binary\", \"MultiString\", \"Unknown\")]\r\n            $PropertyType = \"DWord\"\r\n        )\r\n        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {\r\n            Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false | Out-Null\r\n        }\r\n        else {\r\n            New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false | Out-Null\r\n        }\r\n    }\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    $path = \"HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem\"\r\n    $filter = \"ConsentPromptBehaviorAdmin|ConsentPromptBehaviorUser|EnableInstallerDetection|EnableLUA|EnableVirtualization|PromptOnSecureDesktop|ValidateAdminCodeSignatures|FilterAdministratorToken\"\r\n    Write-Host \"Before:\"\r\n    (Get-ItemProperty $path).psobject.properties | Where-Object { $_.name -match $filter } | Select-Object name, value\r\n\r\n    try {\r\n        $filter -split '|' | ForEach-Object {\r\n            Set-ItemProp -Path $Path -Name $_ -Value (Get-Variable -Name $_).Value\r\n        }\r\n    }\r\n    catch {\r\n        Write-Error $_\r\n        exit 1\r\n    }\r\n\r\n    Write-Host \"After:\"\r\n    (Get-ItemProperty $path).psobject.properties | Where-Object { $_.name -match $filter } | Select-Object name, value\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Casos de uso em potencial<\/h2>\n<p>Considere um cen\u00e1rio em que uma empresa esteja implantando um novo software que exija configura\u00e7\u00f5es espec\u00edficas do UAC para otimizar o desempenho e a seguran\u00e7a. Em vez de configurar manualmente cada computador, a equipe de TI pode usar esse script para garantir que cada m\u00e1quina seja configurada corretamente. Al\u00e9m disso, para empresas que precisam aderir a normas de seguran\u00e7a r\u00edgidas, esse script pode ajudar a garantir a conformidade padronizando as configura\u00e7\u00f5es do UAC em todos os setores.<\/p>\n<h2>Implica\u00e7\u00f5es de seguran\u00e7a<\/h2>\n<p>As configura\u00e7\u00f5es do UAC desempenham um papel fundamental na seguran\u00e7a do sistema. Configura\u00e7\u00f5es incorretas podem, inadvertidamente, dar luz verde para que o malware seja instalado ou executado sem a permiss\u00e3o do usu\u00e1rio. Ao automatizar o processo de configura\u00e7\u00e3o, esse script reduz as chances de erro humano, mas ressalta a import\u00e2ncia de compreender as implica\u00e7\u00f5es de cada configura\u00e7\u00e3o.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li>Sempre fa\u00e7a backup do registro antes de fazer altera\u00e7\u00f5es para se proteger contra poss\u00edveis problemas.<\/li>\n<li>Teste o script em um \u00fanico computador ou em um ambiente controlado antes de implement\u00e1-lo em toda a rede.<\/li>\n<li>Mantenha-se atualizado sobre as pr\u00e1ticas recomendadas de configura\u00e7\u00f5es do UAC para garantir a seguran\u00e7a ideal.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>No cen\u00e1rio em constante evolu\u00e7\u00e3o da seguran\u00e7a de TI, ferramentas como esse script de configura\u00e7\u00e3o do UAC s\u00e3o inestim\u00e1veis. Ao compreender e aproveitar essas ferramentas, os profissionais de TI podem garantir um ambiente mais seguro e eficiente para seus usu\u00e1rios.<\/p>\n","protected":false},"author":35,"featured_media":142510,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[12456],"class_list":["post-809291","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/809291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=809291"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/142510"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=809291"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=809291"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=809291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}