powershell 什么 命令

2025-03-13 14:17:04125 次浏览

最佳答案

关于PowerShell命令的一些基本知识

•PowerShell的命令叫做cmdlet

•具有一致的命名规范,都采用动词-名词形式,如New-Item

•动词部分一般为Add、New、Get、Remove、Set等

•命令的别名一般兼容Windows

Command以及Linux

Shell,如Get-ChildItem命令使用dir或ls均可

•PowerShell

命令产生的结果都是DLR对象

•PowerShell命令不区分大小写

以文件操作为例讲解PowerShell命令的基本用法

•新建目录

New-Item

b2

-ItemType

Directory

•新建文件

New-Item

a.txt

-ItemType

File

•删除目录

Remove-Item

b2

•递归列pre开头的文件或目录,只列出名称

Get-ChildItem

-Recurse

-Name

-Filter

"pre*“

•显示文本内容

Get-Content

a.txt

•设置文本内容

Set-Content

a.txt

-Value

"content1“

•追加内容

Add-Content

a.txt

-Value

“content2“

•清除内容

Clear-Content

a.txt

声明:知趣百科所有作品均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请在页面底部查找“联系我们”的链接,并通过该渠道与我们取得联系以便进一步处理。