> 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 la versión 2.9 y posteriores de SCEPman
{% endhint %}

Puede usar el módulo de 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, podría no ser deseable almacenar las credenciales del principal de servicio en una máquina que podría usarse para solicitar certificados arbitrarios.

Por lo tanto, 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 autenticación:

<pre class="language-powershell"><code class="lang-powershell"><strong>$Subject = $env:COMPUTERNAME
</strong><strong>$ValidityThreshold = 30
</strong><strong>
</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 buscará certificados que caduquen en el próximo mes y lo usará para autenticar la solicitud de renovación.

## Solicitud inicial

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

{% content-ref url="/pages/b31d8f3786b22311eafcf73ce7738f65815607e8" %}
[Inscripción mediante 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 obtener 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/administracion-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.
