> 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/ja/zheng-ming-shu-guan-li/api-certificates/api-enrollment/windows-server.md).

# Windows サーバー

{% hint style="info" %}
SCEPman バージョン 2.9 以降に適用されます
{% endhint %}

SCEPmanClient PowerShell モジュールを使用して、Windows サーバーの証明書を要求できます。前提条件については、モジュールのメイン記事を参照してください:

{% content-ref url="/pages/bf7351c033e552bb4765454f3191e59e17971340" %}
[SCEPmanClient](/ja/zheng-ming-shu-guan-li/api-certificates/scepmanclient.md)
{% endcontent-ref %}

## ユースケースの説明

このモジュールは最初の証明書要求はできますが、任意の証明書を要求できる可能性のあるマシンに service principal の資格情報を保存するのは望ましくないかもしれません。

したがって、シナリオに Certificate Master を使用した証明書の展開が含まれる場合は、次を使用して自動的に更新できます *SCEPmanClient* 認証用に既存の証明書を指定することで:

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

# 新しい証明書を配置したら、古い証明書を削除できます
# $CertificateToRenew.PSPath を Remove-Item で削除します
</code></pre>

この例では、次の 1 か月以内に期限切れになる証明書を見つけ、それを更新要求の認証に使用します。

## 初回要求

サーバーで最初に証明書を要求したい場合は、ロールを持つ認証用の service principal を指定することで実行できます **CSR DB Requesters** が割り当てられている必要があります。そのような service principal を実装する方法については、次のガイドを参照してください:

{% content-ref url="/pages/36cc2f22559c6d88af378786d530d4c19b4503b4" %}
[API による登録](/ja/zheng-ming-shu-guan-li/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
```

既存の証明書を更新したい場合は、service principal を無視して、認証に発行済みの証明書を使用できます。これにより、既存の証明書の詳細を使用して新しい CSR を作成し、SCEPman に送信して新しい証明書を発行します。


---

# 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/ja/zheng-ming-shu-guan-li/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.
