Skip to content

PowerShell

PowerShell Github

PowerShell Documentation

安装

MacOS

bash
# 安装
brew install --cask powershell
# 更新
brew update
brew upgrade powershell --cask
# 卸载
brew uninstall --cask powershell

常用操作

bash
# 因为在此系统上禁止运行脚本。
# 查看当前执行策略
get-executionpolicy
# 修改策略
set-executionpolicy RemoteSigned
set-executionpolicy Unrestricted

软连接

参数顺序跟 Linux 相反,即现软连接名,后源文件/目录

bash
# 创建文件链接
mklink D:\test.txt D:\App\test.txt
# 创建目录链接
mklink /d E:\App\Webapp\8080\resources E:\App\Webapp\www\resources
# 删除软连接
rd E:\App\Webapp\8080\resources

防火墙

bash
# 配置防火墙出入站规则
netsh advfirewall firewall add rule name=WSL dir=in action=allow protocol=TCP localport=22
netsh advfirewall firewall add rule name=MySQL dir=in action=allow protocol=TCP localport=3306
netsh advfirewall firewall add rule name=RabbitMQ dir=in action=allow protocol=TCP localport=5672
netsh advfirewall firewall add rule name=RabbitMQ dir=in action=allow protocol=TCP localport=15672
netsh advfirewall firewall add rule name=Redis dir=in action=allow protocol=TCP localport=6379
# 配置端口转发规则
# 把物理机端口2222指向[IP]的端口[PORT]
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=2222 connectaddress=[IP] connectport=[PORT]