{"id":531910,"date":"2025-09-25T00:41:05","date_gmt":"2025-09-25T00:41:05","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=531910"},"modified":"2025-09-25T00:41:05","modified_gmt":"2025-09-25T00:41:05","slug":"blocage-des-adresses-ip-wan-avec-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/blocage-des-adresses-ip-wan-avec-powershell\/","title":{"rendered":"Comment effectuer une v\u00e9rification de la liste de blocage des adresses IP WAN avec PowerShell"},"content":{"rendered":"<p>Le blacklistage des adresses IP publiques est une menace silencieuse mais significative dans les environnements d&rsquo;entreprise hyperconnect\u00e9s. Lorsque l&rsquo;IP WAN de votre entreprise se retrouve sur une liste de blocage bas\u00e9e sur le DNS (DNSBL), cela peut entra\u00eener des courriels non d\u00e9livr\u00e9s, des communications interrompues et une perte de confiance de la part des clients. Pour les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\/\">fournisseurs de services g\u00e9r\u00e9s (MSP)<\/a> et les professionnels de l&rsquo;informatique, il est essentiel de d\u00e9tecter ces incidents et d&rsquo;y r\u00e9pondre avant qu&rsquo;ils n&rsquo;aient un impact sur les op\u00e9rations. Apprendre \u00e0 <strong>automatiser<\/strong> <strong>la v\u00e9rification de la liste de blocage des adresses IP WAN (r\u00e9seau \u00e9tendu) avec PowerShell<\/strong> peut constituer un outil puissant dans la bo\u00eete \u00e0 outils de la cybers\u00e9curit\u00e9 proactive.<\/p>\n<h2>Contexte<\/h2>\n<p>De nombreuses entreprises ne se rendent pas compte que leur adresse IP WAN a \u00e9t\u00e9 mise sur liste noire avant d&rsquo;\u00eatre confront\u00e9es \u00e0 des probl\u00e8mes de d\u00e9livrabilit\u00e9 du courrier \u00e9lectronique ou de recevoir des plaintes de la part de leurs clients. Les listes noires sont g\u00e9r\u00e9es par des services tiers qui signalent les adresses IP impliqu\u00e9es dans des spams ou des activit\u00e9s malveillantes. Bien que ces services soient essentiels \u00e0 l&rsquo;hygi\u00e8ne globale du courrier \u00e9lectronique, les faux positifs ne sont pas rares, en particulier pour les adresses IP dynamiques ou les environnements d&rsquo;h\u00e9bergement partag\u00e9s.<\/p>\n<p>Ce script PowerShell a \u00e9t\u00e9 con\u00e7u pour automatiser le processus de v\u00e9rification d&rsquo;une adresse IP WAN par rapport \u00e0 des dizaines de DNSBL courants. Il peut \u00eatre ex\u00e9cut\u00e9 manuellement ou programm\u00e9 pour des v\u00e9rifications p\u00e9riodiques, ce qui en fait un excellent outil pour les MSP et les \u00e9quipes d&rsquo;exploitation informatique internes qui doivent v\u00e9rifier la sant\u00e9 de l&rsquo;IP externe dans plusieurs environnements clients.<\/p>\n<h2>Le script<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Checks several common blacklists to see if the device's WAN IP is currently being blacklisted. A private recursive DNS server is recommended, as it is not uncommon for DNS blocklists to block public DNS servers such as 1.1.1.1.\r\n.DESCRIPTION\r\n    Checks several common blacklists to see if the device's WAN IP is currently being blacklisted. A private recursive DNS server is recommended, as it is not uncommon for DNS blocklists to block public DNS servers such as 1.1.1.1. \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.EXAMPLE\r\n    (No Parameters) - When found on blacklist\r\n\r\n    [Alert] The WAN IP '127.0.0.1' was found on 9 blacklist(s).\r\n    You may want to validate these results with 'https:\/\/mxtoolbox.com\/SuperTool.aspx?action=blacklist%3a127.0.0.1'.\r\n    Name                          TTL                                                ResponseCode                          \r\n    ----                          ---                                                ------------                          \r\n    Blocklist.de                  1269                                               127.0.0.14                            \r\n    Interserver RBL               903                                                127.0.0.2                             \r\n    Interserver Spam Assassin RBL 903                                                127.0.0.2                             \r\n    Mailspike Z                   120                                                127.0.0.2                             \r\n    Mailspike BL                  120                                                127.0.0.2                             \r\n    S5H                           5, 86400, 86400, 86400, 30, 300, 30, 300, 300, 300 127.0.0.2, 85.119.82.99, 2001:ba8:1...\r\n    UCE Protect - L1              902                                                127.0.0.2                             \r\n    UCE Protect - L2              902                                                127.0.0.2                             \r\n    UCE Protect - L3              902                                                127.0.0.2\r\n\r\n    Blacklists Checked: 0Spam, 0Spam RBL, Anonmails DNSBL, Backscatterer, Blocklist.de, Cymru Bogons, Dan Tor, Dan Tor Exit, Drone BL, Fabel Sources, Host Karma, ImproWare (IMP) DNS RBL, ImproWare (IMP) Spam RBL, Interserver RBL, Interserver Spam Assassin RBL, JIPPG's Relay Blackhole List Project, Kempt.net DNS Black List, Mailspike Z, Mailspike BL, Nordspam BL, PSBL, S5H, Schulte, Spam Eating Monkey - Backscatter, Spam Eating Monkey - Black, SpamCop, Suomispam, Truncate, UCE Protect - L1, UCE Protect - L2, UCE Protect - L3, ZapBL\r\n\r\n.EXAMPLE\r\n    (No Parameters) - When not found on blacklist\r\n\r\n    The WAN IP '127.0.0.1' was not found on any blacklists.\r\n    You may want to validate these results with 'https:\/\/mxtoolbox.com\/SuperTool.aspx?action=blacklist%3a127.0.0.1'.\r\n\r\n    Blacklists Checked: 0Spam, 0Spam RBL, Anonmails DNSBL, Backscatterer, Blocklist.de, Cymru Bogons, Dan Tor, Dan Tor Exit, Drone BL, Fabel Sources, Host Karma, ImproWare (IMP) DNS RBL, ImproWare (IMP) Spam RBL, Interserver RBL, Interserver Spam Assassin RBL, JIPPG's Relay Blackhole List Project, Kempt.net DNS Black List, Mailspike Z, Mailspike BL, Nordspam BL, PSBL, S5H, Schulte, Spam Eating Monkey - Backscatter, Spam Eating Monkey - Black, SpamCop, Suomispam, Truncate, UCE Protect - L1, UCE Protect - L2, UCE Protect - L3, ZapBL\r\n\r\nPARAMETER: -CustomField \"ReplaceMeWithYourDesiredMultilineCustomField\"\r\n    Optionally specify the name of a multiline custom field to store the results in.\r\n\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]$CustomField\r\n)\r\n\r\nbegin {\r\n    # If using script form variables, replace command line parameters with them.\r\n    if($env:multilineCustomFieldName -and $env:multilineCustomFieldName -notlike \"null\") { $CustomField = $env:multilineCustomFieldName }\r\n\r\n    # Local administrator privileges are required to set custom fields.\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    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    # Blacklists we are going to check.\r\n    $BlackLists = @(\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"0Spam\"\r\n            DNSBLDomainName = \"bl.0spam.org\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"0Spam RBL\"\r\n            DNSBLDomainName = \"rbl.0spam.org\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Anonmails DNSBL\"\r\n            DNSBLDomainName = \"spam.dnsbl.anonmails.de\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Backscatterer\"\r\n            DNSBLDomainName = \"ips.backscatterer.org\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Blocklist.de\"\r\n            DNSBLDomainName = \"bl.blocklist.de\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Cymru Bogons\"\r\n            DNSBLDomainName = \"bogons.cymru.com\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Dan Tor\"\r\n            DNSBLDomainName = \"tor.dan.me.uk\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Dan Tor Exit\"\r\n            DNSBLDomainName = \"torexit.dan.me.uk\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Drone BL\"\r\n            DNSBLDomainName = \"dnsbl.dronebl.org\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Fabel Sources\"\r\n            DNSBLDomainName = \"spamsources.fabel.dk\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Host Karma\"\r\n            DNSBLDomainName = \"hostkarma.junkemailfilter.com\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"ImproWare (IMP) DNS RBL\"\r\n            DNSBLDomainName = \"dnsrbl.swinog.ch\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"ImproWare (IMP) Spam RBL\"\r\n            DNSBLDomainName = \"spamrbl.swinog.ch\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Interserver RBL\"\r\n            DNSBLDomainName = \"rbl.interserver.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Interserver Spam Assassin RBL\"\r\n            DNSBLDomainName = \"rblspamassassin.interserver.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"JIPPG's Relay Blackhole List Project\"\r\n            DNSBLDomainName = \"mail-abuse.blacklist.jippg.org\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Kempt.net DNS Black List\"\r\n            DNSBLDomainName = \"dnsbl.kempt.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Mailspike Z\"\r\n            DNSBLDomainName = \"z.mailspike.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Mailspike BL\"\r\n            DNSBLDomainName = \"bl.mailspike.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Nordspam BL\"\r\n            DNSBLDomainName = \"bl.nordspam.com\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"PSBL\"\r\n            DNSBLDomainName = \"psbl.surriel.com\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"S5H\"\r\n            DNSBLDomainName = \"all.s5h.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Schulte\"\r\n            DNSBLDomainName = \"rbl.schulte.org\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Spam Eating Monkey - Backscatter\"\r\n            DNSBLDomainName = \"backscatter.spameatingmonkey.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Spam Eating Monkey - Black\"\r\n            DNSBLDomainName = \"bl.spameatingmonkey.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"SpamCop\"\r\n            DNSBLDomainName = \"bl.spamcop.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Suomispam\"\r\n            DNSBLDomainName = \"bl.suomispam.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"Truncate\"\r\n            DNSBLDomainName = \"truncate.gbudb.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"UCE Protect - L1\"\r\n            DNSBLDomainName = \"dnsbl-1.uceprotect.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"UCE Protect - L2\"\r\n            DNSBLDomainName = \"dnsbl-2.uceprotect.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"UCE Protect - L3\"\r\n            DNSBLDomainName = \"dnsbl-3.uceprotect.net\"\r\n        }\r\n        [PSCustomObject]@{\r\n            DisplayName     = \"ZapBL\"\r\n            DNSBLDomainName = \"dnsbl.zapbl.net\"\r\n        }\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 running with elevated privileges (Administrator)\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    # Try to retrieve the WAN IP using the ipify.org service\r\n    try {\r\n        $WanIP = (Invoke-WebRequest -Uri \"api.ipify.org\" -UseBasicParsing).Content\r\n    }\r\n    catch {\r\n        Write-Host -Object \"[Error] Failed to retrieve WAN IP.\"\r\n        Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n        exit 1\r\n    }\r\n\r\n    # Validate the retrieved WAN IP format\r\n    if ($WanIP -notmatch '\\d+\\.\\d+\\.\\d+\\.\\d+') {\r\n        Write-Host -Object \"[Error] The service ipify.org returned '$WanIp' which is not a valid IP.\"\r\n        exit 1\r\n    }\r\n\r\n    # Further validate the WAN IP by attempting to cast it as an IP address object\r\n    try {\r\n        [IPAddress]$WanIP | Out-Null\r\n    }\r\n    catch {\r\n        Write-Host -Object \"[Error] The service ipify.org returned '$WanIp' which is not a valid IP.\"\r\n        Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n        exit 1\r\n    }\r\n\r\n    # Reverse the IP address octets for DNSBL query\r\n    $IPOctets = $WanIP -split '\\.'\r\n    [array]::Reverse($IPOctets)\r\n    $ReversedIp = $IPOctets -join '.'\r\n\r\n    # Validate the reversed IP format\r\n    if ($ReversedIp -notmatch '\\d+\\.\\d+\\.\\d+\\.\\d+') {\r\n        Write-Host -Object \"[Error] '$ReversedIp' is not a valid reversed IP of '$WanIP'.\"\r\n        exit 1\r\n    }\r\n\r\n    # Further validate the reversed IP by attempting to cast it as an IP address object\r\n    try {\r\n        [IPAddress]$ReversedIp | Out-Null\r\n    }\r\n    catch {\r\n        Write-Host -Object \"[Error] '$ReversedIp' is not a valid reversed IP of '$WanIP'.\"\r\n        Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n        exit 1\r\n    }\r\n\r\n    # Initialize a list to store blacklisted services\r\n    $BlackListedServices = New-Object System.Collections.Generic.List[object]\r\n\r\n    # Loop through each DNSBL to check if the IP is listed\r\n    $BlackLists | ForEach-Object {\r\n        try {\r\n            $Result = Resolve-DnsName -Name \"$ReversedIp.$($_.DNSBLDomainName)\" -NoHostsFile -DnsOnly -QuickTimeout -ErrorAction Stop\r\n\r\n            $BlockListIP = Resolve-DnsName -Name $($_.DNSBLDomainName) -NoHostsFile -DnsOnly -QuickTimeout -ErrorAction SilentlyContinue | Select-Object -ExpandProperty IPAddress -ErrorAction SilentlyContinue\r\n\r\n            foreach($IPAddress in $Result.IPAddress){\r\n                if($IPaddress -notmatch '^127\\.0\\.' -and $BlockListIP -and $BlockListIP -notcontains $IPAddress){\r\n                    Write-Host -Object \"[Error] A Response Code of '$IPaddress' was given by $($_.DisplayName).\"\r\n                    Write-Host -Object \"[Error] Typically response codes start with '127.0.' you may want to use different DNS servers.\"\r\n                    $ExitCode = 1\r\n                    return\r\n                }\r\n            }\r\n\r\n            # If the result does not contain an IP address skip to next entry\r\n            if(!$($Result.IPAddress)){\r\n                return\r\n            }\r\n\r\n            $BlackListedServices.Add(\r\n                [PSCustomObject]@{\r\n                    Name         = $($_.DisplayName)\r\n                    TTL          = $($Result.TTL -join ', ')\r\n                    ResponseCode = $($Result.IPAddress -join ', ')\r\n                }\r\n            )\r\n        }\r\n        catch {\r\n            return\r\n        }\r\n    }\r\n\r\n    # Create a custom field value to store the results\r\n    $CustomFieldValue = New-Object System.Collections.Generic.List[string]\r\n    $MXToolboxLink = \"https:\/\/mxtoolbox.com\/SuperTool.aspx?action=blacklist%3a$WanIP\"\r\n\r\n    # Check if any blacklists contain the WAN IP and output the results\r\n    if($BlackListedServices.Count -gt 0){\r\n        Write-Host -Object \"[Alert] The WAN IP '$WanIp' was found on $($BlackListedServices.Count) blacklist(s).\"\r\n        Write-Host -Object \"You may want to validate these results with '$MXToolboxLink'.\"\r\n        $CustomFieldValue.Add(\"[Alert] The WAN IP '$WanIp' was found on $($BlackListedServices.Count) blacklist(s).\")\r\n        $CustomFieldValue.Add($MXToolboxLink)\r\n\r\n        ($BlackListedServices | Format-Table | Out-String).Trim() | Write-Host\r\n        $CustomFieldValue.Add($($BlackListedServices | Format-List | Out-String))\r\n    }else{\r\n        Write-Host -Object \"The WAN IP '$WanIp' was not found on any blacklists.\"\r\n        Write-Host -Object \"You may want to validate these results with '$MXToolboxLink'.\"\r\n\r\n        $CustomFieldValue.Add(\"The WAN IP '$WanIp' was not found on any blacklists.\")\r\n        $CustomFieldValue.Add($MXToolboxLink)\r\n    }\r\n\r\n    # Output the list of blacklists checked\r\n    Write-Host -Object \"`nBlacklists Checked: $($BlackLists.DisplayName -join ', ')\"\r\n\r\n    # Optionally set a custom field with the results\r\n    if($CustomField){\r\n        try {\r\n            Write-Host \"`nAttempting to set Custom Field '$CustomField'.\"\r\n            Set-NinjaProperty -Name $CustomField -Value $CustomFieldValue\r\n            Write-Host \"Successfully set Custom Field '$CustomField'!\"\r\n        }\r\n        catch {\r\n            Write-Host \"[Error] $($_.Exception.Message)\"\r\n            exit 1\r\n        }\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<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>\u00c0 un niveau \u00e9lev\u00e9, le script effectue les op\u00e9rations suivantes :<\/p>\n<ol>\n<li><strong>Pr\u00e9paration de l&rsquo;environnement<\/strong>\n<ul>\n<li>N\u00e9cessite PowerShell 5.1 et des privil\u00e8ges d&rsquo;administrateur.<\/li>\n<li>S&rsquo;int\u00e8gre en option avec les champs personnalis\u00e9s de NinjaOne pour l&rsquo;\u00e9tablissement de rapports.<\/li>\n<\/ul>\n<\/li>\n<li><strong>R\u00e9cup\u00e9rer l&rsquo;IP WAN<\/strong>\n<ul>\n<li>Utilise ipify.org pour obtenir l&rsquo;adresse IP actuelle du r\u00e9seau \u00e9tendu.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Formatage invers\u00e9 de l&rsquo;IP<\/strong>\n<ul>\n<li>Formate l&rsquo;IP pour les requ\u00eates DNSBL (par exemple, 1.2.3.4 devient 4.3.2.1).<\/li>\n<\/ul>\n<\/li>\n<li><strong>Ex\u00e9cution de la requ\u00eate DNSBL<\/strong>\n<ul>\n<li>Passe en boucle par plus de 30 listes de blocage pr\u00e9d\u00e9finies.<\/li>\n<li>Utilise Resolve-DnsName pour v\u00e9rifier les entr\u00e9es de la liste de blocage.<\/li>\n<li>Identifie si l&rsquo;IP est list\u00e9e et capture le TTL et les codes de r\u00e9ponse.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Enregistrement et sortie des r\u00e9sultats<\/strong>\n<ul>\n<li>Produit les r\u00e9sultats de la liste de blocage dans un format lisible par l&rsquo;homme.<\/li>\n<li>G\u00e9n\u00e8re un lien pour valider les r\u00e9sultats via MXToolbox.<\/li>\n<li>Il est possible d&rsquo;\u00e9crire dans un champ personnalis\u00e9 multiligne NinjaOne \u00e0 l&rsquo;aide d&rsquo;une fonction Set-NinjaProperty int\u00e9gr\u00e9e.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Code de sortie<\/strong>\n<ul>\n<li>D\u00e9finit un code de sortie appropri\u00e9 en fonction de la pr\u00e9sence d&rsquo;une liste noire, ce qui facilite l&rsquo;int\u00e9gration dans les processus d&rsquo;automatisation.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<p>Imaginez un sc\u00e9nario dans lequel un fournisseur de services g\u00e9r\u00e9s (MSP) re\u00e7oit des rapports indiquant que les e-mails des clients sont rejet\u00e9s. Au lieu de v\u00e9rifier manuellement l&rsquo;IP WAN par rapport \u00e0 plusieurs DNSBL, le technicien ex\u00e9cute ce script \u00e0 distance via NinjaOne. En quelques instants, le script identifie que l&rsquo;adresse IP du client figure sur quatre listes noires. Le technicien utilise la sortie pour lancer les proc\u00e9dures de radiation tout en documentant le r\u00e9sultat dans un champ personnalis\u00e9 NinjaOne pour r\u00e9f\u00e9rence ult\u00e9rieure.<\/p>\n<p>Ce niveau de r\u00e9ponse rapide r\u00e9duit consid\u00e9rablement les temps d&rsquo;arr\u00eat et assure la transparence pour les parties prenantes internes et les clients.<\/p>\n<h2>Comparaisons<\/h2>\n<p>Traditionnellement, les v\u00e9rifications des listes de blocage sont effectu\u00e9es manuellement \u00e0 l&rsquo;aide d&rsquo;outils Web tels que MXToolbox ou par l&rsquo;interm\u00e9diaire de plateformes de surveillance haut de gamme. Bien qu&rsquo;efficaces, ces m\u00e9thodes sont r\u00e9actives et n\u00e9cessitent un d\u00e9clenchement manuel. En revanche, ce script <a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-powershell\/\">PowerShell<\/a> :<\/p>\n<ul>\n<li>Permet\u00a0<strong>l&rsquo;automatisation<\/strong>\u00a0et\u00a0<strong>la planification<\/strong>,<\/li>\n<li>Peut \u00eatre utiliser pour un\u00a0<strong>grand nombre de terminaux<\/strong>, et<\/li>\n<li>Int\u00e9gration native avec les champs personnalis\u00e9s de\u00a0<strong>NinjaOne<\/strong>\u00a0pour la cr\u00e9ation de rapports et la documentation.<\/li>\n<\/ul>\n<p>Il existe d&rsquo;autres approches de script, mais peu d&rsquo;entre elles offrent ce niveau de gestion int\u00e9gr\u00e9e des erreurs, de couverture de plusieurs listes et de formatage des r\u00e9sultats adapt\u00e9 aux flux de travail des entreprises MSP.<\/p>\n<h2>Questions fr\u00e9quentes<\/h2>\n<h3>Q\u00a0: Que se passe-t-il si l&rsquo;adresse IP WAN ne peut \u00eatre r\u00e9cup\u00e9r\u00e9e ?<\/h3>\n<p>R\u00a0: Le script se termine de mani\u00e8re \u00e9l\u00e9gante et informe l&rsquo;utilisateur par un message d&rsquo;erreur si ipify.org est inaccessible ou renvoie un format non valide.<\/p>\n<h3>Q\u00a0: Puis-je utiliser un serveur DNS public comme 8.8.8.8 ?<\/h3>\n<p>R\u00a0: Ce n&rsquo;est pas recommand\u00e9. De nombreux DNSBL bloquent les requ\u00eates provenant de r\u00e9solveurs publics. Utilisez un serveur DNS r\u00e9cursif priv\u00e9 pour obtenir des r\u00e9sultats pr\u00e9cis.<\/p>\n<h3>Q\u00a0: Comment ce syst\u00e8me est-il int\u00e9gr\u00e9 \u00e0 NinjaOne ?<\/h3>\n<p>R\u00a0: Si un nom de champ personnalis\u00e9 est fourni, le script \u00e9crit les r\u00e9sultats dans ce champ en utilisant l&rsquo;interface en ligne de commande (CLI) de NinjaOne. C&rsquo;est id\u00e9al pour les pistes d&rsquo;audit et la documentation.<\/p>\n<h3>Q\u00a0: Ce script va-t-il modifier la configuration de mon r\u00e9seau ?<\/h3>\n<p>R\u00a0: Non, le script est en lecture seule, sauf lorsqu&rsquo;il \u00e9crit dans les champs NinjaOne (s&rsquo;ils sont configur\u00e9s).<\/p>\n<h2>Implications<\/h2>\n<p>Si une IP WAN est trouv\u00e9e dans un seul DNSBL, cela peut entra\u00eener le rejet ou le renvoi silencieux des e-mails sortants. Cela peut nuire \u00e0 la r\u00e9putation de l&rsquo;entreprise et perturber ses activit\u00e9s. L&rsquo;automatisation de la d\u00e9tection des listes de blocage permet aux \u00e9quipes informatiques de r\u00e9agir rapidement et d&rsquo;\u00e9viter que de petits probl\u00e8mes ne se transforment en incidents majeurs.<\/p>\n<p>De plus, des entr\u00e9es r\u00e9p\u00e9t\u00e9es dans la liste de blocage peuvent signaler des probl\u00e8mes plus profonds, tels que des dispositifs internes compromis ou des relais de messagerie mal configur\u00e9s. Des contr\u00f4les r\u00e9guliers permettent de d\u00e9tecter ces anomalies \u00e0 un stade pr\u00e9coce.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Ex\u00e9cutez le script chaque semaine<\/strong>\u00a0sur les appareils critiques ou les clients disposant d&rsquo;une adresse IP statique.<\/li>\n<li><strong>Utilisez un serveur DNS s\u00e9curis\u00e9 et r\u00e9cursif<\/strong>\u00a0pour garantir des r\u00e9sultats fiables.<\/li>\n<li><strong>Utilisez les champs de NinjaOne<\/strong>\u00a0pour enregistrer l&rsquo;historique des listes de blocage et en d\u00e9gager des tendances.<\/li>\n<li><strong>Assurez le suivi de toute d\u00e9tection de liste noire<\/strong>\u00a0en consultant le fournisseur de liste noire pour conna\u00eetre les mesures correctives \u00e0 prendre.<\/li>\n<li><strong>Incorporez le script dans les pipelines RMM ou CI\/CD<\/strong>\u00a0pour une surveillance continue.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>La v\u00e9rification de la liste de blocage des adresses IP du r\u00e9seau \u00e9tendu \u00e0 l&rsquo;aide de PowerShell permet aux \u00e9quipes informatiques de conna\u00eetre les risques de r\u00e9putation externes avant qu&rsquo;ils ne deviennent critiques. Ce script, en particulier lorsqu&rsquo;il est associ\u00e9 aux fonctions d&rsquo;automatisation et de documentation de NinjaOne, permet d&rsquo;adopter une position proactive en mati\u00e8re de d\u00e9livrabilit\u00e9 du courrier \u00e9lectronique et d&rsquo;hygi\u00e8ne de la s\u00e9curit\u00e9. Il permet aux entreprises MSP et aux administrateurs informatiques de disposer d&rsquo;une solution \u00e9volutive et v\u00e9rifiable pour g\u00e9rer et maintenir l&rsquo;int\u00e9grit\u00e9 des IP WAN dans l&rsquo;ensemble de leur parc informatique.<\/p>\n<p>Si vous cherchez \u00e0 rendre op\u00e9rationnels vos contr\u00f4les de l&rsquo;int\u00e9grit\u00e9 du r\u00e9seau ou \u00e0 optimiser les rapports destin\u00e9s aux clients, l&rsquo;int\u00e9gration de ce script dans vos flux de travail <a href=\"https:\/\/www.ninjaone.com\/fr\/\">NinjaOne<\/a> est un point de d\u00e9part pratique et \u00e0 fort impact.<\/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":[4281],"class_list":["post-531910","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\/531910","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=531910"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=531910"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=531910"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=531910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}