> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/automate-protect-and-extend/zh/ji-cheng-yu-api/powershell-module.md).

# VergeOS PowerShell 模块（PSVergeOS）

## 概述

PSVergeOS 是一个用于通过 REST API 管理 VergeOS 基础设施的 PowerShell 模块。它提供 200 多个 cmdlet，用于自动化 VM 生命周期、网络、存储、多租户操作和灾难恢复工作流，使管理员能够利用其 PowerShell 专业知识来管理 VergeOS。

## 主要功能

* **虚拟机管理**: 创建、配置、电源控制、克隆、快照和迁移
* **高级网络**：虚拟网络、防火墙规则、DHCP、DNS、IPSec VPN 和 WireGuard
* **NAS 与存储**：卷管理、CIFS/NFS 共享和同步
* **多租户**：带资源隔离的租户预配
* **灾难恢复**: 云快照、站点同步、恢复工作流
* **管道支持**: 可链式连接的 cmdlet，用于批量操作
* **跨平台**: 在 Windows、macOS 和 Linux 上运行，需 PowerShell 7.4+

## 要求

* PowerShell 7.4 或更高版本
* VergeOS 26.0 或更高版本

## 安装

### 从 PowerShell Gallery 安装（推荐）

```powershell
Install-Module -Name PSVergeOS -Scope CurrentUser
```

### 手动安装

```powershell
git clone https://github.com/verge-io/PSVergeOS.git
Import-Module ./PSVergeOS/PSVergeOS.psd1
```

## 身份验证

该模块支持多种身份验证方法：

* **交互式凭据**: 在运行时提示输入用户名和密码
* **PSCredential 对象**: 使用存储的凭据自动进行身份验证
* **API 令牌**: 在非交互式场景中使用预生成的令牌
* **自签名证书**: 可选择跳过证书验证，适用于测试环境

## 可用的 Cmdlet

该模块包含 200 多个按类别组织的 cmdlet：

| 类别      | 描述                           |
| ------- | ---------------------------- |
| 连接      | 连接、断开连接并管理服务器连接              |
| 虚拟机     | 生命周期、快照、磁盘、NIC               |
| 网络      | 网络、规则、DNS、DHCP、诊断            |
| VPN     | IPSec 连接/策略，WireGuard 接口/对等端 |
| NAS/存储  | 服务、卷、共享、快照、同步                |
| 租户      | 配置、快照、存储分配                   |
| 用户和组    | 账户管理、权限、API 密钥               |
| 系统      | 集群、节点、许可证、设置                 |
| 监控      | 告警、日志、任务                     |
| 备份与灾难恢复 | 配置文件、云快照、站点管理                |

## 常见用例

* **批量 VM 操作**: 借助管道支持停止、启动、快照或迁移多个 VM
* **基础设施报告**: 导出 VM 清单、资源使用情况和配置数据
* **网络自动化**: 创建网络、配置 DHCP 并管理防火墙规则
* **计划维护**: 与任务计划程序或 cron 集成以实现自动化操作
* **CI/CD 集成**: 在部署管道中配置测试环境

有关代码示例，请参阅 [示例目录](https://github.com/verge-io/PSVergeOS/tree/main/Examples) 在 GitHub 仓库中。

## 文档和资源

如需完整文档（包括所有 cmdlet、参数和详细使用示例），请访问官方仓库：

* [GitHub 仓库](https://github.com/verge-io/PSVergeOS)
* [PowerShell Gallery](https://www.powershellgallery.com/packages/PSVergeOS)

## 支持

如果您遇到问题或有功能请求，请在 GitHub 仓库中提交 issue：

<https://github.com/verge-io/PSVergeOS/issues>

## 其他资源

* [PowerShell 文档](https://learn.microsoft.com/en-us/powershell/)
* [VergeOS API 文档](/knowledge-base/zh/automation-api/verge-api-guide.md)


---

# 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.verge.io/automate-protect-and-extend/zh/ji-cheng-yu-api/powershell-module.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.
