Skip to content

基本用法

查看版本

$host

$PSVersionTable

查看操作系统版本

systeminfo

[Environment]::OSVersion

查看当前用户

whoami

$env:USERNAME

查看当前路径

$PWD

查看当前目录文件列表

Get-ChildItem

操作

新建文件夹

New-Item -ItemType Directory -Path test

进入文件夹

Set-Location test

新建文件并输入内容

New-Item -ItemType File -Path a.txt

'Hello World' | Out-File a.txt

'Hello Human' | Out-File a.txt -Append

Get-Content a.txt

'Hello World' | Out-File b.txt

'Hello Human' | Out-File b.txt

Get-Content b.txt

Get-Content *.txt

复制文件

Copy-Item a.txt c.txt

移动文件

Move-Item b.txt d.txt

查看文件数量

Get-ChildItem | Measure-Object

删除文件、删除文件夹

Remove-Item a.txt

Set-Location ..

Remove-Item test -Recurse

退出

exit

联系 math@baima.site