Skip to content

TYzzt/wsl-powershell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

WSL-PowerShell Controller

License WSL PowerShell GitHub stars

Call Windows PowerShell from WSL (Windows Subsystem for Linux) to control Windows from Linux environment.

๐ŸŽฏ Features

  • โœ… Support Windows PowerShell and PowerShell Core
  • โœ… Automatic path conversion (WSL โ†” Windows)
  • โœ… Error handling and debug mode
  • โœ… Command and script file execution modes
  • โœ… Comprehensive help and version info
  • โœ… Colored log output

๐Ÿ“ฆ Installation

Method 1: Manual Install (Recommended for Agents)

# Clone to OpenClaw workspace skills directory
cd ~/.openclaw/workspace/skills
git clone https://github.com/TYzzt/wsl-powershell.git

# Add execute permission
chmod +x wsl-powershell/scripts/psctl.sh

For Agents: Restart OpenClaw session after cloning, skill will auto-load.

Method 2: Using ClawHub CLI

# Install ClawHub CLI
npm install -g clawhub

# Login
clawhub login

# Install skill
clawhub install wsl-powershell

Method 3: Direct Download

# Download ZIP
wget https://github.com/TYzzt/wsl-powershell/archive/refs/heads/main.zip
unzip main.zip -d ~/.openclaw/workspace/skills/
mv ~/.openclaw/workspace/skills/wsl-powershell-main ~/.openclaw/workspace/skills/wsl-powershell

# Add execute permission
chmod +x ~/.openclaw/workspace/skills/wsl-powershell/scripts/psctl.sh

๐Ÿ”ง Basic Usage

# Execute PowerShell command
./scripts/psctl.sh "Get-Process | Select-Object -First 5 Name,Id"

# Execute PowerShell script file
./scripts/psctl.sh -f /mnt/c/scripts/myscript.ps1

# Check PowerShell availability
./scripts/psctl.sh --check

๐Ÿ“– Examples

System Information

# Get system info
./scripts/psctl.sh "Get-ComputerInfo | Select-Object WindowsProductName,WindowsVersion"

# Get process list
./scripts/psctl.sh "Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name,Id,CPU"

# Get service status
./scripts/psctl.sh "Get-Service | Where-Object {\$_.Status -eq 'Running'} | Select-Object -First 10 Name,DisplayName"

File Operations

# List directory
./scripts/psctl.sh "Get-ChildItem C:\\Users"

# Copy file
./scripts/psctl.sh "Copy-Item C:\\source\\file.txt C:\\dest\\file.txt -Force"

# Create file
./scripts/psctl.sh "New-Item -Path C:\\test.txt -ItemType File -Force"

Process Management

# Start program
./scripts/psctl.sh "Start-Process notepad.exe"

# Stop process
./scripts/psctl.sh "Stop-Process -Name notepad -Force"

Network Operations

# Get network config
./scripts/psctl.sh "Get-NetIPConfiguration | Select-Object InterfaceAlias,IPv4Address"

# Ping test
./scripts/psctl.sh "Test-Connection -ComputerName google.com -Count 2"

๐Ÿ”ง Advanced Options

# Show help
./scripts/psctl.sh --help

# Show version
./scripts/psctl.sh --version

# Debug mode
DEBUG=1 ./scripts/psctl.sh "Get-Process"

# Verbose output
./scripts/psctl.sh -v "Get-Service"

# Use PowerShell Core
./scripts/psctl.sh -p "Get-Module -ListAvailable"

# Check PowerShell availability
./scripts/psctl.sh --check

โš ๏ธ Notes

  1. Permissions: Some operations require administrator privileges

    # Start elevated PowerShell
    ./scripts/psctl.sh "Start-Process powershell -Verb RunAs"
  2. Path Escaping: Backslashes \ in Windows paths must be escaped as \\

  3. Execution Policy: Running scripts may require setting execution policy

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  4. Encoding: PowerShell outputs UTF-16 by default, may need conversion

๐Ÿ”’ Security Tips

  • โš ๏ธ Use caution with system-level commands
  • โš ๏ธ Avoid deleting critical system files
  • โš ๏ธ Test commands before executing in production
  • โš ๏ธ Do not execute scripts from untrusted sources

๐Ÿค Contributing

Issues and Pull Requests are welcome!

  1. Fork the project
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

๐Ÿ“„ License

Apache-2.0 License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿค– Agent Integration

Skill Loading Mechanism

OpenClaw automatically scans these directories for skills:

  1. ~/.openclaw/workspace/skills/ - Main workspace skills
  2. ./skills/ - Skills in current working directory

Skill Activation

After installation, restart OpenClaw session and the skill will auto-load. Agents can:

  1. Call script directly:

    ~/.openclaw/workspace/skills/wsl-powershell/scripts/psctl.sh "PowerShell command"
  2. Learn from skill description:

    • Agent reads SKILL.md to understand skill capabilities
    • Automatically uses this skill based on user requests
  3. Example scenarios:

    • "Check Windows Update policy"
    • "List Windows processes"
    • "Get system information"

๐Ÿ“ฎ Project Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages