> 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/es/gestion-de-certificados/api-certificates/api-enrollment/windows-server.md).

# Servidor Windows

{% hint style="info" %}
Aplicable a la versión 2.9 de SCEPman y posteriores
{% endhint %}

Puedes usar el módulo de PowerShell SCEPmanClient para solicitar certificados para tu servidor Windows. Consulta el artículo principal del módulo para conocer los requisitos previos:

{% content-ref url="/pages/53a88a3274a2c93bbc35ad73bc9abe307ee6d80f" %}
[SCEPmanClient](/es/gestion-de-certificados/api-certificates/scepmanclient.md)
{% endcontent-ref %}

## Descripción del caso de uso

Aunque el módulo es capaz de solicitar certificados inicialmente, quizá no sea deseable almacenar las credenciales de Service Principal en una máquina que podría usarse para solicitar certificados arbitrarios.

Así que, si tu escenario incluye el despliegue de un certificado usando Certificate Master, puedes renovarlo automáticamente usando *SCEPmanClient* proporcionando un certificado ya existente para autenticación:

<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'

# Con el nuevo certificado en su lugar, podemos eliminar el anterior
# Remove-Item $CertificateToRenew.PSPath
</code></pre>

Este ejemplo encontrará certificados que expiran el próximo mes y los usará para autenticar la solicitud de renovación.

## Solicitud inicial

Si deseas solicitar certificados inicialmente en tu servidor, puedes hacerlo proporcionando para la autenticación un Service Principal que tenga asignado el rol **CSR DB Requesters** asignado. Consulta la siguiente guía sobre cómo implementar un Service Principal de este tipo:

{% content-ref url="/pages/b31d8f3786b22311eafcf73ce7738f65815607e8" %}
[Inscripción mediante API](/es/gestion-de-certificados/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 ahora queremos renovar un certificado, podemos prescindir del Service Principal y usar un certificado ya emitido para autenticación. Esto utilizará los detalles del certificado existente para construir una nueva CSR y enviarla a SCEPman para un nuevo certificado.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scepman.com/es/gestion-de-certificados/api-certificates/api-enrollment/windows-server.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
