{"id":394202,"date":"2024-12-17T10:13:15","date_gmt":"2024-12-17T10:13:15","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=394202"},"modified":"2024-12-17T10:13:15","modified_gmt":"2024-12-17T10:13:15","slug":"controle-integrite-active-directory","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/controle-integrite-active-directory\/","title":{"rendered":"Script PowerShell pour le contr\u00f4le de l&rsquo;int\u00e9grit\u00e9 d&rsquo;Active Directory\u00a0: le guide complet\u00a0"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Le maintien de l&rsquo;int\u00e9grit\u00e9 de votre environnement\u00a0<a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-active-directory\/\">Active Directory (AD)<\/a>\u00a0est crucial pour la stabilit\u00e9 et la s\u00e9curit\u00e9 des syst\u00e8mes informatiques. Un AD malsain peut entra\u00eener des \u00e9checs d&rsquo;authentification, des probl\u00e8mes de r\u00e9plication et des perturbations plus importantes sur le r\u00e9seau d&rsquo;une entreprise. Ce script\u00a0<a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-powershell\/\">PowerShell<\/a>\u00a0est con\u00e7u pour rationaliser le processus d&rsquo;\u00e9valuation et de d\u00e9pannage des\u00a0<strong>contr\u00f4les d&rsquo;int\u00e9grit\u00e9 d&rsquo;Active Directory<\/strong>, offrant une m\u00e9thode structur\u00e9e et automatis\u00e9e pour les professionnels de l&rsquo;informatique et les\u00a0<a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\">fournisseurs de services g\u00e9r\u00e9s (MSP).<\/a><\/p>\n<h2>Contexte<\/h2>\n<p>Active Directory est la cl\u00e9 de vo\u00fbte de nombreux environnements informatiques d&rsquo;entreprise, g\u00e9rant l&rsquo;authentification des utilisateurs, les strat\u00e9gies de groupe et les services d&rsquo;annuaire. Toutefois, garantir son bon fonctionnement peut s&rsquo;av\u00e9rer complexe, compte tenu du nombre de points de d\u00e9faillance potentiels. Ce script utilise l&rsquo;utilitaire de ligne de commande DCDiag pour analyser l&rsquo;\u00e9tat d&rsquo;un contr\u00f4leur de domaine, identifier les probl\u00e8mes potentiels et rapporter les r\u00e9sultats. Pour les MSP et les administrateurs informatiques, cet outil est inestimable, car il fournit un aper\u00e7u clair de l&rsquo;int\u00e9grit\u00e9 d&rsquo;AD et facilite une maintenance proactive.<\/p>\n<h2>Le script\u00a0:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Analyzes the state of a domain controller and reports any problems to help with troubleshooting. Optionally, set a WYSIWYG custom field.\r\n    By 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.DESCRIPTION\r\n    Analyzes the state of a domain controller and reports any problems to help with troubleshooting. Optionally, set a WYSIWYG custom field.\r\n.EXAMPLE\r\n    (No Parameters)\r\n    \r\nRetrieving Directory Server Diagnosis Test Results.\r\n\r\nPassing Tests: CheckSDRefDom, Connectivity, CrossRefValidation, DFSREvent, FrsEvent, Intersite, KccEvent, KnowsOfRoleHolders, MachineAccount, NCSecDesc, NetLogons, ObjectsReplicated, Replications, RidManager, Services, SystemLog, SysVolCheck, VerifyReferences\r\n\r\n[Alert] Failed Tests Detected!\r\nFailed Tests: Advertising, LocatorCheck\r\n\r\n### Detailed Output ###\r\n\r\nDirectory Server Diagnosis\r\nPerforming initial setup:\r\n   Trying to find home server...\r\n   Home Server = SRV16-DC2-TEST\r\n   * Identified AD Forest. \r\n   Done gathering initial info.\r\nDoing initial required tests\r\n   Testing server: Default-First-Site-Name\\SRV16-DC2-TEST\r\n      Starting test: Connectivity\r\n         ......................... SRV16-DC2-TEST passed test Connectivity\r\nDoing primary tests\r\n   Testing server: Default-First-Site-Name\\SRV16-DC2-TEST\r\n      Starting test: Advertising\r\n         Warning: SRV16-DC2-TEST is not advertising as a time server.\r\n         ......................... SRV16-DC2-TEST failed test Advertising\r\n   Running partition tests on : ForestDnsZones\r\n   Running partition tests on : DomainDnsZones\r\n   Running partition tests on : Schema\r\n   Running partition tests on : Configuration\r\n   Running partition tests on : test\r\n   Running enterprise tests on : test.lan\r\n\r\nDirectory Server Diagnosis\r\nPerforming initial setup:\r\n   Trying to find home server...\r\n   Home Server = SRV16-DC2-TEST\r\n   * Identified AD Forest. \r\n   Done gathering initial info.\r\nDoing initial required tests\r\n   Testing server: Default-First-Site-Name\\SRV16-DC2-TEST\r\n      Starting test: Connectivity\r\n         ......................... SRV16-DC2-TEST passed test Connectivity\r\nDoing primary tests\r\n   Testing server: Default-First-Site-Name\\SRV16-DC2-TEST\r\n   Running partition tests on : ForestDnsZones\r\n   Running partition tests on : DomainDnsZones\r\n   Running partition tests on : Schema\r\n   Running partition tests on : Configuration\r\n   Running partition tests on : test\r\n   Running enterprise tests on : test.lan\r\n      Starting test: LocatorCheck\r\n         Warning: DcGetDcName(TIME_SERVER) call failed, error 1355\r\n         A Time Server could not be located.\r\n         The server holding the PDC role is down.\r\n         Warning: DcGetDcName(GOOD_TIME_SERVER_PREFERRED) call failed, error\r\n         1355\r\n         A Good Time Server could not be located.\r\n         ......................... test.lan failed test LocatorCheck\r\n\r\nPARAMETER: -wysiwygCustomField \"ReplaceMeWithaWYSIWYGcustomField\"\r\n    Name of a WYSIWYG custom field to optionally save the results to.\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: Initial Release\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [String]$wysiwygCustomField\r\n)\r\n\r\nbegin {\r\n    # If script form variables are used, replace command line parameters with their value. \r\n    if ($env:wysiwygCustomFieldName -and $env:wysiwygCustomFieldName -notlike \"null\") { $wysiwygCustomField = $env:wysiwygCustomFieldName }\r\n\r\n    # Function to test if the current machine is a domain controller\r\n    function Test-IsDomainController {\r\n        $OS = if ($PSVersionTable.PSVersion.Major -lt 5) {\r\n            Get-WmiObject -Class Win32_OperatingSystem\r\n        }\r\n        else {\r\n            Get-CimInstance -ClassName Win32_OperatingSystem\r\n        }\r\n\r\n        # Check if the OS is a domain controller (ProductType 2)\r\n        if ($OS.ProductType -eq \"2\") {\r\n            return $true\r\n        }\r\n    }\r\n\r\n    function Get-DCDiagResults {\r\n        # Define the list of DCDiag tests to run\r\n        $DCDiagTestsToRun = \"Connectivity\", \"Advertising\", \"FrsEvent\", \"DFSREvent\", \"SysVolCheck\", \"KccEvent\", \"KnowsOfRoleHolders\", \"MachineAccount\", \"NCSecDesc\", \"NetLogons\", \"ObjectsReplicated\", \"Replications\", \"RidManager\", \"Services\", \"SystemLog\", \"VerifyReferences\", \"CheckSDRefDom\", \"CrossRefValidation\", \"LocatorCheck\", \"Intersite\"\r\n    \r\n        foreach ($DCTest in $DCDiagTestsToRun) {\r\n            # Run DCDiag for the current test and save the output to a file\r\n            $DCDiag = Start-Process -FilePath \"DCDiag.exe\" -ArgumentList \"\/test:$DCTest\", \"\/f:$env:TEMP\\dc-diag-$DCTest.txt\" -PassThru -Wait -NoNewWindow\r\n\r\n            # Check if the DCDiag test failed\r\n            if ($DCDiag.ExitCode -ne 0) {\r\n                Write-Host \"[Error] Running $DCTest!\"\r\n                exit 1\r\n            }\r\n\r\n            # Read the raw results from the output file and filter out empty lines\r\n            $RawResult = Get-Content -Path \"$env:TEMP\\dc-diag-$DCTest.txt\" | Where-Object { $_.Trim() }\r\n            \r\n            # Find the status line indicating whether the test passed or failed\r\n            $StatusLine = $RawResult | Where-Object { $_ -match \"\\. .* test $DCTest\" }\r\n\r\n            # Extract the status (passed or failed) from the status line\r\n            $Status = $StatusLine -split ' ' | Where-Object { $_ -like \"passed\" -or $_ -like \"failed\" }\r\n\r\n            # Create a custom object to store the test results\r\n            [PSCustomObject]@{\r\n                Test   = $DCTest\r\n                Status = $Status\r\n                Result = $RawResult\r\n            }\r\n\r\n            # Remove the temporary output file\r\n            Remove-Item -Path \"$env:TEMP\\dc-diag-$DCTest.txt\"\r\n        }\r\n    }\r\n\r\n    function Set-NinjaProperty {\r\n        [CmdletBinding()]\r\n        Param(\r\n            [Parameter(Mandatory = $True)]\r\n            [String]$Name,\r\n            [Parameter()]\r\n            [String]$Type,\r\n            [Parameter(Mandatory = $True, ValueFromPipeline = $True)]\r\n            $Value,\r\n            [Parameter()]\r\n            [String]$DocumentName\r\n        )\r\n    \r\n        $Characters = $Value | Out-String | Measure-Object -Character | Select-Object -ExpandProperty Characters\r\n        if ($Characters -ge 200000) {\r\n            throw [System.ArgumentOutOfRangeException]::New(\"Character limit exceeded: the value is greater than or equal to 200,000 characters.\")\r\n        }\r\n        \r\n        # If requested to set the field value for a Ninja document, specify it here.\r\n        $DocumentationParams = @{}\r\n        if ($DocumentName) { $DocumentationParams[\"DocumentName\"] = $DocumentName }\r\n        \r\n        # This is a list of valid fields that can be set. If no type is specified, assume that the input does not need to be changed.\r\n        $ValidFields = \"Attachment\", \"Checkbox\", \"Date\", \"Date or Date Time\", \"Decimal\", \"Dropdown\", \"Email\", \"Integer\", \"IP Address\", \"MultiLine\", \"MultiSelect\", \"Phone\", \"Secure\", \"Text\", \"Time\", \"URL\", \"WYSIWYG\"\r\n        if ($Type -and $ValidFields -notcontains $Type) { Write-Warning \"$Type is an invalid type. Please check here for valid types: https:\/\/ninjarmm.zendesk.com\/hc\/en-us\/articles\/16973443979789-Command-Line-Interface-CLI-Supported-Fields-and-Functionality\" }\r\n        \r\n        # The field below requires additional information to set.\r\n        $NeedsOptions = \"Dropdown\"\r\n        if ($DocumentName) {\r\n            if ($NeedsOptions -contains $Type) {\r\n                # Redirect error output to the success stream to handle errors more easily if nothing is found or something else goes wrong.\r\n                $NinjaPropertyOptions = Ninja-Property-Docs-Options -AttributeName $Name @DocumentationParams 2&gt;&amp;1\r\n            }\r\n        }\r\n        else {\r\n            if ($NeedsOptions -contains $Type) {\r\n                $NinjaPropertyOptions = Ninja-Property-Options -Name $Name 2&gt;&amp;1\r\n            }\r\n        }\r\n        \r\n        # If an error is received with an exception property, exit the function with that error information.\r\n        if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions }\r\n        \r\n        # The types below require values not typically given to be set. The code below will convert whatever we're given into a format ninjarmm-cli supports.\r\n        switch ($Type) {\r\n            \"Checkbox\" {\r\n                # Although it's highly likely we were given a value like \"True\" or a boolean data type, it's better to be safe than sorry.\r\n                $NinjaValue = [System.Convert]::ToBoolean($Value)\r\n            }\r\n            \"Date or Date Time\" {\r\n                # Ninjarmm-cli expects the GUID of the option to be selected. Therefore, match the given value with a GUID.\r\n                $Date = (Get-Date $Value).ToUniversalTime()\r\n                $TimeSpan = New-TimeSpan (Get-Date \"1970-01-01 00:00:00\") $Date\r\n                $NinjaValue = $TimeSpan.TotalSeconds\r\n            }\r\n            \"Dropdown\" {\r\n                # Ninjarmm-cli expects the GUID of the option we're trying to select, so match the value we were given with a GUID.\r\n                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header \"GUID\", \"Name\"\r\n                $Selection = $Options | Where-Object { $_.Name -eq $Value } | Select-Object -ExpandProperty GUID\r\n        \r\n                if (-not $Selection) {\r\n                    throw [System.ArgumentOutOfRangeException]::New(\"Value is not present in dropdown options.\")\r\n                }\r\n        \r\n                $NinjaValue = $Selection\r\n            }\r\n            default {\r\n                # All the other types shouldn't require additional work on the input.\r\n                $NinjaValue = $Value\r\n            }\r\n        }\r\n        \r\n        # Set the field differently depending on whether it's a field in a Ninja Document or not.\r\n        if ($DocumentName) {\r\n            $CustomField = Ninja-Property-Docs-Set -AttributeName $Name -AttributeValue $NinjaValue @DocumentationParams 2&gt;&amp;1\r\n        }\r\n        else {\r\n            $CustomField = $NinjaValue | Ninja-Property-Set-Piped -Name $Name 2&gt;&amp;1\r\n        }\r\n        \r\n        if ($CustomField.Exception) {\r\n            throw $CustomField\r\n        }\r\n    }\r\n   \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\n    if (!$ExitCode) {\r\n        $ExitCode = 0\r\n    }\r\n}\r\nprocess {\r\n    # Check if the script is run with Administrator privileges\r\n    if (!(Test-IsElevated)) {\r\n        Write-Host -Object \"[Error] Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    # Check if the script is run on a Domain Controller\r\n    if (!(Test-IsDomainController)) {\r\n        Write-Host -Object \"[Error] This script needs to be run on a Domain Controller.\"\r\n        exit 1\r\n    }\r\n\r\n    # Initialize lists to store passing and failing tests\r\n    $PassingTests = New-Object System.Collections.Generic.List[object]\r\n    $FailedTests = New-Object System.Collections.Generic.List[object]\r\n\r\n    # Notify the user that the tests are being retrieved\r\n    Write-Host -Object \"`nRetrieving Directory Server Diagnosis Test Results.\"\r\n    $TestResults = Get-DCDiagResults\r\n\r\n    # Process each test result\r\n    foreach ($Result in $TestResults) {\r\n        $TestFailed = $False\r\n\r\n        # Check if any status in the result indicates a failure\r\n        $Result.Status | ForEach-Object {\r\n            if ($_ -notmatch \"pass\") {\r\n                $TestFailed = $True\r\n            }\r\n        }\r\n\r\n        # Add the result to the appropriate list\r\n        if ($TestFailed) {\r\n            $FailedTests.Add($Result)\r\n        }\r\n        else {\r\n            $PassingTests.Add($Result)\r\n        }\r\n    }\r\n\r\n    # Optionally set a WYSIWYG custom field if specified\r\n    if ($wysiwygCustomField) {\r\n        try {\r\n            Write-Host -Object \"`nBuilding HTML for Custom Field.\"\r\n\r\n            # Create an HTML report for the custom field\r\n            $HTML = New-Object System.Collections.Generic.List[object]\r\n\r\n            $HTML.Add(\"&lt;h1 style='text-align: center'&gt;Directory Server Diagnosis Test Results (DCDiag.exe)&lt;\/h1&gt;\")\r\n            $FailedPercentage = $([math]::Round((($FailedTests.Count \/ ($FailedTests.Count + $PassingTests.Count)) * 100), 2))\r\n            $SuccessPercentage = 100 - $FailedPercentage\r\n            $HTML.Add(\r\n                @\"\r\n&lt;div class='p-3 linechart'&gt;\r\n    &lt;div style='width: $FailedPercentage%; background-color: #C6313A;'&gt;&lt;\/div&gt;\r\n    &lt;div style='width: $SuccessPercentage%; background-color: #007644;'&gt;&lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n        &lt;ul class='unstyled p-3' style='display: flex; justify-content: space-between; '&gt;\r\n            &lt;li&gt;&lt;span class='chart-key' style='background-color: #C6313A;'&gt;&lt;\/span&gt;&lt;span&gt;Failed ($($FailedTests.Count))&lt;\/span&gt;&lt;\/li&gt;\r\n            &lt;li&gt;&lt;span class='chart-key' style='background-color: #007644;'&gt;&lt;\/span&gt;&lt;span&gt;Passed ($($PassingTests.Count))&lt;\/span&gt;&lt;\/li&gt;\r\n        &lt;\/ul&gt;\r\n\"@\r\n            )\r\n\r\n            # Add failed tests to the HTML report\r\n            $FailedTests | Sort-Object Test | ForEach-Object {\r\n                $HTML.Add(\r\n                    @\"\r\n&lt;div class='info-card error'&gt;\r\n    &lt;i class='info-icon fa-solid fa-circle-exclamation'&gt;&lt;\/i&gt;\r\n    &lt;div class='info-text'&gt;\r\n        &lt;div class='info-title'&gt;$($_.Test)&lt;\/div&gt;\r\n        &lt;div class='info-description'&gt;\r\n            $($_.Result | Out-String)\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n\"@\r\n                )\r\n            }\r\n\r\n            # Add passing tests to the HTML report\r\n            $PassingTests | Sort-Object Test | ForEach-Object {\r\n                $HTML.Add(\r\n                    @\"\r\n&lt;div class='info-card success'&gt;\r\n    &lt;i class='info-icon fa-solid fa-circle-check'&gt;&lt;\/i&gt;\r\n    &lt;div class='info-text'&gt;\r\n        &lt;div class='info-title'&gt;$($_.Test)&lt;\/div&gt;\r\n        &lt;div class='info-description'&gt;\r\n            Test passed.\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n\"@\r\n                )\r\n            }\r\n\r\n            # Set the custom field with the HTML report\r\n            Write-Host -Object \"Attempting to set Custom Field '$wysiwygCustomField'.\"\r\n            Set-NinjaProperty -Name $wysiwygCustomField -Value $HTML\r\n            Write-Host -Object \"Successfully set Custom Field '$wysiwygCustomField'!\"\r\n        }\r\n        catch {\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    # Display the list of passing tests\r\n    if ($PassingTests.Count -gt 0) {\r\n        Write-Host -Object \"\"\r\n        Write-Host -Object \"Passing Tests: \" -NoNewline\r\n        Write-Host -Object ($PassingTests.Test | Sort-Object) -Separator \", \"\r\n        Write-Host -Object \"\"\r\n    }\r\n\r\n    # Display the list of failed tests with detailed output\r\n    if ($FailedTests.Count -gt 0) {\r\n        Write-Host -Object \"[Alert] Failed Tests Detected!\"\r\n        Write-Host -Object \"Failed Tests: \" -NoNewline\r\n        Write-Host -Object ($FailedTests.Test | Sort-Object) -Separator \", \"\r\n\r\n        Write-Host -Object \"`n### Detailed Output ###\"\r\n        $FailedTests | Sort-Object Test | ForEach-Object {\r\n            Write-Host -Object \"\"\r\n            Write-Host -Object ($_.Result | Out-String)\r\n            Write-Host -Object \"\"\r\n        }\r\n    }\r\n    else {\r\n        Write-Host -Object \"All Directory Server Diagnosis Tests Pass!\"\r\n    }\r\n\r\n    exit $ExitCode\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Gagnez du temps gr\u00e2ce \u00e0 plus de 300 scripts du Dojo NinjaOne.<\/p>\n<p>\u2192 <a class=\"waffle-rich-text-link\" href=\"https:\/\/www.ninjaone.com\/fr\/phase-de-test-gratuit\/\">Obtenir l&rsquo;acc\u00e8s<\/a><\/p>\n<\/div>\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<h3>Caract\u00e9ristiques du script<\/h3>\n<ol>\n<li><strong>V\u00e9rification des privil\u00e8ges administrateur<\/strong><br \/>\nLe script commence par v\u00e9rifier qu&rsquo;il s&rsquo;ex\u00e9cute avec des privil\u00e8ges \u00e9lev\u00e9s, en s&rsquo;assurant qu&rsquo;il dispose des autorisations n\u00e9cessaires pour ex\u00e9cuter les commandes de diagnostic.<\/li>\n<li><strong>Validation du contr\u00f4leur de domaine<\/strong><br \/>\nIl v\u00e9rifie si le script est ex\u00e9cut\u00e9 sur un contr\u00f4leur de domaine. Si ce n&rsquo;est pas le cas, il se termine de mani\u00e8re \u00e9l\u00e9gante avec un message d&rsquo;erreur appropri\u00e9.<\/li>\n<li><strong>Ex\u00e9cution des tests DCDiag<\/strong><br \/>\nUne s\u00e9rie de tests DCDiag critiques sont effectu\u00e9s, y compris des contr\u00f4les de connectivit\u00e9, de publicit\u00e9, de r\u00e9plication, de journaux syst\u00e8me, etc. Les r\u00e9sultats sont analys\u00e9s pour s\u00e9parer les tests r\u00e9ussis de ceux qui \u00e9chouent.<\/li>\n<li><strong>Cat\u00e9gorisation des r\u00e9sultats<\/strong><br \/>\nLes r\u00e9sultats sont divis\u00e9s en cat\u00e9gories de r\u00e9ussite et d&rsquo;\u00e9chec, avec des r\u00e9sultats d\u00e9taill\u00e9s pour tous les tests \u00e9chou\u00e9s. Cela permet aux administrateurs de se concentrer sur les probl\u00e8mes qui n\u00e9cessitent une attention imm\u00e9diate.<\/li>\n<li><strong>Rapports facultatifs sur les champs personnalis\u00e9s<\/strong><br \/>\nLe script prend en charge un param\u00e8tre facultatif permettant d&rsquo;afficher les r\u00e9sultats dans un champ personnalis\u00e9 WYSIWYG (What You See Is What You Get), utile pour l&rsquo;int\u00e9gration avec des outils tels que NinjaOne.<\/li>\n<li><strong>G\u00e9n\u00e9ration de rapports HTML<\/strong><br \/>\nPour une meilleure lisibilit\u00e9, le script g\u00e9n\u00e8re un rapport HTML qui r\u00e9sume les r\u00e9sultats des tests dans un format visuellement intuitif, y compris les pourcentages de r\u00e9ussite et d&rsquo;\u00e9chec.<\/li>\n<\/ol>\n<h3>R\u00e9sum\u00e9 du flux de travail<\/h3>\n<ol>\n<li>Valider les conditions pr\u00e9alables\u00a0: Privil\u00e8ges administrateur et environnement du contr\u00f4leur de domaine.<\/li>\n<li>Ex\u00e9cuter les tests DCDiag et saisir les r\u00e9sultats.<\/li>\n<li>Classer et afficher les r\u00e9sultats.<\/li>\n<li>G\u00e9n\u00e9rer un rapport HTML optionnel pour l&rsquo;int\u00e9gration de champs personnalis\u00e9s.<\/li>\n<\/ol>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<h3>Sc\u00e9nario concret<\/h3>\n<p>Prenons l&rsquo;exemple d&rsquo;un administrateur informatique charg\u00e9 de g\u00e9rer un environnement AD multi-site. L&rsquo;un des contr\u00f4leurs de domaine commence \u00e0 rencontrer des \u00e9checs d&rsquo;authentification intermittents. L&rsquo;administrateur ex\u00e9cute ce script sur le serveur concern\u00e9 pour diagnostiquer le probl\u00e8me. Le r\u00e9sultat met en \u00e9vidence les \u00e9checs des tests\u00a0<strong>Advertising<\/strong>\u00a0et\u00a0<strong>LocatorCheck<\/strong>\u00a0, ce qui indique des probl\u00e8mes de synchronisation temporelle et de disponibilit\u00e9 des r\u00f4les PDC. Les r\u00e9sultats d\u00e9taill\u00e9s permettent \u00e0 l&rsquo;administrateur d&rsquo;identifier et de r\u00e9soudre rapidement l&rsquo;origine du probl\u00e8me et de r\u00e9tablir le fonctionnement normal de l&rsquo;entreprise.<\/p>\n<h2>Comparaisons<\/h2>\n<h3>Contr\u00f4les manuels de l&rsquo;int\u00e9grit\u00e9 d&rsquo;AD<\/h3>\n<p>L&rsquo;ex\u00e9cution manuelle des tests DCDiag n\u00e9cessite un investissement en temps important, notamment pour l&rsquo;analyse et l&rsquo;interpr\u00e9tation des r\u00e9sultats. Ce script automatise l&rsquo;ensemble du processus, en fournissant des r\u00e9sultats structur\u00e9s et des options d&rsquo;int\u00e9gration.<\/p>\n<h3>Outils bas\u00e9s sur une interface graphique<\/h3>\n<p>Si les outils GUI comme AD Manager ou RSAT offrent une interface conviviale pour les contr\u00f4les d&rsquo;int\u00e9grit\u00e9 d&rsquo;AD, ils manquent souvent de la flexibilit\u00e9 et des capacit\u00e9s d&rsquo;automatisation des scripts PowerShell. Ce script est particuli\u00e8rement avantageux pour les MSP qui g\u00e8rent plusieurs environnements clients.<\/p>\n<h2>FAQ<\/h2>\n<ol>\n<li><strong>Ce script peut-il \u00eatre ex\u00e9cut\u00e9 sur n&rsquo;importe quel serveur\u00a0?<\/strong><br \/>\nNon, il doit \u00eatre ex\u00e9cut\u00e9 sur un contr\u00f4leur de domaine. Les environnements non-DC d\u00e9clencheront une erreur.<\/li>\n<li><strong>Quelles sont les autorisations requises\u00a0?<\/strong><br \/>\nLes privil\u00e8ges d&rsquo;administrateur sont obligatoires pour ex\u00e9cuter le script avec succ\u00e8s.<\/li>\n<li><strong>Les r\u00e9sultats peuvent-ils \u00eatre export\u00e9s vers un fichier\u00a0?<\/strong><br \/>\nOui, le script comprend une option permettant de g\u00e9n\u00e9rer un rapport HTML pour l&rsquo;int\u00e9gration des champs personnalis\u00e9s.<\/li>\n<li><strong>Comment les tests \u00e9chou\u00e9s sont-ils mis en \u00e9vidence\u00a0?<\/strong><br \/>\nLes tests qui ont \u00e9chou\u00e9 sont r\u00e9pertori\u00e9s s\u00e9par\u00e9ment avec des messages de diagnostic d\u00e9taill\u00e9s, ce qui permet de hi\u00e9rarchiser les efforts de d\u00e9pannage.<\/li>\n<\/ol>\n<h2>Implications<\/h2>\n<p>Les r\u00e9sultats de ce script peuvent r\u00e9v\u00e9ler des vuln\u00e9rabilit\u00e9s critiques dans votre environnement AD, telles que des \u00e9checs de r\u00e9plication ou des r\u00f4les mal configur\u00e9s. Si elles ne sont pas r\u00e9solues, ces questions peuvent entra\u00eener des probl\u00e8mes d&rsquo;authentification g\u00e9n\u00e9ralis\u00e9s, des applications erron\u00e9es des politiques et des risques pour la s\u00e9curit\u00e9.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Ex\u00e9cutez-le r\u00e9guli\u00e8rement<\/strong>\u00a0: planifiez l&rsquo;ex\u00e9cution p\u00e9riodique du script afin d&rsquo;assurer une surveillance continue de l&rsquo;int\u00e9grit\u00e9 d&rsquo;AD.<\/li>\n<li><strong>Analysez les tendances<\/strong>\u00a0: Comparez les r\u00e9sultats dans le temps pour identifier les probl\u00e8mes r\u00e9currents.<\/li>\n<li><strong>Int\u00e9gration avec les outils de surveillance<\/strong>\u00a0: Utilisez l&rsquo;option de champ personnalis\u00e9 pour int\u00e9grer les r\u00e9sultats dans des outils tels que NinjaOne pour un suivi centralis\u00e9.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Ce script PowerShell offre une solution rationalis\u00e9e et automatis\u00e9e pour effectuer des contr\u00f4les de sant\u00e9 AD, r\u00e9duisant ainsi le temps et les efforts requis pour les diagnostics manuels. En identifiant les probl\u00e8mes \u00e0 un stade pr\u00e9coce, les professionnels de l&rsquo;informatique peuvent traiter de mani\u00e8re proactive les perturbations potentielles, garantissant ainsi un environnement Active Directory stable et s\u00e9curis\u00e9. Pour les MSP, des outils comme NinjaOne compl\u00e8tent ce script en fournissant une plateforme centralis\u00e9e pour la gestion et le contr\u00f4le des op\u00e9rations informatiques. Ensemble, ils constituent une strat\u00e9gie solide pour maintenir l&rsquo;int\u00e9grit\u00e9 informatique de l&rsquo;entreprise.<\/p>\n","protected":false},"author":35,"featured_media":0,"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":[4284],"class_list":["post-394202","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/394202","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=394202"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=394202"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=394202"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=394202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}