PowerShell是微软公司开发的一种基于任务和命令的脚本语言及相应的开发工具。它可跨平台运行,在Windows操作系统上是强大且广泛使用的命令行工具。本文将介绍PowerShell常用命令,包括文件和目录管理、进程控制、网络管理等。
一、文件和目录管理
1、新建目录
mkdir C:TestDirectory
2、删除目录
rmdir C:TestDirectory
3、复制文件
Copy-Item -Path "C:TestFile.txt" -Destination "C:Destination"
4、移动文件
Move-Item -Path "C:TestFile.txt" -Destination "C:Destination"
5、删除文件
rm C:TestFile.txt
二、进程控制
1、查看进程
Get-Process
2、结束进程
Stop-Process -Name "chrome"
3、启动程序
start-process "notepad.exe"
三、网络管理
1、查看本地IP地址
Get-NetIPAddress | Where-Object -FilterScript { $_.AddressFamily -eq 'IPv4' } | Select-Object -ExpandProperty IPAddress
2、查看本地连接
Get-NetAdapter
3、查看网络路由
Get-NetRoute
四、其他常用命令
1、运行其他脚本
.OtherScript.ps1
2、查看帮助文档
Get-Help
3、查看当前路径
Get-Location
4、设置别名
Set-Alias -Name np -Value notepad.exe
以上是PowerShell常用命令的简单总结,包括文件和目录管理、进程控制、网络管理等。随着使用PowerShell的不断深入,掌握更多常用命令可以提高工作效率。