跳到正文
cccskills
免费在 GitHub 公开

windows-powershell

Windows 11 system administration with PowerShell — system info reporting, hardware monitoring, package management (winget/scoop), disk cleanup, performance optimization, environment configuration, PowerShell profile setup with aliases and autocomplete, and Task Scheduler automation. Use when user asks to check system info, install tools on Windows, clean up disk space, set up PowerShell profile, or automate Windows tasks. Do NOT use for Linux administration, cross-platform scripting, or network infrastructure management.

中文简介正在准备中。当前显示原文说明。

集成工具Docker
查看安装方法

包含的文件(6)

  • SKILL.md9.1 KB
  • assets/Microsoft.PowerShell_profile.ps18.5 KB
  • references/powershell-mastery.md8.3 KB
  • scripts/cleanup-system.ps15.4 KB
  • scripts/install-tools.ps13.4 KB
  • scripts/system-info.ps13.8 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Windows PowerShell

Windows 11 system administration and automation with PowerShell 7.

Workflow

Step 1: System health check

scripts/system-info.ps1

Outputs:

  • OS: Windows 11 build, edition, install date
  • CPU: Model, cores, current usage %
  • RAM: Total, used, free, usage %
  • Disk: Per drive: total, used, free, usage %
  • Top 5 processes by memory usage
  • Network: Adapters, IP addresses
  • Uptime: Days since last restart
  • Windows Updates: Pending update count

If RAM usage > 80% or disk usage > 90%: proceed to Step 2.

Step 2: System cleanup

# Preview what would be cleaned
scripts/cleanup-system.ps1 -DryRun

# Clean everything
scripts/cleanup-system.ps1

Cleans:

  • Windows temporary files
  • Recycle Bin
  • Windows Update cache
  • npm/yarn/pnpm cache
  • Docker unused data
  • Windows.old (if present)
  • Prefetch files

Reports total space recovered.

Step 3: Install development tools

# Install everything
scripts/install-tools.ps1

# Install specific categories only
scripts/install-tools.ps1 -Scope dev  # Git, Node, Python, VS Code
scripts/install-tools.ps1 -Scope tools  # 7-Zip, Windows Terminal, Oh My Posh

The script checks if each tool is already installed before attempting. Uses winget as primary, falls back to scoop.

Step 4: Set up PowerShell profile

Copy the premium profile template:

# Install the premium profile
Copy-Item "~\\.config\\opencode\\skills\\windows-powershell\\assets\\Microsoft.PowerShell_profile.ps1" $PROFILE

# Reload profile
. $PROFILE

The profile includes:

  • Oh My Posh prompt with git status
  • PSReadLine with autocomplete and syntax highlighting
  • Git aliases: gst (status), ga (add), gc (commit), gp (push), gl (pull), gb (branch)
  • npm aliases: ni (install), nrd (run dev), nrb (run build), nt (test)
  • Docker aliases: dps (ps), dlog (logs), dstop (stop), drm (rm)
  • Utils: touch, which, ll (ls -la), mkcd (mkdir + cd), admin (runas admin)

Step 5: Schedule recurring maintenance

# Weekly cleanup every Sunday at 9 PM
schtasks /Create /SC WEEKLY /D SUN /TN "SystemCleanup" /TR "powershell.exe -File '~\\.config\\opencode\\skills\\windows-powershell\\scripts\\cleanup-system.ps1'" /ST 21:00 /RL HIGHEST

Windows Utilities Reference

See references/powershell-mastery.md for complete reference.

TaskCommand
Find large files`Get-ChildItem -Recurse
Kill process by port`Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess
Check disk health`Get-PhysicalDisk
Export installed programs`Get-Package
Check battery healthpowercfg /batteryreport
Network speed testInvoke-WebRequest -Uri "http://speedtest.url"
Windows activation statusslmgr /xpr

Error Handling

