powershell中给命令定义一个别名该怎么做

2025-03-07 04:05:21
推荐回答(1个)
回答1:

以下是PowerShell官方帮助文件的内容,描述得很清楚了.

示例 1

C:\PS>new-alias list get-childitem
说明
-----------
此命令创建名为“list”的别名,以表示 Get-ChildItem cmdlet。

示例 2

C:\PS>new-alias -name w -value get-wmiobject -description "quick wmi alias" -option ReadOnly

C:\PS> get-alias -name w | format-list *
说明
-----------
此命令创建名为“w”的别名,以表示 Get-WMIObject cmdlet。它为别名创建说明“quick wmi alias”,并使其为只读。该命令的最后一行使用 Get-Alias 获取新别名,并通过管道将它传递给 Format-List 以显示它的所有相关信息。