SuperAPI AI Directory

powershell-basic

General & other

View repository

Updated 10-16 00:04

About this skill

PowerShell Basics

Perform Windows system operations via PowerShell.

Use Cases

  • Need to obtain Windows system information (disk, memory, processes)
  • Need batch file operations
  • Need to manage system services or processes
  • Called internally by other Skills

Command Reference

System Information

# 系统概览
Get-ComputerInfo | Select-Object OsName, OsVersion, CsTotalPhysicalMemory
Disk Space

Get-PSDrive -PSProvider FileSystem | Select-Object Name, @{N='Free(GB)';E={[math]::Round($.Free/1GB,1)}}, @{N='Used(GB)';E={[math]::Round($.Used/1GB,1)}}

Memory Usage

Get-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 10 Name, @{N='Memory(MB)';E={[math]::Round($_.WorkingSet64/1MB,1)}}

Battery Status

Get-WmiObject Win32_Battery | Select-Object EstimatedChargeRemaining, BatteryStatus

Wi-Fi Information

netsh wlan show interfaces | Select-String "SSID|Signal"


### 文件操作

```powershell
# 搜索文件
Get-ChildItem -Path "$env:USERPROFILE\Documents" -Recurse -Filter "*.pdf" | Select-Object Name, FullName, Length, LastWriteTime

# 按大小排序
Get-ChildItem -Path . -Recurse -File | Sort-Object Length -Descending | Select-Object -First 20 Name, @{N='Size(MB)';E={[math]::Round($_.Length/1MB,2)}}, FullName

# 最近修改的文件
Get-ChildItem -Path "$env:USERPROFILE" -Recurse -File | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) } | Sort-Object LastWriteTime -Descending | Select-Object -First 20

# 批量重命名
Get-ChildItem -Path . -Filter "*.txt" | Rename-Item -NewName { $_.Name -replace '旧名', '新名' }

Process Management

# 列出进程
Get-Process | Sort-Object CPU -Descending | Select-Object -First 15 Name, Id, CPU, @{N='Memory(MB)';E={[math]::Round($_.WorkingSet64/1MB,1)}}

# 查找进程
Get-Process -Name "*chrome*"

# 已安装应用
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher | Sort-Object DisplayName

Network

# 测试连通性
Test-NetConnection -ComputerName google.com -Port 443

# 公网 IP
(Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing).Content

Security Rules

  • Do not execute administrator commands: Do not use Run as Administrator
  • Do not modify the registry: Do not operate on system registries such as HKLM
  • Do not operate on system services: Do not Start/Stop system services
  • Deletion operations must be confirmed by HITL