Windows 命令速查
用 winget 装机
Section titled “用 winget 装机”Windows 11 自带 winget,不需要额外装包管理器。先搜索确认包 ID,再按 ID 安装,避免装错同名软件。
winget search "Visual Studio Code"winget install --id Microsoft.PowerShell --source wingetwinget install --id Git.Git --source winget批量装机把 ID 列成清单,一次跑完:
'Microsoft.PowerShell', 'Git.Git', 'Microsoft.VisualStudioCode' | ForEach-Object { winget install --id $_ --source winget --accept-package-agreements }升级已安装的软件
Section titled “升级已安装的软件”# List what has updates availablewinget upgrade
# Upgrade everything at oncewinget upgrade --all --include-unknownPowerShell 执行策略
Section titled “PowerShell 执行策略”默认策略会拦下本地脚本。按当前用户放开即可,不要动系统级策略。
Get-ExecutionPolicy -ListSet-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned网络与端口排查
Section titled “网络与端口排查”# Which process holds port 4321Get-NetTCPConnection -LocalPort 4321 -State Listen | Select-Object OwningProcessGet-Process -Id <PID>
# Flush the DNS cacheClear-DnsClientCache
# Trace the route to a hostTest-NetConnection 1.1.1.1 -TraceRoutesetx 写入的是持久化环境变量,当前窗口不会立即生效,需要新开一个终端。
# Persist for the current usersetx EDITOR "code --wait"
# Read it back[Environment]::GetEnvironmentVariable('EDITOR', 'User')