> For the complete documentation index, see [llms.txt](https://docs.scepman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scepman.com/fr/gestion-des-certificats/api-certificates/api-enrollment/windows-server.md).

# Serveur Windows

{% hint style="info" %}
Applicable à la version 2.9 de SCEPman et ultérieures
{% endhint %}

Vous pouvez utiliser le module PowerShell SCEPmanClient pour demander des certificats pour votre serveur Windows. Veuillez vous référer à l'article principal du module pour les prérequis :

{% content-ref url="/pages/e13dc3c6efc569a4b2dd87e2c564bb136d77c73e" %}
[SCEPmanClient](/fr/gestion-des-certificats/api-certificates/scepmanclient.md)
{% endcontent-ref %}

## Description du cas d'utilisation

Bien que le module soit capable de demander initialement des certificats, il peut ne pas être souhaitable de stocker les informations d'identification du Service Principal sur une machine qui pourrait être utilisée pour demander des certificats arbitraires.

Donc, si votre scénario inclut le déploiement d'un certificat à l'aide de Certificate Master, vous pouvez le renouveler automatiquement en utilisant *SCEPmanClient* en fournissant un certificat déjà existant pour l'authentification :

<pre class="language-powershell"><code class="lang-powershell"><strong>$Subject = $env:COMPUTERNAME
</strong><strong>$ValidityThreshold = 30
</strong>
<strong>$CertificateToRenew = Get-ChildItem Cert:\LocalMachine\My `
</strong>                        | Where-Object NotAfter -lt (Get-Date).AddDays($ValidityThreshold) `
                        | Where-Object Subject -match $Subject

New-SCEPmanCertificate -Certificate $CertificateToRenew -SaveToStore 'LocalMachine'

# Avec le nouveau certificat en place, nous pouvons supprimer l'ancien
# Remove-Item $CertificateToRenew.PSPath
</code></pre>

Cet exemple trouvera les certificats expirant dans le mois à venir et l'utilisera pour authentifier la demande de renouvellement.

## Demande initiale

Si vous souhaitez demander initialement des certificats sur votre serveur, vous pouvez le faire en fournissant un Service Principal pour l'authentification qui possède le rôle **CSR DB Requesters** attribué. Veuillez vous référer au guide suivant pour savoir comment implémenter un tel Service Principal :

{% content-ref url="/pages/9c02c2d84b9f5cb46dd91ef987350d59110b089c" %}
[Inscription via l'API](/fr/gestion-des-certificats/api-certificates/api-enrollment.md)
{% endcontent-ref %}

```powershell
$Parameters = @{
    'Url'              = 'scepman.contoso.com'
    'ClientId'         = '569fbf51-aa63-4b5c-8b26-ebbcfcde2715'
    'TenantId'         = '8aa3123d-e76c-42e2-ba3c-190cabbec531'
    'ClientSecret'     = 'csa8Q~aVaWCLZTzswIBGvhxUiEvhptuqEyJugb70'
    'Subject'          = 'CN=WebServer'
    'DNSName'          = 'Webserver.domain.local'
    'ExtendedKeyUsage' = 'ServerAuth'
    'SaveToStore'      = 'LocalMachine'
}

New-SCEPmanCertificate @Parameters
```

Si nous voulons maintenant renouveler un certificat, nous pouvons ignorer le Service Principal et utiliser un certificat déjà émis pour l'authentification. Cela utilisera les détails du certificat existant pour construire une nouvelle CSR et l'envoyer à SCEPman pour obtenir un nouveau certificat.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.scepman.com/fr/gestion-des-certificats/api-certificates/api-enrollment/windows-server.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
