本次使用为powershell7版本
命令不分大小写,官方标准为单词首字母大写
powershell中也可以使用部分linux命令
get-host 查看powershell版本信息
New-Item test.txt [-File] 新建文件,-file可以省略
New-Item test -Type Directory 创建文件夹
mkdir test\demo 新建文件夹及其子文件夹,此命令为linux命令
Set-Content .\demo1.txt -Value “hello world” 给文件插入内容,原有内容会被覆盖
Add-Content .\demo1.txt -Value “hello worrld” 追加文件内容
Get-Content .\demo1.txt 查看文件内容
cat .\demo1.txt 查看文件内容,此命令为linux命令
Remove-Item .\demo2.txt 删除文件
rm -r .\demo2.txt 删除文件和它的子文件,此命令为linux命令
Get-ExecutionPolicy 查看powershell执行策略
Set-ExecutionPolicy Unrestricted 设置powershell执行策略
Restricted 为脚本不能运行,是默认设置
Unrestricted 为允许所有的脚本运行
RemoteSigned 为只能运行本地创建的脚本,不能运行从网上下载的脚本,除了有数字签名证书
Allsigned 为只运行有受信任的发布者签名的脚本
clear 清屏
cls 清屏