ScenarioCauseFix
winget not foundOutdated Windows or missing App InstallerInstall from Microsoft Store or use scoop
Script execution blockedPowerShell execution policySet-ExecutionPolicy RemoteSigned -Scope CurrentUser
Permission denied running scriptNot admin for system operationsRun admin (from profile) or Start-Process powershell -Verb RunAs
Cleanup shows 0 bytesNo temp files to cleanThat's fine. Run again in a week.
Tool installation failswinget source out of datewinget source update

Production Checklist

  • PowerShell 7 installed ($PSVersionTable.PSVersion)
  • Execution policy set to RemoteSigned
  • PowerShell profile installed with aliases
  • Dev tools installed via winget/scoop
  • Weekly cleanup scheduled
  • System info script run monthly
  • Battery report generated (laptops)
  • Windows Updates checked

Anti-Patterns

Anti-patternFix
Installing tools manually every timeUse winget/scoop with install-tools script
Ignoring temp file buildupSchedule weekly cleanup
Default PowerShell promptCustomize with Oh My Posh
No aliases for common commandsUse the profile template
Running without admin when neededUse admin alias for elevated commands

Advanced Patterns

Desired State Configuration (DSC)

Configuration WebServer {
    Import-DscResource -ModuleName PSDesiredStateConfiguration
    Node "localhost" {
        WindowsFeature IIS { Name = "Web-Server"; Ensure = "Present" }
        File WebContent {
            Ensure = "Present"
            SourcePath = "C:\inetpub\wwwroot"
            DestinationPath = "C:\inetpub\wwwroot"
            DependsOn = "[WindowsFeature]IIS"
        }
    }
}
WebServer -OutputPath C:\DSC
Start-DscConfiguration -Path C:\DSC -Wait -Verbose

Just Enough Administration (JEA)

