TOC

PowerShell 在 Ubuntu 下的安装和试用

PowerShell 的最近的一次更新修复了其作为 SSH 的登录 Shell 的一些问题。
Win 10 对 NFS,SSH 的支持推进也是有目共睹。
随着 MS 对 Windows 的策略调整,估计以后 Windows 服务器也会变多。

# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of products
sudo apt-get update

# Enable the "universe" repositories
sudo add-apt-repository universe

# Install PowerShell
sudo apt-get install -y powershell

# Start PowerShell
pwsh

PS 常用命令

# 获取本地 IP
(invoke-webrequest -uri "http://ifconfig.me/ip").content

get-nettcpconnection | where-object {$_.State -eq "Listen"}
get-nettcpconnection -localport 49667
get-process -id (get-nettcpconnection -localport 49667).owningprocess
stop-process -id (get-nettcpconnection -localport 11).owningprocess

"# README" | out-file README.md
type README.md