# ADdomain **Repository Path**: eekon/addomain ## Basic Information - **Project Name**: ADdomain - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2026-05-30 - **Last Updated**: 2026-05-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Domain Management Tool / 域管理工具 [中文](#中文) | [English](#english) --- ## 中文 一个基于 PowerShell + WinForms 的 Windows 域管理 GUI 工具,适用于企业 IT 运维批量加域场景。 ### 功能 - **一键加域**:输入 AD 用户名 → 自动生成计算机名 → 加入域 → 配置本地管理员 → 提示重启 - **一键退域**:退出域 → 清理管理员组 → 删除 AD 计算机对象(三级容错) - **AD 实时搜索**:输入 2 个字符即触发 LDAP 模糊查询,400ms 防抖 - **智能命名**:用户名 + 设备后缀 + 自动递增编号,15 字符限制自动切换短后缀 - **后缀可配置**:GUI 设置界面,配置跟随 EXE 文件(追加到文件尾部) - **三语界面**:中文 / English / 日本語,自动检测系统语言,运行时切换 ### 快速开始 #### 1. 修改域配置 打开 `JoinDomainGUI-Generic.ps1`,修改顶部配置: ```powershell $global:domain = "contoso.com" # 域名 $global:username = "contoso\svc_joindomain" # 加域服务账号 $global:plainPassword = "YourPassword123" # 密码 $global:ouPath = "OU=Workstations,DC=contoso,DC=com" # 目标 OU(留空则用默认容器) ``` #### 2. 运行 ```powershell # 以管理员权限运行 powershell.exe -ExecutionPolicy Bypass -File "JoinDomainGUI-Generic.ps1" ``` #### 3. 编译为 EXE(可选) ```powershell # 一键构建(合并模块 + 语法检查 + 编译) powershell -ExecutionPolicy Bypass -File Build.ps1 ``` 产出:`DomainTool-Generic-v1.0.exe`(自动提权、无控制台窗口) ### 项目结构 ``` JoinDomainGUI-Generic.ps1 # 主入口 Build.ps1 # 构建脚本 modules/ ├── Config.ps1 # 配置持久化 ├── Lang.ps1 # 三语言数据 ├── UIHelpers.ps1 # DPI 适配、配色、字体 ├── LogFunctions.ps1 # 日志(GUI + 文件双写) ├── ADSearch.ps1 # AD 搜索、命名生成 ├── DomainOperations.ps1 # 加域/退域业务逻辑 ├── SettingsDialog.ps1 # 后缀设置弹窗 └── MainForm.ps1 # 主窗体、事件绑定 docs/ # 操作手册(中/英/日) ``` ### 环境要求 - Windows 10 / 11 - PowerShell 5.1(Windows 内置) - 管理员权限 - 目标计算机可访问域控制器 - 编译 EXE 需安装 `ps2exe` 模块 ### 文件编码 所有 `.ps1` 文件使用 **UTF-8 with BOM** 编码。PowerShell 5.x 将无 BOM 的 UTF-8 当作 ANSI 读取,会导致中文乱码。 ### License MIT --- ## English A PowerShell + WinForms GUI tool for Windows Active Directory domain management, designed for enterprise IT operations. ### Features - **One-click domain join**: AD username → auto-generate computer name → join domain → configure local admin → prompt restart - **One-click domain leave**: Leave domain → clean admin group → delete AD computer object (3-level fallback) - **Real-time AD search**: LDAP fuzzy query triggered after 2 characters, with 400ms debounce - **Smart naming**: Username + device suffix + auto-increment number, auto-switch to short suffix at 15-char limit - **Configurable suffixes**: GUI settings dialog, config persists with EXE file (appended to file tail) - **Tri-lingual UI**: Chinese / English / Japanese, auto-detect system language, runtime switching ### Quick Start #### 1. Configure domain settings Edit `JoinDomainGUI-Generic.ps1`, modify the config section at the top: ```powershell $global:domain = "contoso.com" # Domain name $global:username = "contoso\svc_joindomain" # Domain join service account $global:plainPassword = "YourPassword123" # Password $global:ouPath = "OU=Workstations,DC=contoso,DC=com" # Target OU (empty = default container) ``` #### 2. Run ```powershell # Run as Administrator powershell.exe -ExecutionPolicy Bypass -File "JoinDomainGUI-Generic.ps1" ``` #### 3. Compile to EXE (optional) ```powershell # One-command build (merge modules + syntax check + compile) powershell -ExecutionPolicy Bypass -File Build.ps1 ``` Output: `DomainTool-Generic-v1.0.exe` (auto-elevate UAC, no console window) ### Requirements - Windows 10 / 11 - PowerShell 5.1 (built-in) - Administrator privileges - Network access to domain controller - `ps2exe` module required for EXE compilation ### License MIT