# Create a restricted endpoint that only allows Get-Service + Restart-Service
New-PSSessionConfigurationFile -Path .\HelpDesk.pssc -SessionType RestrictedRemoteServer `
    -VisibleCmdlets @{ Name = 'Get-Service'; Parameters = @{ Name = 'Name' }},
                    @{ Name = 'Restart-Service'; Parameters = @{ Name = 'Name' }}
Register-PSSessionConfiguration -Name HelpDesk -Path .\HelpDesk.pssc -Force

PSRemoting

# Enable on target machine (admin)
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.100"

# Connect from source
$session = New-PSSession -ComputerName 192.168.1.100 -Credential (Get-Credential)
Invoke-Command -Session $session -ScriptBlock { Get-Process }
Remove-PSSession $session

Script Signing

# Generate self-signed certificate
$cert = New-SelfSignedCertificate -Subject "CN=PowerShell Code Signing" -Type CodeSigningCert -CertStoreLocation Cert:\CurrentUser\My

# Sign a script
Set-AuthenticodeSignature -FilePath .\script.ps1 -Certificate $cert

# Verify
Get-AuthenticodeSignature .\script.ps1

# Enforce in session
Set-ExecutionPolicy AllSigned -Scope Process

Module Manifests

New-ModuleManifest -Path .\MyModule.psd1 -RootModule MyModule.psm1 -Author "YourName" `
    -CompanyName "Company" -Description "Module description" -PowerShellVersion "5.1" `
    -FunctionsToExport @("Get-Data","Set-Data") -RequiredModules @("Az","SqlServer")

Error Handling Patterns

# Pattern 1: Try/Catch/Finally with resource cleanup
try {
    $conn = New-Object System.Data.SqlClient.SqlConnection($connString)
    $conn.Open()
    # Work
} catch [System.Data.SqlClient.SqlException] {
    Write-Error "Database error: $_"
} catch {
    Write-Error "Unexpected: $_"
} finally {
    if ($conn) { $conn.Dispose() }
}

# Pattern 2: -ErrorAction with $ErrorActionPreference
Get-ChildItem -Path $path -ErrorAction Stop
# or globally
$ErrorActionPreference = "Stop"

# Pattern 3: $LASTEXITCODE for native commands
& python script.py
if ($LASTEXITCODE -ne 0) {
    throw "Python script failed with exit code $LASTEXITCODE"
}

# Pattern 4: $? for PowerShell commands
Get-Item $path -ErrorAction SilentlyContinue
if (-not $?) {
    Write-Warning "Path not found, using default"
}

Related Scripts

  • ~/.shokunin/scripts/scan-cleanup.ps1 — Scans Downloads, Desktop, and Temp for files to classify (keep/review/trash) and optionally clean

Sources

  • Microsoft PowerShell docs (learn.microsoft.com/powershell)
  • Oh My Posh docs (ohmyposh.dev)
  • PSReadLine docs (learn.microsoft.com)
  • Windows Package Manager (winget) docs
  • Scoop package manager (scoop.sh)
  • SS64 PowerShell commands reference

Checklist

  • Skill loads without errors in the AI agent
  • YAML frontmatter is valid (description, compatibility, audience)
  • Workflow section provides clear step-by-step instructions
  • Error handling section covers common failure modes
  • All referenced files (references/, scripts/, assets/) exist
  • Skill triggers correctly for intended use cases
  • No broken links or missing resources

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Apply professional, premium UI/UX design standards when building or styling web interfaces. Use this skill when the user asks to create a website, landing page, web app, dashboard, UI component, or any visual interface — or when they ask to make something look better, more professional, or more beautiful. Covers visual hierarchy, typography, color systems, layout, spacing, motion, dark mode, responsive design, and conversion patterns. Activate even when the user doesn't say "design" — if they're building a web frontend, these standards apply.

中文简介正在准备中。当前显示原文说明。

EliasOulkadi/shokunin1132026年10月5日 更新

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

中文简介正在准备中。当前显示原文说明。

EliasOulkadi/shokunin1132026年10月5日 更新

Run 150+ AI apps via inference.sh CLI - image generation, video creation, LLMs, search, 3D, Twitter automation. Models: FLUX, Veo, Gemini, Grok, Claude, Seedance, OmniHuman, Tavily, Exa, OpenRouter, and many more. Use when running AI apps, generating images/videos, calling LLMs, web search, or automating Twitter. Triggers: inference.sh, infsh, ai model, run ai, serverless ai, ai api, flux, veo, claude api, image generation, video generation, openrouter, tavily, exa search, twitter api, grok

中文简介正在准备中。当前显示原文说明。

EliasOulkadi/shokunin1132026年10月5日 更新

api-forge

免费

Design REST/GraphQL APIs with OpenAPI 3.1, error handling, pagination, rate limiting, webhooks, and idempotency. Use when user asks to design an API, create endpoints, define REST/GraphQL schema, or generate OpenAPI spec. Do NOT use for database schema design, frontend API integration, or non-HTTP protocols (gRPC, WebSocket, MQTT).

中文简介正在准备中。当前显示原文说明。

EliasOulkadi/shokunin1132026年10月5日 更新

Implement authentication and authorization with OWASP Top 10 standards, OAuth 2.0 + OIDC, WebAuthn/Passkeys, session management, and RBAC/ABAC. Use when user asks to implement login, signup, authentication, authorization, JWT, OAuth, SSO, passkeys, MFA, or role-based access. Do NOT use for API key management (use api-forge), encryption at rest, or network-level security (firewalls, WAF).

中文简介正在准备中。当前显示原文说明。

EliasOulkadi/shokunin1132026年10月5日 更新

Generate brand guidelines, design systems with design tokens (W3C format), creative direction (SCAMPER, Design Thinking, TRIZ), and design briefs with scope and success criteria.

中文简介正在准备中。当前显示原文说明。

EliasOulkadi/shokunin1132026年10月5日 更新

查看 EliasOulkadi 的全部技能

报告此技能的问题