# Windows Server

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

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

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

## ユースケースの説明

このモジュールは最初の証明書要求は可能ですが、任意の証明書を要求できるマシンにサービス プリンシパルの資格情報を保存するのは望ましくない場合があります。

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

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

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

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

## 初回要求

サーバー上で最初に証明書を要求したい場合は、次のロールを持つ認証用のサービス プリンシパルを指定することで実行できます **CSR DB Requesters** 割り当て済み。 このようなサービス プリンシパルを実装する方法については、次のガイドを参照してください:

{% 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
```

ここで証明書を更新したい場合は、サービス プリンシパルを無視して、すでに発行された証明書を認証に使用できます。これにより、既存の証明書の詳細を使用して新しい CSR を作成し、SCEPman に送信して新しい証明書を発行します。


---

# Agent Instructions: 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:

```
GET https://docs.scepman.com/ja/zheng-ming-shu-guan-li/api-certificates/api-enrollment/windows-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
