Set-Alias [-Name] <string> [-Value] <string> [-Description <string>] [-Option <ScopedItemOptions>] [-PassThru] [-Scope <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]说明cmdlet Set-Alias 创建或更改 cmd
1. 这会在记事本中打开配置文件,之后你可以添加你的 Set-Alias 命令。例如: Set-Alias ll Get-ChildItem Set-Alias gs Get-Content Set-Alias dc docker-compose 1. 2. 3. 保存并关闭记事本。 PS: 为了避免类似的问题,建议你: 确保正确的文件编码:保存配置文件时,请选择 UTF-8 编码(在记事本中可以通过...
# 查看变量的方法: Get-Variable Profile #查看这个文件是否存在方法:(F表示不存在) Test-Path $profile #创建这个路径的方法:(创建后上条命令执行结果为T) New-Item -Type file -Force $profile #向此文件追加内容 以ll命令别名为例(也可以打开文件直接输入) Add-Content $Profile 'Set-Alias ll ls' 命令...
Remove-Aliasgpv-Force# 强制移除gpv这个alias,必须写到配置文件里,否则打开新的powersell又会加载默认配置 最新版去这找[1:1],FileList->aliases.ps1。 下面是我常用的alias,刚好没有和powershell默认的alias冲突。 [更新内容] Remove-Aliasgp-Force# common usefunctioncl{clear}# root aliasfunctioncdc{cdD:\Da...
1 首先,创建Alias需要借助启动profile文件(类似linux bashrc文件),创建方式见经验引用。2 创建profile文件之后,右键编辑,自动用windows自带编辑器打开。3 在powershell中,Set-Alias只能对单个对象进行缩写。如果要所写的命令是带参数的,可以先封装成函数。如图,先创建function,在用Set-Alias设置别名。4 在ISE中...
export-alias -path a.txt import-alias -path a.txt (注意导入的时候, 只需要添加自己常用的alias,系统自带的需要删除,不然会报错) 方法二: 使用powershell 配置文件 a. 创建一个配置文件 $profile="D:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1″ 包含: set-alias marui...
使用Remove-Item alias命令删除已设定的别名。 如删除别名ls: PS C:\> Remove-Item alias:ls 创建永久的别名 在PowerShell中直接使用Set-Alias或New-Alias命令创建的别名在关闭此Session后即会失效,防止此现象的方法是将此命令写入Windows PowerShell profile文件。
使用效果: 参考: Set-Alias (Microsoft.PowerShell.Utility) - PowerShelllearn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-7.3编辑于 2023-04-02 16:40・江西 PowerShell 命令提示符 (cmd) Microsoft Windows ...
如果你想为自己的 Windows PowerShell 设置永久的命令别名 (Alias),可以遵循以下步骤: 打开PowerShell ,运行 echo $profile,会输出一个文件路径。创建这个文件。 打开刚创建的文件,按以下格式设置多条别名: function 别名 { 需要替代的命令,可以包含空格 } 以管理员身份打开 PowerShell,执行 Set-ExecutionPolicy Remot...
CommandType Name --- --- Alias gci -> Get-ChildItem 若要创建别名,请使用Set-Alias命令。 可以为 cmdlet、函数、脚本和本机可执行文件文件创建别名。 PowerShell Set-Alias-Namenp-ValueNotepad.exeSet-Alias-Namecmpo-ValueCompare-Object Windows 中的兼容...