# デバイス承認コマンド

#### 使い方

```
device-approve [--options] [device ...]
```

**パラメータ:**

承認または拒否するユーザーのメールアドレスまたはデバイスID。未指定の場合は保留中デバイスの一覧を表示します。

#### 対応コマンド

* [デバイス承認 - 一覧コマンド](#device-approval-requests-list-command)
* [デバイス承認 - 承認コマンド](#device-approval-request-approve)
* [デバイス承認 - 拒否コマンド](#device-approval-request-deny)

### デバイス承認リクエスト一覧コマンド <a href="#device-approval-requests-list-command" id="device-approval-requests-list-command"></a>

<details>

<summary>DotNet CLI</summary>

**使い方:**

```bash
enterprise-device [options] [command] [match]
```

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

**サブコマンド:**

* `list` - デバイス承認リクエストの一覧表示 (既定)

**オプション:**

* `-f, --force` - エンタープライズデータの強制再読み込み
* `--auto-approve <true|false>` - 自動承認ポリシーの設定

**照合パターン:**

* `all` - 保留中リクエストのすべて
* `email` - ユーザーのメールアドレス
* `device-id` - 特定のデバイスID

**例:**

```zsh
# 保留中デバイス承認の一覧
enterprise-device list
ed list

# 自動承認ポリシーの設定
enterprise-device --auto-approve true

```

</details>

<details>

<summary>DotNet SDK</summary>

**メソッド:** `DeviceApprovalRequests`

```csharp
  public IEnumerable<DeviceRequestForAdminApproval> DeviceApprovalRequests => _deviceApprovals.Entities;
```

**例:**

```csharp
var enterpriseData = new EnterpriseData();
var deviceApproval = new DeviceApprovalData();
// ... initialize enterprise loader with deviceApproval plugin ...

var pendingDevices = deviceApproval.DeviceApprovalRequests;
foreach (var device in pendingDevices)
{
    Console.WriteLine($"User ID: {device.EnterpriseUserId}, Device: {device.DeviceName}");
}
```

</details>

<details>

<summary>PowerCommander</summary>

**コマンド:** `Get-PendingKeeperDeviceApproval`

**フラグ:**

| フラグ       | 説明                                         |
| --------- | ------------------------------------------ |
| `-Reload` | 保留中一覧のサーバー再読み込み (スイッチ)                     |
| `-Format` | 出力形式 (`table` / `csv` / `json`、既定 `table`) |
| `-Output` | 出力先ファイルパス (`csv` / `json` では必須)            |

**例:**

```powershell
PS > Get-PendingKeeperDeviceApproval

Email                DeviceId            DeviceName      ClientVersion  IpAddress
-----                --------            ----------      -------------  ---------
user@example.com     a1b2c3d4e5f6...     John's iPhone   16.0.0         192.168.1.100
admin@company.com    b2c3d4e5f6a1...     Work Laptop      16.1.0         10.0.0.50
```

**JSON出力の例:**

```powershell
PS > Get-PendingKeeperDeviceApproval -Reload -Format json
[
    {
        "Email":  "user@example.com",
        "DeviceId":  "a1b2c3d4e5f6...",
        "DeviceName":  "John's iPhone",
        "ClientVersion":  "16.0.0",
        "IpAddress":  "192.168.1.100",
        "DeviceType":  "mobile"
    }
]
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `device-aprove`

**パラメータ:**

`device` - ユーザーのメールアドレスまたはデバイスID (省略可、複数指定可)

**オプション:**

* `-r`, `--reload` - 保留中承認リクエスト一覧の再読み込み
* `--trusted-ip` - 信頼済みIPから接続したデバイスのみ承認
* `--format` - 出力形式: `json`、`table`、`csv`
* `--output` - 出力ファイル名

**例:**

```bash
My Vault> device-approve

Date                 Email                                     Device ID             Device Name       Device Type    IP Address    Client Version    Location
-------------------  ----------------------------------------  --------------------  ----------------  -------------  ------------  ----------------  ----------
2026-01-21 06:02:40  user@keepersecurity.com                   1234hgghjjhg234gh123  Web Vault Chrome  Web Vault      192.168.1.1    w17.5.0
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.enterprise import enterprise_data
from keepersdk import utils


def token_to_string(token: bytes) -> str:
    """Convert device token bytes to hexadecimal string representation."""
    src = token[0:TOKEN_PREFIX_LENGTH]
    if src.hex:
        return src.hex()
    return ''.join('{:02x}'.format(x) for x in src)

enterprise = enterprise_data.IEnterpriseData()
approve_requests = enterprise.device_approval_requests.get_all_entities()
for device in approve_requests:
    device_id = device.encrypted_device_token
    if not device_id:
        continue
    device_id = token_to_string(utils.base64_url_decode(device_id))
    print(device_id)
    print(device.device_name)
    print(device.device_type)
    print(device.ip_address)
    print(device.client_version)
    print(device.location)
```

</details>

### デバイス承認リクエストの承認 <a href="#device-approval-request-approve" id="device-approval-request-approve"></a>

保留中のデバイス承認リクエストを承認します。デバイスID（部分一致可）またはユーザーのメールアドレスで対象を指定できます。照合を指定しない場合、保留中のデバイスがすべて承認されます。

<details>

<summary>DotNet CLI</summary>

**使い方:**

```bash
enterprise-device [options] [command] [match]
```

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

**サブコマンド:**

* `approve` - デバイスの承認

**オプション:**

* `-f, --force` - エンタープライズデータの強制再読み込み
* `--auto-approve <true|false>` - 自動承認ポリシーの設定

**照合パターン:**

* `all` - 保留中リクエストのすべて
* `email` - ユーザーのメールアドレス
* `device-id` - 特定のデバイスID

**例:**

```
# デバイスの承認
enterprise-device approve user@example.com
ed approve all
enterprise-device approve abc123deviceid

# 自動承認ポリシーの設定
enterprise-device --auto-approve true

```

</details>

<details>

<summary>DotNet SDK</summary>

非対応

</details>

<details>

<summary>PowerCommander</summary>

**コマンド:** `Approve-KeeperDevice`

**フラグ:**

| フラグ          | 説明                                           |
| ------------ | -------------------------------------------- |
| `-Match`     | 承認対象 (デバイスIDの部分一致可、またはメール)。省略時は保留中デバイスをすべて承認 |
| `-Reload`    | 処理前の保留中一覧の再読み込み (スイッチ)                       |
| `-TrustedIp` | 信頼済みIPからのデバイスのみ承認 (スイッチ、未実装)                 |
| `-WhatIf`    | 承認せず内容のプレビュー (スイッチ、SupportsShouldProcess)    |
| `-Confirm`   | 承認前の確認プロンプト (スイッチ、SupportsShouldProcess)     |

**例:**

```powershell
PS > Approve-KeeperDevice -Match "user@example.com"

What if: Performing the operation "Approve" on target "1 device(s)".
Approved 1 device(s)
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `device-aprove --approve <Device_UID>`

**パラメータ:**

`device` - ユーザーのメールアドレスまたはデバイスID (省略可、複数指定可)

**オプション:**

* `-a`, `--approve` - ユーザーデバイスの承認
* `--trusted-ip` - 信頼済みIPから接続したデバイスのみ承認

**例:**

```bash
My Vault> device-approve --approve 1234hgghjjhg234gh123
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
approval_requests: List[DeviceApprovalRequest] = list(enterprise_data.device_approval_requests.get_all_entities())

for device in approval_requests:
            device_rq = enterprise_pb2.ApproveUserDeviceRequest()
            device_rq.enterpriseUserId = device.enterprise_user_id
            device_rq.encryptedDeviceToken = utils.base64_url_decode(device.encrypted_device_token)
            device_rq.denyApproval = False
            device_rq.encryptedDeviceDataKey = encrypted_data_key
            device_requests.append(device_rq)
approve_rq = enterprise_pb2.ApproveUserDevicesRequest()
approve_rq.deviceRequests.extend(device_requests)
KeeperAuth.execute_auth_rest(APPROVE_USER_DEVICES_ENDPOINT, approve_rq, 
                                response_type=enterprise_pb2.ApproveUserDevicesResponse)
```

</details>

### デバイス承認リクエストの拒否 <a href="#device-approval-request-deny" id="device-approval-request-deny"></a>

保留中のデバイス承認リクエストを拒否します。デバイスID（部分一致可）またはユーザーのメールアドレスで対象を指定できます。照合を指定しない場合、保留中のデバイスがすべて拒否されます。

<details>

<summary>DotNet CLI</summary>

**使い方:**

```bash
enterprise-device [options] [command] [match]
```

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

**サブコマンド:**

* `decline` - デバイスの拒否

**オプション:**

* `-f, --force` - エンタープライズデータの強制再読み込み
* `--auto-approve <true|false>` - 自動承認ポリシーの設定

**照合パターン:**

* `all` - 保留中リクエストのすべて
* `email` - ユーザーのメールアドレス
* `device-id` - 特定のデバイスID

**例:**

```
# デバイスの拒否
enterprise-device decline user@example.com
ed decline all

# 自動承認ポリシーの設定
enterprise-device --auto-approve true

```

</details>

<details>

<summary>DotNet SDK</summary>

非対応

</details>

<details>

<summary>PowerCommander</summary>

**コマンド:** `Deny-KeeperDevice`

**フラグ:**

| フラグ        | 説明                                           |
| ---------- | -------------------------------------------- |
| `-Match`   | 拒否対象 (デバイスIDの部分一致可、またはメール)。省略時は保留中デバイスをすべて拒否 |
| `-Reload`  | 処理前の保留中一覧の再読み込み (スイッチ)                       |
| `-WhatIf`  | 拒否せず内容のプレビュー (スイッチ、SupportsShouldProcess)    |
| `-Confirm` | 拒否前の確認プロンプト (スイッチ、SupportsShouldProcess)     |

**例:**

```powershell
PS > Deny-KeeperDevice -Match "user@example.com"

What if: Performing the operation "Deny" on target "1 device(s)".
Denied 1 device(s)
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `device-approve --deny <Device_UID>`

**パラメータ:**

`device` - ユーザーのメールアドレスまたはデバイスID (省略可、複数指定可)

**オプション:**

* `-d`, `--deny` - ユーザーデバイスの拒否

**例:**

```bash
My Vault> device-approve --deny user@example.com
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
approval_requests: List[DeviceApprovalRequest] = list(enterprise_data.device_approval_requests.get_all_entities())

for device in approval_requests:
            device_rq = enterprise_pb2.ApproveUserDeviceRequest()
            device_rq.enterpriseUserId = device.enterprise_user_id
            device_rq.encryptedDeviceToken = utils.base64_url_decode(device.encrypted_device_token)
            device_rq.denyApproval = True
            device_requests.append(device_rq)
approve_rq = enterprise_pb2.ApproveUserDevicesRequest()
approve_rq.deviceRequests.extend(device_requests)
KeeperAuth.execute_auth_rest(APPROVE_USER_DEVICES_ENDPOINT, approve_rq, 
                                response_type=enterprise_pb2.ApproveUserDevicesResponse)
```

</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/enterprise-management-commands/device-approve-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.
