{"id":235717,"date":"2024-04-12T11:17:44","date_gmt":"2024-04-12T11:17:44","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=235717"},"modified":"2024-04-12T11:17:44","modified_gmt":"2024-04-12T11:17:44","slug":"comment-verifier-l-activation-de-windows-et-la-licence-avec-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/comment-verifier-l-activation-de-windows-et-la-licence-avec-powershell\/","title":{"rendered":"Comment v\u00e9rifier l&rsquo;activation de Windows et la licence efficacement avec PowerShell"},"content":{"rendered":"<h2>Points \u00e0 retenir<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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=\"1\" data-aria-level=\"1\"><strong>Contr\u00f4le de conformit\u00e9 automatis\u00e9<\/strong>: Le script automatise le processus de v\u00e9rification de l&rsquo;activation de Windows et de l&rsquo;\u00e9tat des licences, garantissant ainsi la conformit\u00e9 de plusieurs syst\u00e8mes.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Identification et r\u00e9solution des erreurs<\/strong>: Il identifie les erreurs d&rsquo;activation sp\u00e9cifiques de Windows et fournit des \u00e9tapes de d\u00e9pannage, ce qui permet une r\u00e9solution rapide.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Efficacit\u00e9 pour la gestion informatique<\/strong>: Il automatise un processus traditionnellement manuel, ce qui permet aux professionnels de l&rsquo;informatique et aux MSP de gagner du temps et d&rsquo;\u00e9conomiser des ressources.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Respect des normes juridiques et de s\u00e9curit\u00e9<\/strong>: Il aide \u00e0 respecter les exigences l\u00e9gales en mati\u00e8re de licences et veille \u00e0 ce que les syst\u00e8mes re\u00e7oivent les mises \u00e0 jour n\u00e9cessaires \u00e0 la s\u00e9curit\u00e9.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Polyvalent pour les syst\u00e8mes Windows modernes<\/strong>: Con\u00e7u pour Windows 10 et Windows Server 2016, il est adapt\u00e9 aux environnements informatiques contemporains.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Int\u00e9gration avec les outils de gestion informatique<\/strong>: Peut \u00eatre int\u00e9gr\u00e9 dans des solutions de gestion informatique plus larges telles que NinjaOne pour une surveillance et une gestion am\u00e9lior\u00e9es.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Sortie claire<\/strong>: Le script fournit des r\u00e9sultats faciles \u00e0 comprendre, ce qui le rend accessible aux professionnels de l&rsquo;informatique, quel que soit leur niveau d&rsquo;expertise.<\/li>\n<\/ul>\n<h2>Introduction<\/h2>\n<p>L&rsquo;activation de Windows et l&rsquo;octroi de licences sont des \u00e9l\u00e9ments essentiels au maintien de la l\u00e9galit\u00e9 et de la fonctionnalit\u00e9 des syst\u00e8mes Windows dans l&rsquo;environnement informatique. S&rsquo;assurer que Windows est correctement activ\u00e9 et que la licence est valide n&rsquo;est pas seulement une obligation l\u00e9gale, c&rsquo;est aussi une condition pr\u00e9alable pour recevoir des mises \u00e0 jour et une assistance importantes. Dans ce contexte, les scripts PowerShell apparaissent comme des outils puissants pour les professionnels de l&rsquo;informatique et les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\">fournisseurs de services g\u00e9r\u00e9s (MSP)<\/a> afin d&rsquo;automatiser et de rationaliser le processus de v\u00e9rification de l&rsquo;activation de Windows et de l&rsquo;\u00e9tat des licences.<\/p>\n<h2>Contexte<\/h2>\n<p>Le script PowerShell fourni est con\u00e7u pour d\u00e9tecter l&rsquo;\u00e9tat d&rsquo;activation et de licence des syst\u00e8mes d&rsquo;exploitation Windows. Il est particuli\u00e8rement utile dans les environnements o\u00f9 plusieurs machines doivent \u00eatre g\u00e9r\u00e9es, en veillant \u00e0 ce qu&rsquo;elles soient toutes conformes aux exigences de Microsoft en mati\u00e8re de licences. Ce script est une aubaine pour les professionnels de l&rsquo;informatique et les MSP, car il leur permet d&rsquo;identifier rapidement les installations Windows sans licence ou non activ\u00e9es, \u00e9vitant ainsi d&rsquo;\u00e9ventuels probl\u00e8mes juridiques et garantissant l&rsquo;int\u00e9grit\u00e9 du syst\u00e8me.<\/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    Condition script for detecting activation and license status of Windows.\r\n.DESCRIPTION\r\n    Condition script for detecting activation and license status of Windows.\r\n    Exit codes:\r\n    0 = Activated and Licensed\r\n    2 = Unlicensed, but under a grace period\r\n    3 = Not Activated and Unlicensed\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: Renamed script\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam ()\r\n\r\nbegin {\r\n    # https:\/\/learn.microsoft.com\/en-us\/previous-versions\/windows\/it-pro\/windows-server-2012-r2-and-2012\/dn502528(v=ws.11)\r\n    $NotificationReasons = {\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004C001\"\r\n            ErrorMessage         = \"The activation server determined the specified product key is invalid\"\r\n            ActivationType       = \"MAK\"\r\n            PossibleCause        = \"An invalid MAK was entered.\"\r\n            TroubleshootingSteps = \"Verify that the key is the MAK provided by Microsoft. Contact the Microsoft Activation Call Center to verify that the MAK is valid.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004C003\"\r\n            ErrorMessage         = \"The activation server determined the specified product key has been blocked\"\r\n            ActivationType       = \"MAK\"\r\n            PossibleCause        = \"The MAK is blocked on the activation server.\"\r\n            TroubleshootingSteps = \"Contact the Microsoft Activation Call Center to obtain a new MAK and install\/activate the system.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004C008\"\r\n            ErrorMessage         = \"The activation server reported that the product key has exceeded its unlock limit.\"\r\n            ActivationType       = \"KMS\"\r\n            PossibleCause        = \"The KMS key has exceeded the activation limit.\"\r\n            TroubleshootingSteps = \"KMS host keys will activate up to 10 times on six different computers. If more activations are necessary, contact the Microsoft Activation Call Center.\"       \r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004C020\"\r\n            ErrorMessage         = \"The activation server reported that the Multiple Activation Key has exceeded its limit.\"\r\n            ActivationType       = \"MAK\"\r\n            PossibleCause        = \"The MAK has exceeded the activation limit.\"\r\n            TroubleshootingSteps = \"MAKs by design have a limited number of activations. Contact the Microsoft Activation Call Center.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004C021\"\r\n            ErrorMessage         = \"The activation server reported that the Multiple Activation Key extension limit has been exceeded.\"\r\n            ActivationType       = \"MAK\"\r\n            PossibleCause        = \"The MAK has exceeded the activation limit.\"\r\n            TroubleshootingSteps = \"MAKs by design have a limited number of activations. Contact the Microsoft Activation Call Center.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F009\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the grace period expired.\"\r\n            ActivationType       = \"MAK\"\r\n            PossibleCause        = \"The grace period expired before the system was activated. Now, the system is in the Notifications state.\"\r\n            TroubleshootingSteps = \"See the section User Experience.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F00F\"\r\n            ErrorMessage         = \"The Software Licensing Server reported that the hardware ID binding is beyond level the of tolerance.\"\r\n            ActivationType       = \"MAK\/KMS client\/KMS host\"\r\n            PossibleCause        = \"The hardware has changed or the drivers were updated on the system.\"\r\n            TroubleshootingSteps = \"MAK: Reactivate the system during the OOT grace period using either online or phone activation. KMS: Restart, or run slmgr.vbs \/ato.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F014\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the product key is not available\"\r\n            ActivationType       = \"MAK\/KMS client\"\r\n            PossibleCause        = \"No product keys are installed on the system.\"\r\n            TroubleshootingSteps = \"Install a MAK product key, or install a KMS Setup key found in \\\\sources\\\\Product.ini on the installation media.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F02C\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the format for the offline activation data is incorrect.\"\r\n            ActivationType       = \"MAK\/KMS client\"\r\n            PossibleCause        = \"The system has detected that the data entered during phone activation is not valid.\"\r\n            TroubleshootingSteps = \"Verify that the CID is correctly entered.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F038\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the computer could not be activated. The count reported by your Key Management Service (KMS) is insufficient. Please contact your system administrator.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"The count on the KMS host is not high enough. The KMS count must be \u00e2\u2030\u00a55 for Windows Server or \u00e2\u2030\u00a525 for Windows client.\"\r\n            TroubleshootingSteps = \"More computers are needed in the KMS pool for KMS clients to activate. Run Slmgr.vbs \/dli to get the current count on the KMS host.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F039\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the computer could not be activated. The Key Management Service (KMS) is not enabled.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"This error occurs when a KMS request is not answered.\"\r\n            TroubleshootingSteps = \"Troubleshoot the network connection between the KMS host and the client. Make sure that TCP port 1688 (default) is not blocked by a firewall or otherwise filtered.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F041\"\r\n            ErrorMessage         = \"The Software Licensing Service determined that the Key Management Service (KMS) is not activated. KMS needs to be activated. Please contact system administrator.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"The KMS host is not activated.\"\r\n            TroubleshootingSteps = \"Activate the KMS host with either online or phone activation.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F042\"\r\n            ErrorMessage         = \"The Software Protection Service determined that the specified Key Management Service (KMS) cannot be used.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"Mismatch between the KMS client and the KMS host.\"\r\n            TroubleshootingSteps = \"This error occurs when a KMS client contacts a KMS host that cannot activate the client software. This can be common in mixed environments that contain application and operating system-specific KMS hosts, for example.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F050\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the product key is invalid.\"\r\n            ActivationType       = \"KMS, KMS client, MAK\"\r\n            PossibleCause        = \"This can be caused by a typo in the KMS key or by typing in a Beta key on a Released version of the operating system.\"\r\n            TroubleshootingSteps = \"Install the appropriate KMS key on the corresponding version of Windows. Check the spelling. If the key is being copied and pasted, make sure that em dashes have not been substituted for the dashes in the key.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F051\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the product key is blocked.\"\r\n            ActivationType       = \"MAK\/KMS\"\r\n            PossibleCause        = \"The product key on the activation server is blocked by Microsoft.\"\r\n            TroubleshootingSteps = \"Obtain a new MAK\/KMS key, install it on the system, and activate.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F074\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the computer could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.\"\r\n            ActivationType       = \"KMS Client\"\r\n            PossibleCause        = \"All KMS host systems  returned an error.\"\r\n            TroubleshootingSteps = \"Troubleshoot errors from each event ID 12288 associated with the activation attempt.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0xC004F06C\"\r\n            ErrorMessage         = \"The Software Protection Service reported that the computer could not be activated. The Key Management Service (KMS) determined that the request timestamp is invalid.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"The system time on the client computer is too different from the time on the KMS host.\"\r\n            TroubleshootingSteps = \"Time sync is important to system and network security for a variety of reasons. Fix this issue by changing the system time on the client to sync with the KMS. Use of a Network Time Protocol (NTP) time source or Active Directory Domain Services for time synchronization is recommended. This issue uses UTP time and is independent of Time Zone selection.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0x80070005\"\r\n            ErrorMessage         = \"Access denied. The requested action requires elevated privileges.\"\r\n            ActivationType       = \"KMS client\/MAK\/KMS host\"\r\n            PossibleCause        = \"User Account Control (UAC) prohibits activation processes from running in a non-elevated command prompt.\"\r\n            TroubleshootingSteps = \"Run slmgr.vbs from an elevated command prompt. Right-click cmd.exe, and then click Run as Administrator.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0x8007232A\"\r\n            ErrorMessage         = \"DNS server failure.\"\r\n            ActivationType       = \"KMS host\"\r\n            PossibleCause        = \"The system has network or DNS issues.\"\r\n            TroubleshootingSteps = \"Troubleshoot network and DNS.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0x8007232B\"\r\n            ErrorMessage         = \"DNS name does not exist.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"The KMS client cannot find KMS SRV RRs in DNS. If a KMS host does not exist on the network, a MAK should be installed.\"\r\n            TroubleshootingSteps = \"Confirm that a KMS host has been installed and DNS publishing is enabled (default). If DNS is unavailable, point the KMS client to the KMS host by using slmgr.vbs \/skms \\u003ckms_host_name\\u003e. Optionally, obtain and install a MAK; then, activate the system. Finally, troubleshoot DNS.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0x800706BA\"\r\n            ErrorMessage         = \"The RPC server is unavailable.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"Firewall settings are not configured on the KMS host, or DNS SRV records are stale.\"\r\n            TroubleshootingSteps = \"Ensure the Key Management Service firewall exception is enabled on the KMS host computer. Ensure that SRV records point to a valid KMS host. Troubleshoot network connections.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            ErrorCode            = \"0x8007251D\"\r\n            ErrorMessage         = \"No records found for given DNS query.\"\r\n            ActivationType       = \"KMS client\"\r\n            PossibleCause        = \"The KMS client cannot find KMS SRV RRs in DNS.\"\r\n            TroubleshootingSteps = \"Troubleshoot network connections and DNS.\"\r\n        }\r\n    }.Invoke()\r\n}\r\nprocess {\r\n    Write-Host \"\"\r\n\r\n    $LicenseStatus = Get-CimInstance -ClassName \"SoftwareLicensingProduct\" -Filter \"Name like 'Windows%'\" -ErrorAction SilentlyContinue |\r\n        Where-Object { $_.PartialProductKey } |\r\n        Select-Object -ExpandProperty LicenseStatus\r\n\r\n    $ActivationNumber = switch ($LicenseStatus) {\r\n        0 { 3 }\r\n        1 { 0 }\r\n        2 { 2 }\r\n        3 { 2 }\r\n        4 { 3 }\r\n        5 { 3 }\r\n        6 { 2 }\r\n        default { 3 }\r\n    }\r\n\r\n    $Result = cscript.exe C:\\Windows\\system32\\slmgr.vbs -dli\r\n    $Result | Select-Object -Skip 4 | Out-String | Write-Host\r\n    $Notification = $Result -split [System.Environment]::NewLine | Where-Object { $_ -match \"^Notification Reason: .*\" }\r\n    Write-Host \"\"\r\n    if ($Notification) {\r\n        $NotificationCode = $($($Notification -split ': ')[1] -split '\\.')[0]\r\n        Write-Host \"[Error] KMS Activation Error Found.\"\r\n        if ($NotificationCode -like \"0xC004F200\") { Write-Host \"Non-Genuine\" }\r\n        elseif ($NotificationCode -like \"0xC004F009\") { Write-Host \"Grace Time Expired\" }\r\n        else {\r\n            $NotificationReasons | Where-Object { $_.ErrorCode -like \"$NotificationCode\" } | Out-String | Write-Host\r\n        }\r\n    }\r\n    if ($Result -like \"*Eval*\") {\r\n        Write-Host \"Evaluation Licensed\"\r\n        exit 5 # Is Activated but is an Evaluation license\r\n    }\r\n    exit $ActivationNumber\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>Acc\u00e9dez \u00e0 plus de 700 scripts dans le Dojo NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/fr\/phase-de-test-gratuit\/\">Obtenir l&rsquo;acc\u00e8s<\/a><\/p>\n<\/div>\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>Le script commence par d\u00e9finir une s\u00e9rie de codes d&rsquo;erreur et de messages potentiels li\u00e9s \u00e0 l&rsquo;activation de Windows. Elles sont encapsul\u00e9es dans un objet personnalis\u00e9 PowerShell, qui fournit des informations d\u00e9taill\u00e9es sur la nature de l&rsquo;erreur, le type d&rsquo;activation (par exemple, MAK, KMS) et les \u00e9tapes de d\u00e9pannage.<\/p>\n<p>Dans le bloc &lsquo;process&rsquo;, le script ex\u00e9cute une s\u00e9rie de commandes :<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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=\"1\" data-aria-level=\"1\">Il r\u00e9cup\u00e8re l&rsquo;\u00e9tat de la licence des produits Windows \u00e0 l&rsquo;aide de la cmdlet <strong>Get-CimInstance<\/strong>.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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=\"1\" data-aria-level=\"1\">L&rsquo;\u00e9tat de la licence est ensuite \u00e9valu\u00e9 au moyen d&rsquo;une instruction de commutation, traduite en un code de sortie qui repr\u00e9sente les diff\u00e9rents \u00e9tats d&rsquo;activation et de licence.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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\">Il ex\u00e9cute <strong>slmgr.vbs -dli<\/strong>, un script qui fournit des informations d\u00e9taill\u00e9es sur l&rsquo;activation de Windows et l&rsquo;\u00e9tat des licences.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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\">Le script analyse la sortie de <strong>slmgr.vbs<\/strong> pour identifier les erreurs d&rsquo;activation sp\u00e9cifiques et fournit les informations de d\u00e9pannage correspondantes \u00e0 partir des objets personnalis\u00e9s d\u00e9finis pr\u00e9c\u00e9demment.<\/li>\n<\/ul>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<p>Imaginez une entreprise MSP qui g\u00e8re l&rsquo;infrastructure informatique d&rsquo;une entreprise de taille moyenne. Elle peut programmer ce script pour qu&rsquo;il s&rsquo;ex\u00e9cute p\u00e9riodiquement sur toutes les machines Windows. Si une machine est trouv\u00e9e avec une installation Windows non activ\u00e9e ou sans licence, le script peut alerter l&rsquo;entreprise MSP, ce qui lui permet de prendre rapidement des mesures correctives.<\/p>\n<h2>Comparaisons<\/h2>\n<p>Les m\u00e9thodes traditionnelles de v\u00e9rification de l&rsquo;activation de Windows impliquent des v\u00e9rifications manuelles sur chaque syst\u00e8me ou l&rsquo;utilisation d&rsquo;outils disparates, ce qui peut prendre du temps et manquer de consistance. Ce script offre une approche centralis\u00e9e et automatis\u00e9e, garantissant la consistance et permettant de gagner du temps.<\/p>\n<h2>FAQ<\/h2>\n<ul>\n<li><strong>Comment ex\u00e9cuter ce script ?<\/strong>\n<ul>\n<li>Ex\u00e9cutez le script dans PowerShell en tant qu&rsquo;administrateur.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Ce script va-t-il activer Windows pour moi ?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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\">Non, il v\u00e9rifie uniquement l&rsquo;\u00e9tat d&rsquo;activation et propose des mesures de d\u00e9pannage.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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>Ce script peut-il fonctionner sur toutes les versions de Windows ?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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\">Il est con\u00e7u pour Windows 10 et Windows Server 2016 et les versions plus r\u00e9centes.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Implications<\/h2>\n<p>Les syst\u00e8mes Windows dont la licence est incorrecte ou qui ne sont pas activ\u00e9s peuvent pr\u00e9senter des risques importants pour la s\u00e9curit\u00e9, car ils risquent de ne pas recevoir les mises \u00e0 jour essentielles. Ce script permet de maintenir les normes de conformit\u00e9 et de s\u00e9curit\u00e9 au sein d&rsquo;une infrastructure informatique.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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\">Planifiez r\u00e9guli\u00e8rement l&rsquo;ex\u00e9cution du script sur toutes les machines Windows de votre r\u00e9seau.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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=\"1\" data-aria-level=\"1\">Examinez et agissez rapidement sur les r\u00e9sultats du script afin de maintenir la conformit\u00e9.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" 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\">Assurez-vous que les strat\u00e9gies d&rsquo;ex\u00e9cution de PowerShell autorisent l&rsquo;ex\u00e9cution des scripts.<\/li>\n<\/ul>\n<h2>Conclusion :<\/h2>\n<p>Dans le domaine de la gestion informatique, des outils comme NinjaOne peuvent compl\u00e9ter ce script PowerShell en fournissant une plateforme compl\u00e8te pour la <a href=\"https:\/\/www.ninjaone.com\/fr\/rmm\/automatisation-informatique\">surveillance, la gestion et l&rsquo;automatisation des t\u00e2ches informatiques<\/a>. L&rsquo;int\u00e9gration de ces scripts dans une solution de gestion informatique plus large comme NinjaOne peut <a href=\"https:\/\/www.ninjaone.com\/fr\/efficacite\">am\u00e9liorer l&rsquo;efficacit\u00e9<\/a>, garantir la conformit\u00e9 et maintenir l&rsquo;int\u00e9grit\u00e9 du syst\u00e8me dans l&rsquo;ensemble de l&rsquo;infrastructure informatique d&rsquo;une entreprise.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[4287],"class_list":["post-235717","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\/235717","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=235717"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=235717"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=235717"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=235717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}