{"id":208368,"date":"2024-01-03T10:02:59","date_gmt":"2024-01-03T10:02:59","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/surveiller-authentification-moderne-activee-office-365-powershell\/"},"modified":"2024-03-04T20:30:45","modified_gmt":"2024-03-04T20:30:45","slug":"surveiller-authentification-moderne-activee-office-365-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/surveiller-authentification-moderne-activee-office-365-powershell\/","title":{"rendered":"Comment s&rsquo;assurer que l&rsquo;authentification moderne est activ\u00e9e dans Office 365 avec PowerShell"},"content":{"rendered":"<p><a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-modern-authentication\/\">L&rsquo;authentification moderne<\/a> est une fonction de s\u00e9curit\u00e9 d&rsquo;Office 365 qui utilise Azure Active Directory (AAD) pour authentifier les utilisateurs. Il constitue un gage de s\u00e9curit\u00e9 qui surpasse les m\u00e9thodes d&rsquo;authentification traditionnelles telles que l&rsquo;authentification de base. La raison ? L&rsquo;authentification moderne utilise un chiffrement plus fort et une couche suppl\u00e9mentaire d&rsquo;authentification \u00e0 deux facteurs, ce qui en fait un m\u00e9canisme de d\u00e9fense redoutable.<\/p>\n<h2>Comprendre le script<\/h2>\n<p>Au fond, le script est con\u00e7u pour clarifier le <strong>statut de l&rsquo;authentification moderne \u00e0 travers les profils d&rsquo;utilisateurs dans un environnement Office 365<\/strong>. Comment y parvient-il ? En parcourant m\u00e9ticuleusement chaque profil d&rsquo;utilisateur sur la machine et en inspectant les valeurs du registre li\u00e9es \u00e0 l&rsquo;authentification moderne. S&rsquo;il rencontre une valeur \u00e9gale \u00e0 0, cela indique clairement que l&rsquo;authentification moderne est d\u00e9sactiv\u00e9e pour ce profil d&rsquo;utilisateur sp\u00e9cifique.<\/p>\n<h2>Le script<\/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>Acc\u00e9dez \u00e0 plus de 700 scripts dans le Dojo NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/fr\/phase-de-test-gratuit\/\">Obtenez l&rsquo;acc\u00e8s<\/a><\/p>\n<\/div>\n<h2>Les avantages pour les professionnels de l&rsquo;informatique<\/h2>\n<p>Le script n&rsquo;est pas un simple outil, c&rsquo;est une solution adapt\u00e9e aux professionnels de l&rsquo;informatique. Voici comment il peut vous aider :<\/p>\n<ol>\n<li><strong>Surveillance proactive<\/strong>: Avant qu&rsquo;une faille de s\u00e9curit\u00e9 potentielle ne devienne un vrai probl\u00e8me, le script permet aux professionnels de l&rsquo;informatique d&rsquo;identifier et de traiter les cas o\u00f9 l&rsquo;authentification moderne est d\u00e9sactiv\u00e9e.<\/li>\n<li><strong>Efficacit\u00e9 maximale<\/strong>: Le temps est un facteur essentiel dans le domaine de l&rsquo;informatique Le script automatise le processus fastidieux de v\u00e9rification individuelle de chaque profil d&rsquo;utilisateur, ce qui permet de gagner un temps pr\u00e9cieux.<\/li>\n<li><strong>Clart\u00e9 et orientation<\/strong>: Fini les devinettes. Le script offre un retour d&rsquo;information clair sur les profils d&rsquo;utilisateurs qui requi\u00e8rent une attention particuli\u00e8re, permettant ainsi une rem\u00e9diation cibl\u00e9e et efficace.<\/li>\n<\/ol>\n<h2>NinjaOne : Votre partenaire en mati\u00e8re de gestion informatique<\/h2>\n<p>Le script offre une solution cibl\u00e9e, et son int\u00e9gration \u00e0 une <a href=\"https:\/\/www.ninjaone.com\/fr\/\">plateforme de gestion informatique compl\u00e8te<\/a> telle que NinjaOne amplifie ses capacit\u00e9s. NinjaOne fournit une plateforme unifi\u00e9e qui simplifie les op\u00e9rations informatiques. En ce qui concerne l&rsquo;authentification moderne dans Office 365, NinjaOne peut ex\u00e9cuter le script de mani\u00e8re optimale \u00e0 des intervalles planifi\u00e9s. Le r\u00e9sultat ? Les <a href=\"https:\/\/www.ninjaone.com\/fr\/plateforme-de-gestion-de-terminaux\/surveillance-a-distance-du-parc-informatique\">\u00e9quipes informatiques sont alert\u00e9es en temps r\u00e9el<\/a> de toute anomalie, ce qui garantit une s\u00e9curit\u00e9 sans faille.<\/p>\n<h2>Conclusion<\/h2>\n<p>Dans le monde en constante \u00e9volution de l&rsquo;informatique, l&rsquo;authentification moderne dans Office 365 n&rsquo;est pas seulement une fonctionnalit\u00e9, c&rsquo;est une n\u00e9cessit\u00e9. En exploitant ce script et en l&rsquo;int\u00e9grant \u00e0 des solutions performantes telles que NinjaOne, les professionnels de l&rsquo;informatique peuvent renforcer leurs d\u00e9fenses et s&rsquo;assurer que leur entreprise a toujours une longueur d&rsquo;avance dans le domaine de la cybers\u00e9curit\u00e9.<\/p>\n","protected":false},"author":35,"featured_media":207006,"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":[4287],"class_list":["post-208368","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/208368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/comments?post=208368"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media\/207006"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=208368"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=208368"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=208368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}