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

# Servidor Windows

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

Puede usar el módulo PowerShell SCEPmanClient para solicitar certificados para su servidor Windows. Consulte el artículo principal del módulo para conocer los requisitos previos:

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

## Descripción del caso de uso

Aunque el módulo es capaz de solicitar certificados inicialmente, puede no ser deseable almacenar las credenciales del principal de servicio en una máquina que podría usarse para solicitar certificados arbitrarios.

Así que, si su escenario incluye la implementación de un certificado mediante Certificate Master, puede renovarlo automáticamente usando *SCEPmanClient* proporcionando un certificado ya existente para la 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 antiguo
# Remove-Item $CertificateToRenew.PSPath
</code></pre>

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

## Solicitud inicial

Si desea solicitar certificados inicialmente en su servidor, puede hacerlo proporcionando un principal de servicio para la autenticación que tenga asignado el rol **CSR DB Requesters** asignado. Consulte la siguiente guía sobre cómo implementar un principal de servicio de este tipo:

{% content-ref url="/pages/b31d8f3786b22311eafcf73ce7738f65815607e8" %}
[Inscripción por API](/es/administracion-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 principal de servicio y usar un certificado ya emitido para la 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 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/es/administracion-de-certificados/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.
