{"id":353647,"date":"2024-08-27T09:11:51","date_gmt":"2024-08-27T09:11:51","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/trouver-et-supprimer-des-certificats\/"},"modified":"2024-10-13T19:07:30","modified_gmt":"2024-10-13T19:07:30","slug":"trouver-et-supprimer-des-certificats","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/trouver-et-supprimer-des-certificats\/","title":{"rendered":"Comment trouver et supprimer des certificats par empreinte de fa\u00e7on efficace \u00e0 l&rsquo;aide de PowerShell"},"content":{"rendered":"<p>La gestion des certificats de syst\u00e8me est une t\u00e2che essentielle pour les professionnels de l&rsquo;informatique et les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\/\" target=\"_blank\" rel=\"noopener\">fournisseurs de services g\u00e9r\u00e9s (MSP).<\/a> Les certificats sont l&rsquo;\u00e9pine dorsale de la communication s\u00e9curis\u00e9e et il est essentiel de s&rsquo;assurer qu&rsquo;ils sont correctement g\u00e9r\u00e9s pour maintenir l&rsquo;int\u00e9grit\u00e9 et la s\u00e9curit\u00e9 des syst\u00e8mes informatiques. Ce script PowerShell complet est con\u00e7u pour rationaliser le <strong>processus de recherche et de suppression des certificats syst\u00e8me par empreinte<\/strong>, r\u00e9pondant ainsi \u00e0 un besoin courant dans le monde informatique.<\/p>\n<h2>Contexte<\/h2>\n<p>Les certificats authentifient et chiffrent les donn\u00e9es afin de garantir la s\u00e9curit\u00e9 des communications sur les r\u00e9seaux. Au fil du temps, les certificats peuvent devenir invalides, expirer ou \u00eatre compromis, ce qui n\u00e9cessite leur suppression. Les professionnels de l&rsquo;informatique et les MSP ont souvent besoin d&rsquo;une m\u00e9thode fiable pour localiser et g\u00e9rer efficacement ces certificats. Ce script PowerShell fournit une solution robuste pour trouver et g\u00e9rer les certificats par empreinte, garantissant ainsi la s\u00e9curit\u00e9 et la conformit\u00e9 des syst\u00e8mes.<\/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    Returns a list of system certificates that have the specified thumbprints or Removes the certificates with matching thumbprints.\r\n.DESCRIPTION\r\n    Returns a list of system certificates that have the specified thumbprints or Removes the certificates with matching thumbprints.\r\n\r\n.EXAMPLE\r\n    (No Parameters)\r\n    ## EXAMPLE OUTPUT WITHOUT PARAMS ##\r\n    Does nothing.\r\n\r\n.EXAMPLE\r\nPARAMETER: -Thumbprint \"AE68D0ADAD2345B48E507320B695D386080E5B25\", \"BE68D0ADAA2145B48E507320B695D386080E5B25\"\r\n    Returns the found thumbprints matching the input.\r\n    ## EXAMPLE OUTPUT WITH Thumbprint ##\r\n    [Alert] Found certificates:\r\n    AE68D0ADAD2345B48E507320B695D386080E5B25\r\n    BE68D0ADAA2145B48E507320B695D386080E5B25\r\n    [Alert] Certificates found\r\n\r\n.EXAMPLE\r\nPARAMETER: -Thumbprint \"BE68D0ADAA2145B48E507320B695D386080E5B25\" -RemoveMatchingCertificates\r\n    Returns the found thumbprints matching the input and Removes the certificates.\r\n    ## EXAMPLE OUTPUT WITH RemoveMatchingCertificates ##\r\n    [Alert] Found certificates:\r\n    BE68D0ADAA2145B48E507320B695D386080E5B25\r\n    [Info] Removing certificates\r\n    [Info] Removing certificate with thumbprint: BE68D0ADAA2145B48E507320B695D386080E5B25\r\n    [Info] Removed certificate with thumbprint: BE68D0ADAA2145B48E507320B695D386080E5B25\r\n    [Alert] Certificates found\r\n.EXAMPLE\r\nPARAMETER: -Thumbprint \"BE68D0ADAA2145B48E507320B695D386080E5B25\" -CustomField \"Thumbprints\"\r\n    Returns the found thumbprints matching the input and Removes the certificates.\r\n    ## EXAMPLE OUTPUT WITH RemoveMatchingCertificates ##\r\n    [Alert] Found certificates:\r\n    BE68D0ADAA2145B48E507320B695D386080E5B25\r\n    [Info] Saving thumbprints to custom field: Thumbprints\r\n    [Alert] Certificates found\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: 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    Generic-Security\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [string[]]$Thumbprint,\r\n    [switch]$RemoveMatchingCertificates,\r\n    [string]$CertRevokeList,\r\n    [string]$GetCrlFromCustomField,\r\n    [string]$CustomField\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        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\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        # If we're requested to set the field value for a Ninja document we'll specify it here.\r\n        $DocumentationParams = @{}\r\n        if ($DocumentName) { $DocumentationParams[\"DocumentName\"] = $DocumentName }\r\n\r\n        # This is a list of valid fields we can set. If no type is given we'll assume the input doesn't have to be changed in any way.\r\n        $ValidFields = \"Attachment\", \"Checkbox\", \"Date\", \"Date or Date Time\", \"Decimal\", \"Dropdown\", \"Email\", \"Integer\", \"IP Address\", \"MultiLine\", \"MultiSelect\", \"Phone\", \"Secure\", \"Text\", \"Time\", \"URL\"\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 below field requires additional information in order to set\r\n        $NeedsOptions = \"Dropdown\"\r\n        if ($DocumentName) {\r\n            if ($NeedsOptions -contains $Type) {\r\n                # We'll redirect the error output to the success stream to make it easier to error out if nothing was found or something else went 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 we received some sort of error it should have an exception property and we'll exit the function with that error information.\r\n        if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions }\r\n\r\n        # The below type's require values not typically given in order to be set. The below code will convert whatever we're given into a format ninjarmm-cli supports.\r\n        switch ($Type) {\r\n            \"Checkbox\" {\r\n                # While it's highly likely we were given a value like \"True\" or a boolean datatype 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 is expecting the time to be representing as a Unix Epoch string. So we'll convert what we were given into that format.\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 is expecting the guid of the option we're trying to select. So we'll match up 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 \"Value is not present in dropdown\"\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        # We'll need to set the field differently depending on if its 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 = Ninja-Property-Set -Name $Name -Value $NinjaValue 2&gt;&amp;1\r\n        }\r\n\r\n        if ($CustomField.Exception) {\r\n            throw $CustomField\r\n        }\r\n    }\r\n    # This function is to make it easier to parse Ninja Custom Fields.\r\n    function Get-NinjaProperty {\r\n        [CmdletBinding()]\r\n        Param(\r\n            [Parameter(Mandatory = $True, ValueFromPipeline = $True)]\r\n            [String]$Name,\r\n            [Parameter()]\r\n            [String]$Type,\r\n            [Parameter()]\r\n            [String]$DocumentName\r\n        )\r\n    \r\n        if ($PSVersionTable.PSVersion.Major -lt 3) {\r\n            throw \"PowerShell 3.0 or higher is required to retrieve data from custom fields. https:\/\/ninjarmm.zendesk.com\/hc\/en-us\/articles\/4405408656013\"\r\n        }\r\n    \r\n        # If we're requested to get the field value from a Ninja document we'll specify it here.\r\n        $DocumentationParams = @{}\r\n        if ($DocumentName) { $DocumentationParams[\"DocumentName\"] = $DocumentName }\r\n    \r\n        # These two types require more information to parse.\r\n        $NeedsOptions = \"DropDown\", \"MultiSelect\"\r\n    \r\n        # Grabbing document values requires a slightly different command.\r\n        if ($DocumentName) {\r\n            # Secure fields are only readable when they're a device custom field\r\n            if ($Type -Like \"Secure\") { throw \"$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            # We'll redirect the error output to the success stream to make it easier to error out if nothing was found or something else went wrong.\r\n            Write-Host \"Retrieving value from Ninja Document...\"\r\n            $NinjaPropertyValue = Ninja-Property-Docs-Get -AttributeName $Name @DocumentationParams 2&gt;&amp;1\r\n    \r\n            # Certain fields require more information to parse.\r\n            if ($NeedsOptions -contains $Type) {\r\n                $NinjaPropertyOptions = Ninja-Property-Docs-Options -AttributeName $Name @DocumentationParams 2&gt;&amp;1\r\n            }\r\n        }\r\n        else {\r\n            # We'll redirect error output to the success stream to make it easier to error out if nothing was found or something else went wrong.\r\n            $NinjaPropertyValue = Ninja-Property-Get -Name $Name 2&gt;&amp;1\r\n    \r\n            # Certain fields require more information to parse.\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 we received some sort of error it should have an exception property and we'll exit the function with that error information.\r\n        if ($NinjaPropertyValue.Exception) { throw $NinjaPropertyValue }\r\n        if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions }\r\n    \r\n        # This switch will compare the type given with the quoted string. If it matches, it'll parse it further; otherwise, the default option will be selected.\r\n        switch ($Type) {\r\n            \"Attachment\" {\r\n                # Attachments come in a JSON format this will convert it into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Checkbox\" {\r\n                # Checkbox's come in as a string representing an integer. We'll need to cast that string into an integer and then convert it to a more traditional boolean.\r\n                [System.Convert]::ToBoolean([int]$NinjaPropertyValue)\r\n            }\r\n            \"Date or Date Time\" {\r\n                # In Ninja Date and Date\/Time fields are in Unix Epoch time in the UTC timezone the below should convert it into local time as a datetime object.\r\n                $UnixTimeStamp = $NinjaPropertyValue\r\n                $UTC = (Get-Date \"1970-01-01 00:00:00\").AddSeconds($UnixTimeStamp)\r\n                $TimeZone = [TimeZoneInfo]::Local\r\n                [TimeZoneInfo]::ConvertTimeFromUtc($UTC, $TimeZone)\r\n            }\r\n            \"Decimal\" {\r\n                # In ninja decimals are strings that represent a decimal this will cast it into a double data type.\r\n                [double]$NinjaPropertyValue\r\n            }\r\n            \"Device Dropdown\" {\r\n                # Device Drop-Downs Fields come in a JSON format this will convert it into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Device MultiSelect\" {\r\n                # Device Multi-Select Fields come in a JSON format this will convert it into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Dropdown\" {\r\n                # Drop-Down custom fields come in as a comma-separated list of GUIDs; we'll compare these with all the options and return just the option values selected instead of a GUID.\r\n                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header \"GUID\", \"Name\"\r\n                $Options | Where-Object { $_.GUID -eq $NinjaPropertyValue } | Select-Object -ExpandProperty Name\r\n            }\r\n            \"Integer\" {\r\n                # Cast's the Ninja provided string into an integer.\r\n                [int]$NinjaPropertyValue\r\n            }\r\n            \"MultiSelect\" {\r\n                # Multi-Select custom fields come in as a comma-separated list of GUID's we'll compare these with all the options and return just the option values selected instead of a guid.\r\n                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header \"GUID\", \"Name\"\r\n                $Selection = ($NinjaPropertyValue -split ',').trim()\r\n    \r\n                foreach ($Item in $Selection) {\r\n                    $Options | Where-Object { $_.GUID -eq $Item } | Select-Object -ExpandProperty Name\r\n                }\r\n            }\r\n            \"Organization Dropdown\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Organization Location Dropdown\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Organization Location MultiSelect\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Organization MultiSelect\" {\r\n                # Turns the Ninja provided JSON into a PowerShell Object.\r\n                $NinjaPropertyValue | ConvertFrom-Json\r\n            }\r\n            \"Time\" {\r\n                # Time fields are given as a number of seconds starting from midnight. This will convert it into a datetime object.\r\n                $Seconds = $NinjaPropertyValue\r\n                $UTC = ([timespan]::fromseconds($Seconds)).ToString(\"hh\\:mm\\:ss\")\r\n                $TimeZone = [TimeZoneInfo]::Local\r\n                $ConvertedTime = [TimeZoneInfo]::ConvertTimeFromUtc($UTC, $TimeZone)\r\n    \r\n                Get-Date $ConvertedTime -DisplayHint Time\r\n            }\r\n            default {\r\n                # If no type was given or not one that matches the above types just output what we retrieved.\r\n                $NinjaPropertyValue\r\n            }\r\n        }\r\n    }\r\n    # Utility function for downloading files.\r\n    function Invoke-Download {\r\n        param(\r\n            [Parameter()]\r\n            [String]$URL,\r\n            [Parameter()]\r\n            [String]$Path,\r\n            [Parameter()]\r\n            [int]$Attempts = 3,\r\n            [Parameter()]\r\n            [Switch]$SkipSleep\r\n        )\r\n        Write-Host \"URL given, Downloading the file...\"\r\n\r\n        $SupportedTLSversions = [enum]::GetValues('Net.SecurityProtocolType')\r\n        if ( ($SupportedTLSversions -contains 'Tls13') -and ($SupportedTLSversions -contains 'Tls12') ) {\r\n            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol::Tls13 -bor [System.Net.SecurityProtocolType]::Tls12\r\n        }\r\n        elseif ( $SupportedTLSversions -contains 'Tls12' ) {\r\n            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12\r\n        }\r\n        else {\r\n            # Not everything requires TLS 1.2, but we'll try anyway.\r\n            Write-Warning \"TLS 1.2 and or TLS 1.3 are not supported on this system. This download may fail!\"\r\n            if ($PSVersionTable.PSVersion.Major -lt 3) {\r\n                Write-Warning \"PowerShell 2 \/ .NET 2.0 doesn't support TLS 1.2.\"\r\n            }\r\n        }\r\n\r\n        $i = 1\r\n        While ($i -le $Attempts) {\r\n            # Some cloud services have rate-limiting\r\n            if (-not ($SkipSleep)) {\r\n                $SleepTime = Get-Random -Minimum 3 -Maximum 15\r\n                Write-Host \"Waiting for $SleepTime seconds.\"\r\n                Start-Sleep -Seconds $SleepTime\r\n            }\r\n        \r\n            if ($i -ne 1) { Write-Host \"\" }\r\n            Write-Host \"Download Attempt $i\"\r\n\r\n            try {\r\n                # Invoke-WebRequest is preferred because it supports links that redirect, e.g., https:\/\/t.ly\r\n                if ($PSVersionTable.PSVersion.Major -lt 4) {\r\n                    # Downloads the file\r\n                    $WebClient = New-Object System.Net.WebClient\r\n                    $WebClient.DownloadFile($URL, $Path)\r\n                }\r\n                else {\r\n                    # Standard options\r\n                    $WebRequestArgs = @{\r\n                        Uri                = $URL\r\n                        OutFile            = $Path\r\n                        MaximumRedirection = 10\r\n                        UseBasicParsing    = $true\r\n                    }\r\n\r\n                    # Downloads the file\r\n                    Invoke-WebRequest @WebRequestArgs\r\n                }\r\n\r\n                $File = Test-Path -Path $Path -ErrorAction SilentlyContinue\r\n            }\r\n            catch {\r\n                Write-Warning \"An error has occurred while downloading!\"\r\n                Write-Warning $_.Exception.Message\r\n\r\n                if (Test-Path -Path $Path -ErrorAction SilentlyContinue) {\r\n                    Remove-Item $Path -Force -Confirm:$false -ErrorAction SilentlyContinue\r\n                }\r\n\r\n                $File = $False\r\n            }\r\n\r\n            if ($File) {\r\n                $i = $Attempts\r\n            }\r\n            else {\r\n                Write-Warning \"File failed to download.\"\r\n                Write-Host \"\"\r\n            }\r\n\r\n            $i++\r\n        }\r\n\r\n        if (-not (Test-Path $Path)) {\r\n            Write-Warning \"Failed to download file!\"\r\n        }\r\n        else {\r\n            return $Path\r\n        }\r\n    }\r\n\r\n    function Revoke-Certificate {\r\n        param (\r\n            $Object,\r\n            $Loop = 0\r\n        )\r\n        $CrlPath = \"$TEMP\\CertRevokeListScript-$(Get-Date -Format FileDate).crl\"\r\n        Write-Host \"[Info] Revoking certificates with CRL file from Path, URL, or custom field: $Object\"\r\n        if ($Object -like \"http*\") {\r\n            Write-Host \"[Info] Downloading CRL file\"\r\n            try {\r\n                # Download the CRL file\r\n                Invoke-Download -URL $Object -Path $CrlPath -SkipSleep -ErrorAction Stop\r\n                Write-Host \"[Info] Downloaded CRL file to $CrlPath\"\r\n                # Revoke the certificates\r\n                certutil.exe -addstore CA $CrlPath\r\n                Write-Host \"[Info] Added CRL to the list of revoked certificates\"\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] Failed to download CRL file\"\r\n                exit 1\r\n            }\r\n            # Remove the temporary CRL file\r\n            try {\r\n                Remove-Item -Path $CrlPath -Force -Confirm:$false -ErrorAction Stop\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] Failed to remove temporary CRL file\"\r\n                exit 1\r\n            }\r\n        }\r\n        elseif ($(Test-Path -Path $Object -ErrorAction SilentlyContinue)) {\r\n            # Revoke the certificates\r\n            Write-Host \"[Info] Adding CRL to the list of revoked certificates\"\r\n            try {\r\n                $Object | Set-Content -Path $CrlPath -Force -ErrorAction Stop\r\n                # Revoke the certificates\r\n                certutil.exe -addstore CA $CrlPath\r\n                Write-Host \"[Info] Added CRL to the list of revoked certificates\"\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] Failed to revoke certificates with CRL file\"\r\n                exit 1\r\n            }\r\n            # Remove the temporary CRL file\r\n            try {\r\n                Remove-Item -Path $CrlPath -Force -Confirm:$false -ErrorAction Stop\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] Failed to remove temporary CRL file\"\r\n                exit 1\r\n            }\r\n        }\r\n        else {\r\n            $ValueFromCf = Get-NinjaProperty -Name $Object\r\n            if (\r\n                # Check if Loop is 0 and the value from the custom field is a path or URL\r\n                $Loop -eq 0 -and (\r\n                    $(Test-Path -Path $ValueFromCf -ErrorAction SilentlyContinue) -or\r\n                    $ValueFromCf -like \"http*\"\r\n                )\r\n            ) {\r\n                # Call Revoke-Certificate if the Custom Field value is a path or URL\r\n                # We'll only call Revoke-Certificate once to prevent an infinite loop via $Loop variable\r\n                Revoke-Certificate -Object $ValueFromCf -Loop $($Loop + 1)\r\n                return\r\n            }\r\n            $ValueFromCf | Set-Content -Path $CrlPath -Force -ErrorAction Stop\r\n            \r\n            # Revoke the certificates\r\n            certutil.exe -addstore CA $CrlPath\r\n            if ($LASTEXITCODE -ne 0) {\r\n                Write-Host \"[Error] Failed to revoke certificates with CRL file\"\r\n                exit 1\r\n            }\r\n            Write-Host \"[Info] Added CRL to the list of revoked certificates\"\r\n            # Remove the temporary CRL file\r\n            try {\r\n                Remove-Item -Path $CrlPath -Force -Confirm:$false -ErrorAction Stop\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] Failed to remove temporary CRL file\"\r\n                exit 1\r\n            }\r\n        }\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    if ($PSSenderInfo) {\r\n        Write-Host \"[Error] This script cannot be run in a PSSession. Please run it locally or via Ninja RMM.\"\r\n        exit 1\r\n    }\r\n\r\n    $CertificatesFound = $false\r\n    $RemoveError = $false\r\n\r\n    # Get a list of thumbprints from the environment variable\r\n    if ($env:Thumbprints -and $env:Thumbprints -ne \"null\") {\r\n        $Thumbprint = $env:Thumbprints -split ',' | ForEach-Object { \"$_\".Trim() }\r\n    }\r\n    elseif ($Thumbprint) {\r\n        # Remove any commas from the thumbprint and trim any whitespace\r\n        $Thumbprint = $Thumbprint | ForEach-Object { \"$($_ -split ',')\".Trim() }\r\n    }\r\n    if ($env:getCrlFromCustomField -and $env:getCrlFromCustomField -ne \"null\") {\r\n        $GetCrlFromCustomField = $env:getCrlFromCustomField\r\n    }\r\n\r\n    # Get crl file path from the environment variable\r\n    if ($env:certificateRevokeListPath -and $env:certificateRevokeListPath -ne \"null\") {\r\n        $CertRevokeList = $env:certificateRevokeListPath\r\n    }\r\n\r\n    # Check that Thumbprint or CertRevokeList where specified\r\n    if ($Thumbprint) {}\r\n    elseif ($CertRevokeList) {}\r\n    elseif ($GetCrlFromCustomField) {}\r\n    else {\r\n        Write-Host \"[Error] Thumbprint or CertRevokeList or GetCrlFromCustomField where not specified. Please specify at least one of them.\"\r\n        exit 2\r\n    }\r\n\r\n    # Check if the RemoveMatchingCertificates switch\/checkbox was selected\r\n    if ($env:removeMatchingCertificates -eq \"true\") {\r\n        $RemoveMatchingCertificates = $true\r\n    }\r\n\r\n    # Get the custom field name from the Script Variable\r\n    if ($env:customField) {\r\n        $CustomField = $env:customField\r\n    }\r\n\r\n    if ($Thumbprint) {\r\n        $Thumbprint = $Thumbprint | ForEach-Object {\r\n            if ($_.Length -eq 40 -and $_ -match \"^[0-9a-fA-F]{40}$\") {\r\n                Write-Host \"[Info] Thumbprint($_) is valid and will be processed.\"\r\n                $_\r\n            }\r\n            else {\r\n                Write-Host \"[Warn] Thumbprint($_) is not valid and will be skipped.\"\r\n            }\r\n        }\r\n    \r\n        # Loop through all certificates installed on the system\r\n        $FoundCertificates = Get-ChildItem -Path Cert:\\LocalMachine\\ -Recurse | Where-Object { $_.Thumbprint -and $_.Thumbprint -in $Thumbprint }\r\n    \r\n        # Output the found certificates\r\n        $OutputThumbprints = if ($FoundCertificates) {\r\n            $CertificatesFound = $true\r\n            Write-Host \"[Alert] Found certificates:\"\r\n            $FoundCertificates = $FoundCertificates | ForEach-Object {\r\n                [PSCustomObject]@{\r\n                    Thumbprint = $_.Thumbprint\r\n                    PSPath     = $_.PSPath\r\n                    ExpiryDate = if ($_.NotAfter) { $_.NotAfter.ToShortDateString() }else { \"No Expiry Date\" }\r\n                }\r\n            }\r\n            if ($FoundCertificates) {\r\n                $thumbprint = \"Thumbprint\"\r\n                $path = \"Path\"\r\n                $padding = 40\r\n\r\n                $centeredThumbprint = $thumbprint.PadLeft(($thumbprint.Length + $padding) \/ 2).PadRight($padding)\r\n                $centeredPath = $path\r\n\r\n                Write-Host \"$centeredThumbprint - $centeredPath - Expires\"\r\n            }\r\n            $FoundCertificates | ForEach-Object {\r\n                $CertPath = $_\r\n                $CertificatePath = $CertPath.PSPath\r\n                # Convert PSPath to how certmgr.mmc formats the path\r\n                $CertificatePath = $CertificatePath -replace 'LocalMachine\\\\', 'Local Computer\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\My\\\\', '\\Personal\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\CA\\\\', '\\Intermediate Certification Authorities\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\Root\\\\', '\\Trusted Root Certification Authorities\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\Disallowed\\\\', '\\Untrusted Certificates\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\AuthRoot\\\\', '\\Third-Party Root Certification Authorities\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\TrustedPublisher\\\\', '\\Trusted Publishers\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\ClientAuthIssuer\\\\', '\\Client Authentication Issuers\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\Remote Desktop\\\\', '\\Remote Desktop\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\SmartCardRoot\\\\', '\\Smart Card Trusted Roots\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\TrustedPeople\\\\', '\\Trusted People\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\Trust\\\\', '\\Enterprise Trust\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\REQUEST\\\\', '\\Certificate Enrollment Requests\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\AddressBook\\\\', '\\Other People\\'\r\n                $CertificatePath = $CertificatePath -replace '\\\\UserdDS\\\\', '\\Active Directory User Object\\'\r\n                # Output with the formatted path\r\n                \"$($CertPath.Thumbprint) - $($CertificatePath -replace 'Microsoft.PowerShell.Security\\\\Certificate::') - $($CertPath.ExpiryDate)\"\r\n            }\r\n        }\r\n        else {\r\n            Write-Host \"[Info] No certificates found\"\r\n        }\r\n        if ($OutputThumbprints) {\r\n            $OutputThumbprints | Out-String | Write-Host\r\n        }\r\n    \r\n        # Remove the certificates if we should\r\n        if ($RemoveMatchingCertificates) {\r\n            Write-Host \"[Info] Removing certificates\"\r\n            # Loop through all the found certificates\r\n            $FoundCertificates | ForEach-Object {\r\n                $Certificate = $_\r\n                # Remove the certificate\r\n                Write-Host \"[Info] Removing certificate with path: $($Certificate.PSPath -replace 'Microsoft.PowerShell.Security\\\\Certificate::')\"\r\n                try {\r\n                    # Remove the certificate and its private key\r\n                    # More Info: https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.security\/about\/about_certificate_provider?view=powershell-5.1#deleting-certificates-and-private-keys\r\n                    if ($IsLinux) {\r\n                        # Only used for testing purposes\r\n                        Remove-Item -Path $Certificate.PSPath -Force -Confirm:$false -ErrorAction Stop\r\n                    }\r\n                    else {\r\n                        Remove-Item -Path $Certificate.PSPath -DeleteKey -Force -Confirm:$false -ErrorAction Stop\r\n                    }\r\n                    Write-Host \"[Info] Removed certificate with path: $($Certificate.PSPath -replace 'Microsoft.PowerShell.Security\\\\Certificate::')\"\r\n                }\r\n                catch {\r\n                    # Only error if there is only one certificate\r\n                    # More than one certificate with the same thumbprint is likely already removed\r\n                    if ($($FoundCertificates | Where-Object { $_ -like $Certificate.Thumbprint }).Count -eq 1) {\r\n                        Write-Host \"[Error] Failed to Remove certificate with thumbprint: $($Certificate.Thumbprint)\"\r\n                        $RemoveError = $true\r\n                    }\r\n                    else {\r\n                        Write-Host \"[Info] Removed certificate with path: $($Certificate.PSPath -replace 'Microsoft.PowerShell.Security\\\\Certificate::')\"\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        else {\r\n            Write-Host \"[Info] Removing certificates is not enabled. Doing nothing.\"\r\n        }\r\n        if ($CustomField) {\r\n            # Save the found thumbprints to a NinjaRMM custom field\r\n            Write-Host \"[Info] Saving thumbprints to custom field: $CustomField\"\r\n            try {\r\n                if ($RemoveMatchingCertificates) {\r\n                    Set-NinjaProperty -Name $CustomField -Value $($OutputThumbprints | ForEach-Object {\r\n                            # Output just the path\r\n                            \"$(\"$_\" -split ' - ' | Select-Object -Skip 1 -First 1) - Removed from system\"\r\n                        } | Out-String) -Type \"MultiLine\"\r\n                }\r\n                else {\r\n                    Set-NinjaProperty -Name $CustomField -Value $($OutputThumbprints | ForEach-Object {\r\n                            # Output just the path\r\n                            \"$(\"$_\" -split ' - ' | Select-Object -Skip 1 -First 1)\"\r\n                        } | Out-String) -Type \"MultiLine\"\r\n                }\r\n            }\r\n            catch {\r\n                # If we ran into some sort of error we'll output it here.\r\n                Write-Error -Message $_.ToString() -Category InvalidOperation -Exception (New-Object System.Exception)\r\n                exit 1\r\n            }\r\n        }\r\n    \r\n        # Exit with an error when we failed to remove a certificate\r\n        if ($RemoveError) {\r\n            Write-Host \"[Error] Failed to Remove one or more certificates\"\r\n            exit 1\r\n        }\r\n    \r\n        # Exit with an error when we found certificates and we shouldn't remove them\r\n        if ($CertificatesFound -and -not $RemoveMatchingCertificates) {\r\n            Write-Host \"[Alert] Certificates found\"\r\n            exit 1\r\n        }\r\n    }\r\n\r\n    if ($CertRevokeList) {\r\n        Revoke-Certificate -Object $CertRevokeList\r\n    }\r\n    if ($GetCrlFromCustomField) {\r\n        Revoke-Certificate -Object $GetCrlFromCustomField\r\n    }\r\n\r\n    # Exit with a success when no certificates were found\r\n    exit 0\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"blog-cta-new blog-cta-style-1\"><div class=\"cta-left\"><h2><\/h2><p><\/p><\/div><div class=\"cta-right\"><a class=\"button\" href=\"\"><\/a><\/div><\/div>\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>Le script est un outil puissant qui permet de trouver et \u00e9ventuellement de supprimer des certificats sur la base d&#8217;empreintes sp\u00e9cifi\u00e9es. Voici une explication \u00e9tape par \u00e9tape de son fonctionnement :<\/p>\n<h3>1. Initialisation et gestion des param\u00e8tres<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"2\">Le script commence par d\u00e9finir les param\u00e8tres n\u00e9cessaires, tels que Thumbprint, RemoveMatchingCertificates, CertRevokeList, GetCrlFromCustomField et CustomField.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"2\">Il comprend des fonctions utilitaires telles que Test-IsElevated pour v\u00e9rifier les privil\u00e8ges administratifs et Set-NinjaProperty pour d\u00e9finir des champs personnalis\u00e9s dans NinjaOne.<\/li>\n<\/ul>\n<h3>2. V\u00e9rification des privil\u00e8ges administratifs<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"2\">La fonction Test-IsElevated v\u00e9rifie si le script est ex\u00e9cut\u00e9 avec des droits d&rsquo;administration, ce qui est essentiel pour acc\u00e9der aux certificats du syst\u00e8me et les modifier.<\/li>\n<\/ul>\n<h3>3. Traitement des empreintes de pouce<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"2\">Le script traite les empreintes fournies, en s&rsquo;assurant qu&rsquo;elles sont valides et correctement format\u00e9es.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"2\">Il r\u00e9cup\u00e8re les certificats dans le magasin de certificats de la machine locale et les filtre en fonction des empreintes sp\u00e9cifi\u00e9es.<\/li>\n<\/ul>\n<h3>4. Gestion des certificats<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"2\">Si le commutateur RemoveMatchingCertificates est activ\u00e9, le script tente de supprimer les certificats trouv\u00e9s. Il traite les erreurs avec \u00e9l\u00e9gance, en veillant \u00e0 ce que tous les probl\u00e8mes soient enregistr\u00e9s et g\u00e9r\u00e9s de mani\u00e8re appropri\u00e9e.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"2\">Le script peut \u00e9galement enregistrer les r\u00e9sultats dans un champ personnalis\u00e9 de NinjaOne, ce qui facilite la gestion et l&rsquo;\u00e9tablissement de rapports.<\/li>\n<\/ul>\n<h3>5. Traitement des CRL<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"2\">Le script peut g\u00e9rer des listes de r\u00e9vocation de certificats (CRL) \u00e0 partir d&rsquo;URL, de chemins locaux ou de champs personnalis\u00e9s. Il t\u00e9l\u00e9charge et traite ces listes pour r\u00e9voquer les certificats si n\u00e9cessaire.<\/li>\n<\/ul>\n<h3>6. Sortie et enregistrement<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"2\">Des r\u00e9sultats d\u00e9taill\u00e9s sont fournis \u00e0 chaque \u00e9tape, ce qui garantit la transparence et facilite le d\u00e9pannage. Le script enregistre les certificats trouv\u00e9s, les actions de suppression et les \u00e9ventuelles erreurs rencontr\u00e9es.<\/li>\n<\/ul>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<p>Imaginez un professionnel de l&rsquo;informatique qui g\u00e8re le r\u00e9seau d&rsquo;une grande entreprise. Les certificats sont utilis\u00e9s pour s\u00e9curiser les communications internes et divers services. Le professionnel constate que certains certificats approchent de l&rsquo;expiration ou ont \u00e9t\u00e9 compromis. \u00c0 l&rsquo;aide de ce script, ils peuvent rapidement trouver ces certificats gr\u00e2ce \u00e0 leur empreinte et les supprimer, garantissant ainsi la s\u00e9curit\u00e9 du r\u00e9seau.<\/p>\n<h2>Comparaisons<\/h2>\n<p>Par rapport aux m\u00e9thodes manuelles de gestion des certificats, ce script offre des avantages significatifs :<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Efficacit\u00e9<\/strong>: Automatise le processus de recherche et de suppression des certificats, ce qui permet de gagner du temps et de r\u00e9duire le risque d&rsquo;erreur humaine.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Pr\u00e9cision<\/strong>: Garantit que seuls les certificats avec les empreintes sp\u00e9cifi\u00e9es sont affect\u00e9s, \u00e9vitant ainsi des modifications involontaires sur d&rsquo;autres certificats.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Int\u00e9gration<\/strong>: Peut s&rsquo;int\u00e9grer \u00e0 NinjaOne, ce qui permet une gestion et des rapports transparents dans un cadre de gestion informatique plus large.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<p><strong>Q\u00a0: Qu&rsquo;est-ce qu&rsquo;une empreinte de pouce et pourquoi est-elle importante ?<\/strong><br \/>\nR\u00a0: Une empreinte est un identifiant unique pour un certificat, utilis\u00e9 pour s&rsquo;assurer que le bon certificat est g\u00e9r\u00e9.<\/p>\n<p><strong>Q\u00a0: Ce script peut-il \u00eatre ex\u00e9cut\u00e9 sur n&rsquo;importe quelle version de Windows ?<\/strong><br \/>\nR\u00a0: Le script n\u00e9cessite Windows 10 ou Windows Server 2016 et plus.<\/p>\n<p><strong>Q\u00a0: Que se passe-t-il si le script n&rsquo;est pas ex\u00e9cut\u00e9 avec des privil\u00e8ges administratifs ?<\/strong><br \/>\nR\u00a0: Le script ne parviendra pas \u00e0 ex\u00e9cuter les actions n\u00e9cessitant des droits d&rsquo;administration, telles que la suppression de certificats.<\/p>\n<p><strong>Q\u00a0: Ce script peut-il g\u00e9rer des certificats provenant de champs personnalis\u00e9s dans NinjaOne ?<\/strong><br \/>\nR\u00a0: Oui, il est possible de r\u00e9cup\u00e9rer et de traiter des certificats en utilisant des champs personnalis\u00e9s dans NinjaOne.<\/p>\n<h2>Implications<\/h2>\n<p>Gr\u00e2ce \u00e0 ce script, les professionnels de l&rsquo;informatique peuvent s&rsquo;assurer que les certificats sont correctement g\u00e9r\u00e9s, r\u00e9duisant ainsi le risque de failles de s\u00e9curit\u00e9 dues \u00e0 des certificats expir\u00e9s ou compromis. Cette approche proactive de la gestion des certificats am\u00e9liore la position globale de l&rsquo;organisation en mati\u00e8re de s\u00e9curit\u00e9.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Audits r\u00e9guliers<\/strong>: Ex\u00e9cutez r\u00e9guli\u00e8rement le script pour auditer et g\u00e9rer les certificats, en veillant \u00e0 ce qu&rsquo;aucun certificat expir\u00e9 ou non valide ne subsiste dans le syst\u00e8me.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Sauvegarde<\/strong>: Sauvegardez toujours le magasin de certificats avant d&rsquo;apporter des modifications, afin de pouvoir le restaurer en cas d&rsquo;erreur.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Int\u00e9gration<\/strong>: Utilisez l&rsquo;int\u00e9gration du script avec NinjaOne pour une gestion et des rapports complets.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Ce script PowerShell est un outil pr\u00e9cieux pour les professionnels de l&rsquo;informatique et les MSP, car il rationalise le processus de recherche et de gestion des certificats syst\u00e8me par empreinte. En s&rsquo;int\u00e9grant \u00e0 NinjaOne, il offre une solution puissante pour maintenir la s\u00e9curit\u00e9 et la conformit\u00e9 dans un environnement d&rsquo;entreprise. La plateforme de <a href=\"https:\/\/www.ninjaone.com\/fr\/\" target=\"_blank\" rel=\"noopener\">NinjaOne<\/a>, combin\u00e9e \u00e0 ce script, fournit une approche compl\u00e8te de la gestion informatique, garantissant que les certificats sont trait\u00e9s de mani\u00e8re <a href=\"https:\/\/www.ninjaone.com\/fr\/efficacite\/\" target=\"_blank\" rel=\"noopener\">efficace<\/a> et s\u00e9curis\u00e9e.<\/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":"","_lmt_disable":""},"operating_system":[4212],"use_cases":[4283],"class_list":["post-353647","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows","use_cases-verrouillage-et-authentification"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/353647","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=353647"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=353647"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=353647"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=353647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}