{"id":808349,"date":"2026-05-14T07:31:00","date_gmt":"2026-05-14T07:31:00","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=808349"},"modified":"2026-05-14T07:31:00","modified_gmt":"2026-05-14T07:31:00","slug":"monitor-modern-authentication-enabled-office-365-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/monitor-modern-authentication-enabled-office-365-powershell\/","title":{"rendered":"Como garantir que a autentica\u00e7\u00e3o moderna esteja ativada no Office 365 com o PowerShell"},"content":{"rendered":"<p><a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-modern-authentication\/\">A autentica\u00e7\u00e3o moderna<\/a> \u00e9 um recurso de seguran\u00e7a do Office 365 que usa o Azure Active Directory (AAD) para autenticar usu\u00e1rios. Ele se destaca como um farol de seguran\u00e7a, ofuscando os m\u00e9todos de autentica\u00e7\u00e3o tradicionais, como a autentica\u00e7\u00e3o b\u00e1sica. O motivo? A autentica\u00e7\u00e3o moderna emprega criptografia mais forte e a camada adicional de autentica\u00e7\u00e3o de dois fatores, o que a torna um mecanismo de defesa formid\u00e1vel no cen\u00e1rio cibern\u00e9tico atual.<\/p>\n<h2>Entendendo o roteiro<\/h2>\n<p>Basicamente, o script foi projetado para esclarecer o <strong>status da autentica\u00e7\u00e3o moderna nos perfis de usu\u00e1rio em um ambiente do Office 365<\/strong>. Como ele consegue isso? Percorrendo meticulosamente cada perfil de usu\u00e1rio na m\u00e1quina e inspecionando os valores do registro vinculados \u00e0 autentica\u00e7\u00e3o moderna. Se ele encontrar um valor definido como 0, \u00e9 um indicador claro de que a autentica\u00e7\u00e3o moderna est\u00e1 desativada para esse perfil de usu\u00e1rio espec\u00edfico.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Monitors if user profiles have modern auth for Office 365 enabled or disabled.\r\n.DESCRIPTION\r\n    Monitors if user profiles have modern auth for Office 365 enabled or disabled.\r\n    Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice15.0CommonIdentityEnableADAL is set to 1.\r\n    Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice16.0CommonIdentityEnableADAL is set to 0.\r\n    Returns an exit code of 1 if one user has modern auth disabled.\r\n    Returns an exit code of 0 if all user have modern auth enabled.\r\n.EXAMPLE\r\n     No parameter needed.\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\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#&gt;\r\n\r\n[CmdletBinding()]\r\nparam ()\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        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\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    # Loop through each user's profile\r\n    # Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice15.0CommonIdentityEnableADAL is set to 1\r\n    # Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice16.0CommonIdentityEnableADAL is set to 1\r\n\r\n    $Path = @(\"SOFTWAREMicrosoftOffice15.0CommonIdentity\", \"SOFTWAREMicrosoftOffice16.0CommonIdentity\")\r\n    $Name = \"EnableADAL\"\r\n\r\n    $Script:FoundModernAuthDisabled = $false\r\n\r\n    # Get each user profile SID and Path to the profile\r\n    $UserProfiles = Get-ItemProperty -Path \"HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*\" |\r\n        Where-Object { $_.PSChildName -match \"S-1-5-21-(d+-?){4}$\" } |\r\n        Select-Object @{Name = \"SID\"; Expression = { $_.PSChildName } }, @{Name = \"UserHive\"; Expression = { \"$($_.ProfileImagePath)NTuser.dat\" } }, @{Name = \"UserName\"; Expression = { \"$($_.ProfileImagePath | Split-Path -Leaf)\" } }\r\n\r\n    # Loop through each profile on the machine\r\n    Foreach ($UserProfile in $UserProfiles) {\r\n        # Load User ntuser.dat if it's not already loaded\r\n        If (($ProfileWasLoaded = Test-Path -Path \"Registry::HKEY_USERS$($UserProfile.SID)\") -eq $false) {\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe LOAD HKU$($UserProfile.SID) $($UserProfile.UserHive)\" -Wait -WindowStyle Hidden\r\n        }\r\n\r\n        # Read the user's registry\r\n        $Path | ForEach-Object {\r\n            $Key = Join-Path -Path \"Registry::HKEY_USERS$($UserProfile.SID)\" -ChildPath $($_)\r\n            $Value = Get-ItemProperty -Path $Key -ErrorAction SilentlyContinue | Select-Object $Name -ExpandProperty $Name -ErrorAction SilentlyContinue\r\n            if (\r\n                (\r\n                    $_ -like \"*15.0*\" -and\r\n                    $Value -ne 1 -and\r\n                    $(Test-Path -Path $Key -ErrorAction SilentlyContinue)\r\n                ) -or\r\n                (\r\n                    $_ -like \"*16.0*\" -and\r\n                    $Value -eq 0\r\n                )\r\n            ) {\r\n                Write-Host \"$($UserProfile.UserName) ModernAuth is not enabled.\"\r\n                $Script:FoundModernAuthDisabled = $true\r\n            }\r\n        }\r\n \r\n        # Unload NTuser.dat\r\n        If ($ProfileWasLoaded -eq $false) {\r\n            [gc]::Collect()\r\n            Start-Sleep 1\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe UNLOAD HKU$($UserProfile.SID)\" -Wait -WindowStyle Hidden | Out-Null\r\n        }\r\n    }\r\n    if ($FoundModernAuthDisabled) {\r\n        Write-Output $false\r\n        exit 1\r\n    }\r\n    else {\r\n        Write-Output $true\r\n        exit 0\r\n    }\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>Como os profissionais de TI podem se beneficiar<\/h2>\n<p>O script n\u00e3o \u00e9 apenas uma ferramenta; \u00e9 uma solu\u00e7\u00e3o personalizada para profissionais de TI. Veja como isso pode mudar o jogo:<\/p>\n<ol>\n<li><strong>Monitoramento proativo<\/strong>: Antes que um poss\u00edvel lapso de seguran\u00e7a se torne um problema completo, o script permite que os profissionais de TI identifiquem e resolvam as inst\u00e2ncias em que a autentica\u00e7\u00e3o moderna est\u00e1 desativada.<\/li>\n<li><strong>Efici\u00eancia em sua melhor forma<\/strong>: O tempo \u00e9 essencial em TI. O script automatiza o processo tedioso de verificar individualmente cada perfil de usu\u00e1rio, liberando tempo valioso.<\/li>\n<li><strong>Clareza e dire\u00e7\u00e3o<\/strong>: N\u00e3o h\u00e1 mais suposi\u00e7\u00f5es. O script oferece feedback claro sobre quais perfis de usu\u00e1rio precisam de aten\u00e7\u00e3o, abrindo caminho para uma corre\u00e7\u00e3o direcionada e eficaz.<\/li>\n<\/ol>\n<h2>NinjaOne: Seu parceiro no gerenciamento de TI<\/h2>\n<p>Embora o script ofere\u00e7a uma solu\u00e7\u00e3o focada, a integra\u00e7\u00e3o com uma <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">plataforma abrangente de gerenciamento de TI<\/a>, como o NinjaOne, amplia seus recursos. O NinjaOne oferece uma plataforma unificada que simplifica as opera\u00e7\u00f5es de TI. Quando se trata de autentica\u00e7\u00e3o moderna no Office 365, o NinjaOne pode executar o script sem problemas em intervalos programados. O resultado? <a href=\"https:\/\/www.ninjaone.com\/pt-br\/endpoint-management\/monitoramento-remoto-e-alertas\/\">Alertas em tempo real para as equipes de TI<\/a> sobre quaisquer discrep\u00e2ncias, garantindo que a seguran\u00e7a n\u00e3o seja comprometida.<\/p>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>No mundo em constante evolu\u00e7\u00e3o da TI, a autentica\u00e7\u00e3o moderna no Office 365 n\u00e3o \u00e9 apenas um recurso; \u00e9 uma necessidade. Ao aproveitar o script discutido e integr\u00e1-lo a solu\u00e7\u00f5es robustas como o NinjaOne, os profissionais de TI podem fortalecer suas defesas, garantindo que suas organiza\u00e7\u00f5es estejam sempre um passo \u00e0 frente no jogo da seguran\u00e7a cibern\u00e9tica.<\/p>\n","protected":false},"author":35,"featured_media":142182,"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-808349","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\/808349","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=808349"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/142182"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=808349"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=808349"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=808349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}