# PEDMポリシーコマンド

### 概要

ここでは、PEDMの特権昇格ポリシーを管理するKeeperコマンダーのコマンドを扱います。ポリシーはフィルターとコントロールにより特権昇格のルールを定義し、ユーザーがいつ・どのように特権を昇格できるかを決めます。これらのコマンドで、ユーザー・マシン・アプリケーション・日付・時刻・曜日などの各種フィルターを用いたポリシーの作成・表示・編集・割り当て・削除が行えます。

このセクションで扱うコマンドは以下のとおりです。

* [**ポリシー一覧コマンド**](#policy-list-command)
* [**ポリシー追加コマンド**](#policy-add-command)
* [**ポリシー編集コマンド**](#policy-edit-command)
* [**ポリシー参照コマンド**](#policy-view-command)
* [**ポリシー削除コマンド**](#policy-delete-command)
* [**ポリシー適用エージェント一覧コマンド**](#policy-agents-command)
* [**ポリシー割り当てコマンド**](#policy-assign-command)

### 使い方

`pedm policy command [--options]` または `pedm p command [--options]`

**エイリアス:** `p`

***

### ポリシー一覧コマンド <a href="#policy-list-command" id="policy-list-command"></a>

すべてのPEDMポリシーを、ポリシータイプ、状態、コントロール、フィルター設定を含む構成とともに表示します。システムに設定された特権昇格ポリシー全体の概要を把握できます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy list`

**エイリアス:** `pedm p l`, `pedm p list`

**フラグ:**

| フラグ        | 説明                         |
| ---------- | -------------------------- |
| `--format` | 出力形式 - json、csv、tableのいずれか |
| `--output` | 指定ファイルに保存する                |

**例:**

```
My Vault> pedm policy list

Policy UID: policy_xyz789
Policy Name: Elevation Policy
Policy Type: PrivilegeElevation
Status: enforce
Controls: ['AUDIT', 'MFA']
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)
policies = plugin.policies.get_all_entities()
```

</details>

### ポリシー追加コマンド <a href="#policy-add-command" id="policy-add-command"></a>

指定したフィルターとコントロールで新しい特権昇格ポリシーを作成します。ポリシーにはユーザー・マシン・アプリケーションのフィルターに加え、日付・時刻・曜日の制限を含められます。特権昇格時に必須または許可される操作は、コントロールで指定します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy add`

**エイリアス:** `pedm p a`, `pedm p add`

**フラグ:**

| フラグ                | 説明                                                                               |
| ------------------ | -------------------------------------------------------------------------------- |
| `--policy-type`    | ポリシータイプ (choices: elevation, file\_access, command, least\_privilege)            |
| `--policy-name`    | ポリシー名                                                                            |
| `--control`        | ポリシーコントロール (choices: allow, deny, audit, notify, mfa, justify, approval)。繰り返し指定可 |
| `--status`         | ポリシーステータス (choices: enforce, monitor, monitor\_and\_notify)                      |
| `--enable`         | ポリシーの有効化または無効化 (choices: on, off)                                                |
| `--user-filter`    | ユーザーコレクションのUID、または全ユーザーを示す\*。繰り返し指定可                                             |
| `--machine-filter` | マシンコレクションのUID。繰り返し指定可                                                            |
| `--app-filter`     | アプリケーションコレクションのUID。繰り返し指定可                                                       |
| `--date-filter`    | ISO形式の日付範囲 (YYYY-MM-DD:YYYY-MM-DD)。繰り返し指定可                                       |
| `--time-filter`    | 24時間形式の時刻範囲 (HH:MM-HH:MM)。繰り返し指定可                                                |
| `--day-filter`     | 曜日フィルター。繰り返し指定可                                                                  |
| `--risk-level`     | ポリシーリスクレベル (0-100)                                                               |

**例:**

```
My Vault> pedm policy add --policy-type elevation --policy-name "Admin Elevation" --control audit --control mfa --user-filter "*" --status enforce

Policy created successfully
Policy UID: policy_new123
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types
from keepersdk import utils

plugin = admin_plugin.PedmPlugin(enterprise_loader)

controls = ['policy controls']
policy_name = 'policy name'
policy_type = 'LeastPrivilege' ## or 'FileAccess', 'PrivilegeElevation'
policy_uid = utils.generate_uid()
policy_data: Dict[str, Any] = {
    'PolicyName': policy_name,
    'PolicyType': policy_type,
    'PolicyId': policy_uid,
    'Status': 'off',
    'Actions': {
        'OnSuccess': {'Controls': controls or []},
        'OnFailure': {'Command': ''}
    },
    "NotificationMessage": "A policy has been set to monitor mode.  When this policy is enabled, [mfa, justification, request] will be required to run this process as an administrator.",
    "NotificationRequiresAcknowledge": False,
    "RiskLevel": 50,
    'Operator': 'And',
    'Rules': [
        {
            'RuleName': 'UserCheck',
            'ErrorMessage': 'This user is not included in this policy',
            'RuleExpressionType': 'BuiltInAction',
            'Expression': 'CheckUser()'
        },
        {
            'RuleName': 'MachineCheck',
            'ErrorMessage': 'This Machine is not included in this policy',
            'RuleExpressionType': 'BuiltInAction',
            'Expression': 'CheckMachine()'
        },
        {
            'RuleName': 'ApplicationCheck',
            'ErrorMessage': 'This application is not included in this policy',
            'RuleExpressionType': 'BuiltInAction',
            'Expression': 'CheckFile(false)'
        },
        {
            "RuleName": "DateCheck",
            "ErrorMessage": "Current date is not covered by this policy",
            "RuleExpressionType": "BuiltInAction",
            "Expression": "CheckDate()"
        },
        {
            'RuleName': 'TimeCheck',
            'ErrorMessage': 'Current time is not covered by this policy',
            'RuleExpressionType': 'BuiltInAction',
            'Expression': 'CheckTime()'
        },
        {
            'RuleName': 'DayCheck',
            'ErrorMessage': 'Today is not included in this policy',
            'RuleExpressionType': 'BuiltInAction',
            'Expression': 'CheckDay()'
        }
    ]
}
disabled: bool = False
policy_key = utils.generate_aes_key()
add_policy = admin_types.PedmPolicy(
    policy_uid=policy_uid, policy_key=policy_key, data=policy_data, admin_data={}, disabled=disabled)
response = plugin.modify_policies(add_policies=[add_policy])
```

</details>

### ポリシー編集コマンド <a href="#policy-edit-command" id="policy-edit-command"></a>

既存ポリシーの構成 (名前、コントロール、フィルター、状態など) を変更します。ポリシーを作り直さずに、管理者が設定を更新できます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy edit <policy>`

**エイリアス:** `pedm p e`, `pedm p edit`

**フラグ:**

| フラグ                | 説明                                                                               |
| ------------------ | -------------------------------------------------------------------------------- |
| `policy`           | ポリシーUID (必須)                                                                     |
| `--policy-name`    | 新しいポリシー名                                                                         |
| `--control`        | ポリシーコントロール (choices: allow, deny, audit, notify, mfa, justify, approval)。繰り返し指定可 |
| `--status`         | ポリシーステータス (choices: enforce, monitor, monitor\_and\_notify)                      |
| `--enable`         | ポリシーの有効化または無効化 (choices: on, off)                                                |
| `--user-filter`    | ユーザーコレクションのUIDまたは\*。繰り返し指定可                                                      |
| `--machine-filter` | マシンコレクションのUID。繰り返し指定可                                                            |
| `--app-filter`     | アプリケーションコレクションのUID。繰り返し指定可                                                       |
| `--date-filter`    | 日付範囲 (YYYY-MM-DD:YYYY-MM-DD)。繰り返し指定可                                             |
| `--time-filter`    | 時刻範囲 (HH:MM-HH:MM)。繰り返し指定可                                                       |
| `--day-filter`     | 曜日。繰り返し指定可                                                                       |
| `--risk-level`     | リスクレベル (0-100)                                                                   |

**例:**

```
My Vault> pedm policy edit policy_xyz789 --policy-name "Updated Admin Policy" --control justify --enable on

Policy updated successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)
policy_id = 'policy name or uid'
policy = plugin.policies.get_entity(policy_id)
policy_data = copy.deepcopy(policy.data or {})
policy_type = policy_data.get('PolicyType') or 'Unknown'
controls = ['policy controls']
if isinstance(controls, list):
    actions = policy_data.get('Actions')
    if not isinstance(actions, dict):
        actions = {}
        policy_data['Actions'] = actions
    on_success = actions.get('OnSuccess')
    if not isinstance(on_success, dict):
        on_success = {}
    on_success['Controls'] = controls
    policy_data['OnSuccess'] = on_success

policy_name = 'policy name'
if policy_name:
    policy_data['PolicyName'] = policy_name

disabled = True #or False
pu = admin_types.PedmUpdatePolicy(policy_uid=policy.policy_uid, data=policy_data, disabled=disabled)

rs = plugin.modify_policies(update_policies=[pu])
```

</details>

### ポリシー参照コマンド <a href="#policy-view-command" id="policy-view-command"></a>

ポリシーの完全なJSON構成を表示します。フィルター、コントロール、ルール、メタデータを含むポリシー詳細をJSON形式で示します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy view <policy>`

**エイリアス:** `pedm p v`, `pedm p view`

**フラグ:**

| フラグ        | 説明                |
| ---------- | ----------------- |
| `policy`   | ポリシーUIDまたは名前 (必須) |
| `--format` | 出力形式 - json       |
| `--output` | ファイルに保存する         |

**例:**

```
My Vault> pedm policy view policy_xyz789

{
    "PolicyName": "Admin Elevation",
    "PolicyType": "PrivilegeElevation",
    "Status": "enforce",
    "Actions": {
        "OnSuccess": {
            "Controls": ["AUDIT", "MFA"]
        }
    }
}
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)
policy_id = 'policy name or uid'
policy = plugin.policies.get_entity(policy_id)
```

</details>

### ポリシー削除コマンド <a href="#policy-delete-command" id="policy-delete-command"></a>

システムから1つ以上のポリシーを削除します。ポリシー構成を恒久削除し、すべてのコレクション割り当てからも外します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy delete <policy> [policy...]`

**エイリアス:** `pedm p delete`

**フラグ:**

| フラグ      | 説明                      |
| -------- | ----------------------- |
| `policy` | ポリシーUIDまたは名前 (必須、複数指定可) |

**例:**

```
My Vault> pedm policy delete policy_old123

Policy deleted successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)
policy_id = 'policy name or uid'
policy = plugin.policies.get_entity(policy_id)
to_delete = [policy.policy_uid]

response = plugin.modify_policies(remove_policies=to_delete)
```

</details>

### ポリシー適用エージェント一覧コマンド <a href="#policy-agents-command" id="policy-agents-command"></a>

指定したポリシーの影響を受けるエージェントを表示します。コレクション割り当てを通じて指定ポリシーに割り当てられたすべてのエージェントを示します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy agents <policy> [policy...]`

**エイリアス:** `pedm p agents`

**フラグ:**

| フラグ      | 説明                      |
| -------- | ----------------------- |
| `policy` | ポリシーUIDまたは名前 (必須、複数指定可) |

**例:**

```
My Vault> pedm policy agents policy_xyz789

Policy: policy_xyz789
Name: Admin Elevation
Status: enforce

Agent: agent_abc123
Machine: SERVER-001
Status: on
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)
policy_id = 'policy name or uid'
policy = plugin.policies.get_entity(policy_id)
policy_uids = [policy.policy_uid]

rq = pedm_pb2.PolicyAgentRequest()
rq.policyUid.extend(policy_uids)
rq.summaryOnly = False
rs = KeeperAuth.execute_router("pedm/get_policy_agents", rq, response_type=pedm_pb2.PolicyAgentResponse)
```

</details>

### ポリシー割り当てコマンド <a href="#policy-assign-command" id="policy-assign-command"></a>

ポリシーにコレクションを割り当て、ポリシーがどのリソースに適用されるかを決めます。コレクションにはエージェント、ユーザー、マシン、アプリケーションを含められます。全エージェントに適用する場合は「\*」を使います。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm policy assign <policy> [policy...]`

**エイリアス:** `pedm p assign`

**フラグ:**

| フラグ                | 説明                                       |
| ------------------ | ---------------------------------------- |
| `-c, --collection` | 割り当てるコレクションのUID (全エージェントには\*を指定)。繰り返し指定可 |
| `policy`           | ポリシーUIDまたは名前 (必須、複数指定可)                  |

**例:**

```
My Vault> pedm policy assign policy_xyz789 -c collection_abc -c collection_def

Collections assigned to policy successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)
policy_id = 'policy name or uid'
policy = plugin.policies.get_entity(policy_id)
policy_uids = [policy.policy_uid]
collections = ['Collection UIDs']
collection_uids: List[bytes] = []
if isinstance(collections, list):
    for c in collections:
        if c in ['*', 'all']:
            collection_uids.append(plugin.all_agents)
        elif c:
            collection_uid = utils.base64_url_decode(c)
            if len(collection_uid) == 16:
                collection_uids.append(collection_uid)


statuses = plugin.assign_policy_collections(policy_uids, collection_uids)
```

</details>


---

# 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.keeper.io/keeperpam/jp/commander-sdk/keeper-commander-sdks/sdk-command-reference/pedm-commands/pedm-policy-commands.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.
