← 返回
开发者工具 中文

WSL-PowerShell Controller

Control Windows PowerShell from WSL by executing commands and scripts on the Windows host using mounted Windows executables.
通过挂载的Windows可执行文件,从WSL控制PowerShell并在Windows主机执行命令脚本。
tyzzt tyzzt 来源
开发者工具 clawhub v1.0.1 1 版本 99885.1 Key: 无需
★ 0
Stars
📥 869
下载
💾 57
安装
1
版本
#automation#latest#powershell#windows#wsl

概述

WSL-PowerShell Controller

Call Windows PowerShell from WSL to control Windows host from Linux environment.

How It Works

WSL mounts Windows drives to /mnt/, allowing direct execution of Windows binaries:

  • PowerShell: /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
  • CMD: /mnt/c/Windows/System32/cmd.exe

Usage

Execute PowerShell Commands

/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Your-Command"

Execute PowerShell Scripts

/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -File "/mnt/c/path/to/script.ps1"

Common Examples

System Information

# Get system info
powershell.exe -Command "Get-ComputerInfo"

# Get process list
powershell.exe -Command "Get-Process | Select-Object -First 10 Name,Id,CPU"

# Get service status
powershell.exe -Command "Get-Service | Where-Object {$_.Status -eq 'Running'} | Select-Object -First 10 Name,DisplayName"

File Operations

# List directory
powershell.exe -Command "Get-ChildItem C:\\Users"

# Copy file
powershell.exe -Command "Copy-Item C:\\source\\file.txt C:\\dest\\file.txt"

# Create file
powershell.exe -Command "New-Item -Path C:\\test.txt -ItemType File -Force"

Process Management

# Start program
powershell.exe -Command "Start-Process notepad.exe"

# Stop process
powershell.exe -Command "Stop-Process -Name notepad -Force"

Network Operations

# Get network config
powershell.exe -Command "Get-NetIPConfiguration"

# Ping test
powershell.exe -Command "Test-Connection -ComputerName google.com -Count 2"

Path Conversion

WSL Path ↔ Windows Path:

  • WSL: /mnt/c/Users/Tao ↔ Windows: C:\Users\Tao
  • Use wslpath command:

```bash

wslpath -w /mnt/c/Users # Output: C:\Users

wslpath -u C:\\Users # Output: /mnt/c/Users

```

Notes

  1. Permissions: Some operations require administrator privileges, use -Verb RunAs for elevated PowerShell
  2. Path Escaping: Backslashes \ in Windows paths must be escaped as \\
  3. Encoding: PowerShell outputs UTF-16 by default, may need conversion
  4. Execution Policy: Running scripts may require Set-ExecutionPolicy

Security Tips

  • Use caution with system-level commands
  • Avoid deleting critical system files
  • Test commands before executing in production

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-19 09:48 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Docker Essentials

arnarsson
核心 Docker 命令和工作流程,包括容器管理、镜像操作和调试。
★ 38 📥 32,241
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 72 📥 181,470
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 195 📥 67,426