{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 1909-powershell-alias" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## overview" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- overview of alias on powershell" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## jupyter notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- https://nbviewer.jupyter.org/github/sakai-memoru/pwshnote/blob/master/1909-powershell-alias.ipynb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## contents" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Basic" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Path \n", "---- \n", "G:\\workspace\\pwshnote\n", "\n", "\n" ] } ], "source": [ "pwd" ] }, { "cell_type": "code", "execution_count": 122, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dir | set -Name dirs\n", "$dirs[0..10] + \"`r`n and more ....\"\n", "\n", "\n", " Directory: G:\\workspace\\pwshnote\n", "\n", "\n", "Mode LastWriteTime Length Name \n", "---- ------------- ------ ---- \n", "d----- 02/09/2019 08:26 .ipynb_checkpoints \n", "d----- 01/09/2019 17:52 data \n", "d----- 01/09/2019 06:11 temp \n", "-a---- 02/09/2019 09:36 231 .gitignore \n", "-a---- 29/07/2019 21:02 20614 1907-keylogger-sample.ipynb \n", "-a---- 01/09/2019 11:34 27941 1908-powershell-about-operators.ipynb \n", "-a---- 01/09/2019 11:21 63452 1908-powershell-about_types.ipynb \n", "-a---- 16/08/2019 19:11 5757 1908-powershell-alias-grep.ipynb \n", "-a---- 27/08/2019 12:33 36948 1908-powershell-array.ipynb \n", "-a---- 31/08/2019 11:59 25028 1908-powershell-datetime.ipynb \n", "-a---- 22/08/2019 12:20 38156 1908-powershell-format-list-all.ipynb \n", "\n", " and more ....\n", "\n", "\n", "\n" ] } ], "source": [ "dir | set -Name dirs\n", "$dirs[0..10] + \"`r`n and more ....\"" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", " Directory: G:\\workspace\\pwshnote\n", "\n", "\n", "Mode LastWriteTime Length Name \n", "---- ------------- ------ ---- \n", "-a---- 07/05/2019 16:05 337989 index.html \n", "-a---- 16/08/2019 19:13 871 index.md \n", "\n", "\n" ] } ], "source": [ "ls index.*" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "# pwshnote\n", "## overview\n", "- a repository for powershell jupyter notebook\n", "- To try a powershell script on jupyter notebook\n", "- GitHub Page\n", " + https://sakai-memoru.github.io/pwshnote/\n", "// -- end of README.md\n" ] } ], "source": [ "cat README.md" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "### vim\n", "\n", "# Swap\n", "[._]*.s[a-v][a-z]\n", "[._]*.sw[a-p]\n", "[._]s[a-v][a-z]\n", "[._]sw[a-p]\n", "\n", "# Session\n", "Session.vim\n", "\n", "# Temporary\n", ".netrwhist\n", "*~\n", "# Auto-generated tag files\n", "tags\n", "# Persistent undo\n", "[._]*.un~\n", "\n", "\n" ] } ], "source": [ "type .gitignore" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get-Help" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "NAME\n", " Get-Alias\n", " \n", "SYNOPSIS\n", " Gets the aliases for the current session.\n", " \n", " \n", "SYNTAX\n", " Get-Alias [-Definition ] [-Exclude ] [-Scope ] []\n", " \n", " Get-Alias [[-Name] ] [-Exclude ] [-Scope ] []\n", " \n", " \n", "DESCRIPTION\n", " The Get-Alias cmdlet gets the aliases in the current session. This includes built-in aliases, aliases that you \n", " have set or imported, and aliases that you have added to your Windows PowerShell profile.\n", " \n", " By default, Get-Alias takes an alias and returns the command name. When you use the Definition parameter, \n", " Get-Alias takes a command name and returns its aliases.\n", " \n", " Beginning in Windows PowerShell 3.0, Get-Alias displays non-hyphenated alias names in an -> \n", " format to make it even easier to find the information that you need.\n", " \n", "\n", "RELATED LINKS\n", " Online Version: http://go.microsoft.com/fwlink/?LinkId=821778\n", " About Aliases \n", " Export-Alias \n", " Import-Alias \n", " New-Alias \n", " Set-Alias \n", "\n", "REMARKS\n", " To see the examples, type: \"get-help Get-Alias -examples\".\n", " For more information, type: \"get-help Get-Alias -detailed\".\n", " For technical information, type: \"get-help Get-Alias -full\".\n", " For online help, type: \"get-help Get-Alias -online\"\n", "\n", "\n" ] } ], "source": [ "Get-Help Get-Alias" ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "$store[0..15] + \"`r`n and more ....\"\n", "TOPIC\n", " about_aliases\n", "\n", "SHORT DESCRIPTION\n", " Describes how to use alternate names for cmdlets and commands in Windows\n", " PowerShell. \n", "\n", "LONG DESCRIPTION\n", " An alias is an alternate name or nickname for a cmdlet or for a command\n", " element, such as a function, script, file, or executable file. You\n", " can use the alias instead of the command name in any Windows PowerShell\n", " commands.\n", " \n", " To create an alias, use the New-Alias cmdlet. For example, the following\n", " command creates the \"gas\" alias for the Get-AuthenticodeSignature cmdlet:\n", "\n", "\n", " and more ....\n", "\n", "\n", "Help about_alias | set -Name store\n" ] } ], "source": [ "Help about_alias | set -Name store\n", "$store[0..15] + \"`r`n and more ....\"\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get-Commands" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "CommandType Name Version Source \n", "----------- ---- ------- ------ \n", "Cmdlet Export-Alias 3.1.0.0 Microsoft.PowerShell.Utility \n", "Cmdlet Get-Alias 3.1.0.0 Microsoft.PowerShell.Utility \n", "Cmdlet Import-Alias 3.1.0.0 Microsoft.PowerShell.Utility \n", "Cmdlet New-Alias 3.1.0.0 Microsoft.PowerShell.Utility \n", "Cmdlet Set-Alias 3.1.0.0 Microsoft.PowerShell.Utility \n", "\n", "\n" ] } ], "source": [ "Get-Command -Noun Alias" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Alias" ] }, { "cell_type": "code", "execution_count": 114, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Get-Alias | set -Name ary\n", "$ary[0..15] + \"`r`n and more ....\"\n", "\n", "CommandType Name Version Source \n", "----------- ---- ------- ------ \n", "Alias % -> ForEach-Object \n", "Alias ? -> Where-Object \n", "Alias ac -> Add-Content \n", "Alias asnp -> Add-PSSnapin \n", "Alias cat -> Get-Content \n", "Alias cd -> Set-Location \n", "Alias CFS -> ConvertFrom-String 3.1.0.0 Microsoft.PowerShell.Utility \n", "Alias chdir -> Set-Location \n", "Alias clc -> Clear-Content \n", "Alias clear -> Clear-Host \n", "Alias clhy -> Clear-History \n", "Alias cli -> Clear-Item \n", "Alias clp -> Clear-ItemProperty \n", "Alias cls -> Clear-Host \n", "Alias clv -> Clear-Variable \n", "Alias cnsn -> Connect-PSSession \n", "\n", " and more ....\n", "\n", "\n", "\n", "\n" ] } ], "source": [ "Get-Alias | set -Name ary\n", "$ary[0..15] + \"`r`n and more ....\"\n" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Alias ac -> Add-Content \n", "Alias cat -> Get-Content \n", "Alias clc -> Clear-Content \n", "Alias gc -> Get-Content \n", "Alias sc -> Set-Content \n", "Alias type -> Get-Content \n", "\n", "\n" ] } ], "source": [ "Get-Alias | Out-String -Stream | select-string 'Content'" ] }, { "cell_type": "code", "execution_count": 94, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Alias gps -> Get-Process \n", "Alias kill -> Stop-Process \n", "Alias ps -> Get-Process \n", "Alias saps -> Start-Process \n", "Alias spps -> Stop-Process \n", "Alias start -> Start-Process \n", "\n", "\n" ] } ], "source": [ "Get-Alias | Out-String -Stream | sls 'process'" ] }, { "cell_type": "code", "execution_count": 81, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "CommandType Name Version Source \n", "----------- ---- ------- ------ \n", "Alias cli -> Clear-Item \n", "Alias copy -> Copy-Item \n", "Alias cp -> Copy-Item \n", "Alias cpi -> Copy-Item \n", "Alias del -> Remove-Item \n", "Alias dir -> Get-ChildItem \n", "Alias erase -> Remove-Item \n", "Alias gci -> Get-ChildItem \n", "Alias gi -> Get-Item \n", "Alias ii -> Invoke-Item \n", "Alias ls -> Get-ChildItem \n", "Alias mi -> Move-Item \n", "Alias move -> Move-Item \n", "Alias mv -> Move-Item \n", "Alias ni -> New-Item \n", "Alias rd -> Remove-Item \n", "Alias ren -> Rename-Item \n", "Alias ri -> Remove-Item \n", "Alias rm -> Remove-Item \n", "Alias rmdir -> Remove-Item \n", "Alias rni -> Rename-Item \n", "Alias si -> Set-Item \n", "\n", "\n" ] } ], "source": [ "Get-Alias -Definition '*Item'" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "HelpUri : https://go.microsoft.com/fwlink/?LinkID=113310\n", "ResolvedCommandName : Get-Content\n", "DisplayName : cat -> Get-Content\n", "ReferencedCommand : Get-Content\n", "ResolvedCommand : Get-Content\n", "Definition : Get-Content\n", "Options : AllScope\n", "Description : \n", "OutputType : {System.Byte, System.String}\n", "Name : cat\n", "CommandType : Alias\n", "Source : \n", "Version : \n", "Visibility : Public\n", "ModuleName : \n", "Module : \n", "RemotingCapability : PowerShell\n", "Parameters : {[ReadCount, System.Management.Automation.ParameterMetadata], [TotalCount, \n", " System.Management.Automation.ParameterMetadata], [Tail, \n", " System.Management.Automation.ParameterMetadata], [Path, \n", " System.Management.Automation.ParameterMetadata]...}\n", "ParameterSets : \n", "\n", "\n", "\n" ] } ], "source": [ "Get-Alias | Where-Object {$_.Name -eq 'cat'} | Format-List *" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Add-Content ac https://go.microsoft.com/fwlink/?LinkID=113278\n", "Clear-Content clc https://go.microsoft.com/fwlink/?LinkID=113282\n", "Get-Content type https://go.microsoft.com/fwlink/?LinkID=113310\n", "Get-Content gc https://go.microsoft.com/fwlink/?LinkID=113310\n", "Get-Content cat https://go.microsoft.com/fwlink/?LinkID=113310\n", "Set-Content sc https://go.microsoft.com/fwlink/?LinkID=113392\n", "\n", "\n" ] } ], "source": [ "Get-Alias | Where-Object {$_.Definition -match 'Content'} | Sort-Object Definition | Format-Table Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Clear-Item cli https://go.microsoft.com/fwlink/?LinkID=113283\n", "Copy-Item cpi https://go.microsoft.com/fwlink/?LinkID=113292\n", "Copy-Item cp https://go.microsoft.com/fwlink/?LinkID=113292\n", "Copy-Item copy https://go.microsoft.com/fwlink/?LinkID=113292\n", "Get-ChildItem gci https://go.microsoft.com/fwlink/?LinkID=113308\n", "Get-ChildItem ls https://go.microsoft.com/fwlink/?LinkID=113308\n", "Get-ChildItem dir https://go.microsoft.com/fwlink/?LinkID=113308\n", "Get-Item gi https://go.microsoft.com/fwlink/?LinkID=113319\n", "Invoke-Item ii https://go.microsoft.com/fwlink/?LinkID=113345\n", "Move-Item mi https://go.microsoft.com/fwlink/?LinkID=113350\n", "Move-Item move https://go.microsoft.com/fwlink/?LinkID=113350\n", "Move-Item mv https://go.microsoft.com/fwlink/?LinkID=113350\n", "New-Item ni https://go.microsoft.com/fwlink/?LinkID=113353\n", "Remove-Item ri https://go.microsoft.com/fwlink/?LinkID=113373\n", "Remove-Item rmdir https://go.microsoft.com/fwlink/?LinkID=113373\n", "Remove-Item rm https://go.microsoft.com/fwlink/?LinkID=113373\n", "Remove-Item del https://go.microsoft.com/fwlink/?LinkID=113373\n", "Remove-Item rd https://go.microsoft.com/fwlink/?LinkID=113373\n", "Remove-Item erase https://go.microsoft.com/fwlink/?LinkID=113373\n", "Rename-Item rni https://go.microsoft.com/fwlink/?LinkID=113382\n", "Rename-Item ren https://go.microsoft.com/fwlink/?LinkID=113382\n", "Set-Item si https://go.microsoft.com/fwlink/?LinkID=113395\n", "\n", "\n" ] } ], "source": [ "Get-Alias | Where-Object {$_.Definition -match 'Item$'} | Sort-Object Definition | Format-Table Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 86, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Get-Location pwd https://go.microsoft.com/fwlink/?LinkID=113321\n", "Get-Location gl https://go.microsoft.com/fwlink/?LinkID=113321\n", "Pop-Location popd https://go.microsoft.com/fwlink/?LinkID=113369\n", "Push-Location pushd https://go.microsoft.com/fwlink/?LinkID=113370\n", "Set-Location sl https://go.microsoft.com/fwlink/?LinkID=113397\n", "Set-Location chdir https://go.microsoft.com/fwlink/?LinkID=113397\n", "Set-Location cd https://go.microsoft.com/fwlink/?LinkID=113397\n", "\n", "\n" ] } ], "source": [ "Get-Alias -Definition '*Location' | Sort-Object Definition | Format-Table Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 91, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Convert-Path cvpa https://go.microsoft.com/fwlink/?LinkID=113289\n", "Resolve-Path rvpa https://go.microsoft.com/fwlink/?LinkID=113384\n", "\n", "\n" ] } ], "source": [ "gal -Def '*Path' | sort Definition | ft Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Compare-Object diff https://go.microsoft.com/fwlink/?LinkID=113286\n", "Compare-Object compare https://go.microsoft.com/fwlink/?LinkID=113286\n", "ForEach-Object foreach https://go.microsoft.com/fwlink/?LinkID=113300\n", "ForEach-Object % https://go.microsoft.com/fwlink/?LinkID=113300\n", "Get-WmiObject gwmi https://go.microsoft.com/fwlink/?LinkID=113337\n", "Group-Object group https://go.microsoft.com/fwlink/?LinkID=113338\n", "Measure-Object measure https://go.microsoft.com/fwlink/?LinkID=113349\n", "Remove-WMIObject rwmi https://go.microsoft.com/fwlink/?LinkID=113381\n", "Select-Object select https://go.microsoft.com/fwlink/?LinkID=113387\n", "Sort-Object sort https://go.microsoft.com/fwlink/?LinkID=113403\n", "Tee-Object tee https://go.microsoft.com/fwlink/?LinkID=113417\n", "Where-Object where https://go.microsoft.com/fwlink/?LinkID=113423\n", "Where-Object ? https://go.microsoft.com/fwlink/?LinkID=113423\n", "\n", "\n" ] } ], "source": [ "Get-Alias | Where {$_.Definition -match 'Object$'} | Sort Definition | Select Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Get-Alias | Where {$_.Definition -match 'Format'} | Sort Definition | Select Definition, Name, HelpUri | format-table *\n", "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Format-Custom fc https://go.microsoft.com/fwlink/?LinkID=113301\n", "Format-Hex fhx https://go.microsoft.com/fwlink/?LinkId=526919\n", "Format-List fl https://go.microsoft.com/fwlink/?LinkID=113302\n", "Format-Table ft https://go.microsoft.com/fwlink/?LinkID=113303\n", "Format-Wide fw https://go.microsoft.com/fwlink/?LinkID=113304\n", "\n", "\n" ] } ], "source": [ "Get-Alias | Where {$_.Definition -match '^Format'} | Sort Definition | Select Definition, Name, HelpUri | format-table *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Frequenctly Using" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "ForEach-Object foreach https://go.microsoft.com/fwlink/?LinkID=113300\n", "ForEach-Object % https://go.microsoft.com/fwlink/?LinkID=113300\n", "Group-Object group https://go.microsoft.com/fwlink/?LinkID=113338\n", "Measure-Object measure https://go.microsoft.com/fwlink/?LinkID=113349\n", "Select-Object select https://go.microsoft.com/fwlink/?LinkID=113387\n", "Sort-Object sort https://go.microsoft.com/fwlink/?LinkID=113403\n", "Tee-Object tee https://go.microsoft.com/fwlink/?LinkID=113417\n", "Where-Object where https://go.microsoft.com/fwlink/?LinkID=113423\n", "Where-Object ? https://go.microsoft.com/fwlink/?LinkID=113423\n", "\n", "\n" ] } ], "source": [ "$ary_for_frequent_use_obj = @(\n", " 'where','?','foreach','%','select','sort', 'group','measure','tee'\n", ")\n", "Get-Alias | Where {$_.Name -in $ary_for_frequent_use_obj} | Sort Definition | Select Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 73, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Clear-Host clear http://technet.microsoft.com/library/hh852689(v=wps.630).aspx\n", "Copy-Item cp https://go.microsoft.com/fwlink/?LinkID=113292 \n", "Copy-Item copy https://go.microsoft.com/fwlink/?LinkID=113292 \n", "Get-ChildItem dir https://go.microsoft.com/fwlink/?LinkID=113308 \n", "Get-ChildItem ls https://go.microsoft.com/fwlink/?LinkID=113308 \n", "Get-Content type https://go.microsoft.com/fwlink/?LinkID=113310 \n", "Get-Content cat https://go.microsoft.com/fwlink/?LinkID=113310 \n", "Get-Location pwd https://go.microsoft.com/fwlink/?LinkID=113321 \n", "help man https://go.microsoft.com/fwlink/?LinkID=113316 \n", "Move-Item move https://go.microsoft.com/fwlink/?LinkID=113350 \n", "Move-Item mv https://go.microsoft.com/fwlink/?LinkID=113350 \n", "Remove-Item rm https://go.microsoft.com/fwlink/?LinkID=113373 \n", "Remove-Item rmdir https://go.microsoft.com/fwlink/?LinkID=113373 \n", "Remove-Item del https://go.microsoft.com/fwlink/?LinkID=113373 \n", "Rename-Item ren https://go.microsoft.com/fwlink/?LinkID=113382 \n", "Set-Location cd https://go.microsoft.com/fwlink/?LinkID=113397 \n", "Set-Location chdir https://go.microsoft.com/fwlink/?LinkID=113397 \n", "Set-Variable set https://go.microsoft.com/fwlink/?LinkID=113401 \n", "Write-Output write https://go.microsoft.com/fwlink/?LinkID=113427 \n", "Write-Output echo https://go.microsoft.com/fwlink/?LinkID=113427 \n", "\n", "\n" ] } ], "source": [ "$ary_for_frequent_cmd = @(\n", " 'man', 'help', 'echo','write','cat','type','pwd','dir','ls','cd','chdir','clear','copy','cp', 'del','move','mv','ren','rm','rmdir', 'del', 'set'\n", ")\n", "Get-Alias | Where {$_.Name -in $ary_for_frequent_cmd} | Sort Definition | Select Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Get-History history https://go.microsoft.com/fwlink/?LinkID=113317\n", "Get-Process ps https://go.microsoft.com/fwlink/?LinkID=113324\n", "Invoke-WebRequest wget https://go.microsoft.com/fwlink/?LinkID=217035\n", "Invoke-WebRequest curl https://go.microsoft.com/fwlink/?LinkID=217035\n", "powershell_ise.exe ise \n", "Start-Sleep sleep https://go.microsoft.com/fwlink/?LinkID=113407\n", "Stop-Process kill https://go.microsoft.com/fwlink/?LinkID=113412\n", "\n", "\n" ] } ], "source": [ "$ary_other = @(\n", " 'ise', 'ps', 'kill','curl','wget','sleep','history'\n", ")\n", "Get-Alias | Where {$_.Name -in $ary_other} | Sort Definition | Select Definition, Name, HelpUri" ] }, { "cell_type": "code", "execution_count": 77, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Definition Name HelpUri \n", "---------- ---- ------- \n", "Format-List fl https://go.microsoft.com/fwlink/?LinkID=113302\n", "Format-Table ft https://go.microsoft.com/fwlink/?LinkID=113303\n", "Get-Alias gal https://go.microsoft.com/fwlink/?LinkID=113306\n", "Get-Member gm https://go.microsoft.com/fwlink/?LinkID=113322\n", "Select-String sls https://go.microsoft.com/fwlink/?LinkID=113388\n", "\n", "\n" ] } ], "source": [ "$ary_other_rare = @(\n", " 'sls', 'fl', 'ft','gm','gal'\n", ")\n", "Get-Alias | Where {$_.Name -in $ary_other_rare} | Sort Definition | Select Definition, Name, HelpUri" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Appendix" ] }, { "cell_type": "code", "execution_count": 116, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "CommandType Name Version Source \n", "----------- ---- ------- ------ \n", "Alias % -> ForEach-Object \n", "Alias ? -> Where-Object \n", "Alias ac -> Add-Content \n", "Alias asnp -> Add-PSSnapin \n", "Alias cat -> Get-Content \n", "Alias cd -> Set-Location \n", "Alias CFS -> ConvertFrom-String 3.1.0.0 Microsoft.PowerShell.Utility \n", "Alias chdir -> Set-Location \n", "Alias clc -> Clear-Content \n", "Alias clear -> Clear-Host \n", "Alias clhy -> Clear-History \n", "Alias cli -> Clear-Item \n", "Alias clp -> Clear-ItemProperty \n", "Alias cls -> Clear-Host \n", "Alias clv -> Clear-Variable \n", "Alias cnsn -> Connect-PSSession \n", "Alias compare -> Compare-Object \n", "Alias copy -> Copy-Item \n", "Alias cp -> Copy-Item \n", "Alias cpi -> Copy-Item \n", "Alias cpp -> Copy-ItemProperty \n", "Alias curl -> Invoke-WebRequest \n", "Alias cvpa -> Convert-Path \n", "Alias dbp -> Disable-PSBreakpoint \n", "Alias del -> Remove-Item \n", "Alias diff -> Compare-Object \n", "Alias dir -> Get-ChildItem \n", "Alias dnsn -> Disconnect-PSSession \n", "Alias ebp -> Enable-PSBreakpoint \n", "Alias echo -> Write-Output \n", "Alias epal -> Export-Alias \n", "Alias epcsv -> Export-Csv \n", "Alias epsn -> Export-PSSession \n", "Alias erase -> Remove-Item \n", "Alias etsn -> Enter-PSSession \n", "Alias exsn -> Exit-PSSession \n", "Alias fc -> Format-Custom \n", "Alias fhx -> Format-Hex 3.1.0.0 Microsoft.PowerShell.Utility \n", "Alias fl -> Format-List \n", "Alias foreach -> ForEach-Object \n", "Alias ft -> Format-Table \n", "Alias fw -> Format-Wide \n", "Alias gal -> Get-Alias \n", "Alias gbp -> Get-PSBreakpoint \n", "Alias gc -> Get-Content \n", "Alias gcb -> Get-Clipboard 3.1.0.0 Microsoft.PowerShell.Management \n", "Alias gci -> Get-ChildItem \n", "Alias gcm -> Get-Command \n", "Alias gcs -> Get-PSCallStack \n", "Alias gdr -> Get-PSDrive \n", "Alias ghy -> Get-History \n", "Alias gi -> Get-Item \n", "Alias gin -> Get-ComputerInfo 3.1.0.0 Microsoft.PowerShell.Management \n", "Alias gjb -> Get-Job \n", "Alias gl -> Get-Location \n", "Alias gm -> Get-Member \n", "Alias gmo -> Get-Module \n", "Alias gp -> Get-ItemProperty \n", "Alias gps -> Get-Process \n", "Alias gpv -> Get-ItemPropertyValue \n", "Alias group -> Group-Object \n", "Alias gsn -> Get-PSSession \n", "Alias gsnp -> Get-PSSnapin \n", "Alias gsv -> Get-Service \n", "Alias gtz -> Get-TimeZone 3.1.0.0 Microsoft.PowerShell.Management \n", "Alias gu -> Get-Unique \n", "Alias gv -> Get-Variable \n", "Alias gwmi -> Get-WmiObject \n", "Alias h -> Get-History \n", "Alias history -> Get-History \n", "Alias icm -> Invoke-Command \n", "Alias iex -> Invoke-Expression \n", "Alias ihy -> Invoke-History \n", "Alias ii -> Invoke-Item \n", "Alias ipal -> Import-Alias \n", "Alias ipcsv -> Import-Csv \n", "Alias ipmo -> Import-Module \n", "Alias ipsn -> Import-PSSession \n", "Alias irm -> Invoke-RestMethod \n", "Alias ise -> powershell_ise.exe \n", "Alias iwmi -> Invoke-WmiMethod \n", "Alias iwr -> Invoke-WebRequest \n", "Alias kill -> Stop-Process \n", "Alias lp -> Out-Printer \n", "Alias ls -> Get-ChildItem \n", "Alias man -> help \n", "Alias md -> mkdir \n", "Alias measure -> Measure-Object \n", "Alias mi -> Move-Item \n", "Alias mount -> New-PSDrive \n", "Alias move -> Move-Item \n", "Alias mp -> Move-ItemProperty \n", "Alias mv -> Move-Item \n", "Alias nal -> New-Alias \n", "Alias ndr -> New-PSDrive \n", "Alias ni -> New-Item \n", "Alias nmo -> New-Module \n", "Alias npssc -> New-PSSessionConfigurationFile \n", "Alias nsn -> New-PSSession \n", "Alias nv -> New-Variable \n", "Alias ogv -> Out-GridView \n", "Alias oh -> Out-Host \n", "Alias popd -> Pop-Location \n", "Alias ps -> Get-Process \n", "Alias pushd -> Push-Location \n", "Alias pwd -> Get-Location \n", "Alias r -> Invoke-History \n", "Alias rbp -> Remove-PSBreakpoint \n", "Alias rcjb -> Receive-Job \n", "Alias rcsn -> Receive-PSSession \n", "Alias rd -> Remove-Item \n", "Alias rdr -> Remove-PSDrive \n", "Alias ren -> Rename-Item \n", "Alias ri -> Remove-Item \n", "Alias rjb -> Remove-Job \n", "Alias rm -> Remove-Item \n", "Alias rmdir -> Remove-Item \n", "Alias rmo -> Remove-Module \n", "Alias rni -> Rename-Item \n", "Alias rnp -> Rename-ItemProperty \n", "Alias rp -> Remove-ItemProperty \n", "Alias rsn -> Remove-PSSession \n", "Alias rsnp -> Remove-PSSnapin \n", "Alias rujb -> Resume-Job \n", "Alias rv -> Remove-Variable \n", "Alias rvpa -> Resolve-Path \n", "Alias rwmi -> Remove-WmiObject \n", "Alias sajb -> Start-Job \n", "Alias sal -> Set-Alias \n", "Alias saps -> Start-Process \n", "Alias sasv -> Start-Service \n", "Alias sbp -> Set-PSBreakpoint \n", "Alias sc -> Set-Content \n", "Alias scb -> Set-Clipboard 3.1.0.0 Microsoft.PowerShell.Management \n", "Alias select -> Select-Object \n", "Alias set -> Set-Variable \n", "Alias shcm -> Show-Command \n", "Alias si -> Set-Item \n", "Alias sl -> Set-Location \n", "Alias sleep -> Start-Sleep \n", "Alias sls -> Select-String \n", "Alias sort -> Sort-Object \n", "Alias sp -> Set-ItemProperty \n", "Alias spjb -> Stop-Job \n", "Alias spps -> Stop-Process \n", "Alias spsv -> Stop-Service \n", "Alias start -> Start-Process \n", "Alias stz -> Set-TimeZone 3.1.0.0 Microsoft.PowerShell.Management \n", "Alias sujb -> Suspend-Job \n", "Alias sv -> Set-Variable \n", "Alias swmi -> Set-WmiInstance \n", "Alias tee -> Tee-Object \n", "Alias trcm -> Trace-Command \n", "Alias type -> Get-Content \n", "Alias wget -> Invoke-WebRequest \n", "Alias where -> Where-Object \n", "Alias wjb -> Wait-Job \n", "Alias write -> Write-Output \n", "\n", "\n" ] } ], "source": [ "Get-Alias" ] }, { "cell_type": "code", "execution_count": 124, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "TOPIC\n", " about_aliases\n", "\n", "SHORT DESCRIPTION\n", " Describes how to use alternate names for cmdlets and commands in Windows\n", " PowerShell. \n", "\n", "LONG DESCRIPTION\n", " An alias is an alternate name or nickname for a cmdlet or for a command\n", " element, such as a function, script, file, or executable file. You\n", " can use the alias instead of the command name in any Windows PowerShell\n", " commands.\n", " \n", " To create an alias, use the New-Alias cmdlet. For example, the following\n", " command creates the \"gas\" alias for the Get-AuthenticodeSignature cmdlet:\n", "\n", " New-Alias -Name gas -Value Get-AuthenticodeSignature\n", "\n", " After you create the alias for the cmdlet name, you can use the alias \n", " instead of the cmdlet name. For example, to get the Authenticode signature\n", " for the SqlScript.ps1 file, type:\n", "\n", " Get-AuthenticodeSignature SqlScript.ps1\n", "\n", " Or, type:\n", "\n", " gas SqlScript.ps1\n", "\n", "\n", " If you create \"word\" as the alias for Microsoft Office Word, you can type\n", " \"word\" instead of the following:\n", "\n", "\n", " \"C:\\Program Files\\Microsoft Office\\Office11\\Winword.exe\" \n", "\n", "BUILT-IN ALIASES\n", " Windows PowerShell includes a set of built-in aliases, including \"cd\" and\n", " \"chdir\" for the Set-Location cmdlet, and \"ls\" and \"dir\" for the\n", " Get-ChildItem cmdlet. \n", "\n", " To get all the aliases on the computer, including the built-in aliases,\n", " type:\n", "\n", " Get-Alias\n", "\n", "\n", "ALIAS CMDLETS\n", " Windows PowerShell includes the following cmdlets, which are designed for\n", " working with aliases: \n", "\n", " - Get-Alias. Gets all the aliases in the current session.\n", " - New-Alias. Creates a new alias.\n", " - Set-Alias. Creates or changes an alias.\n", " - Export-Alias. Exports one or more aliases to a file.\n", " - Import-Alias. Imports an alias file into Windows PowerShell. \n", "\n", " For detailed information about the cmdlets, type:\n", "\n", "Get-Help -Detailed\n", "\n", " For example, type:\n", "\n", "Get-Help Export-Alias -Detailed\n", "\n", "CREATING AN ALIAS\n", " To create a new alias, use the New-Alias cmdlet. For example, to create the\n", " \"gh\" alias for Get-Help, type:\n", "\n", "New-Alias -Name gh -Value Get-Help\n", "\n", " You can use the alias in commands, just as you would use the full cmdlet\n", " name, and you can use the alias with parameters.\n", "\n", " For example, to get detailed Help for the Get-WmiObject cmdlet, type:\n", "\n", "Get-Help Get-WmiObject -Detailed\n", "\n", " Or, type:\n", "\n", "gh Get-WmiObject -Detailed\n", "\n", "SAVING ALIASES\n", " The aliases that you create are saved only in the current session. To use\n", " the aliases in a different session, add the alias to your Windows \n", " PowerShell profile. Or, use the Export-Alias cmdlet to save the aliases to\n", " a file. \n", " \n", " For more information, type:\n", "\n", " Get-Help about_Profiles\n", "\n", "GETTING ALIASES\n", " To get all the aliases in the current session, including the built-in\n", " aliases, the aliases in your Windows PowerShell profiles, and the aliases\n", " that you have created in the current session, type:\n", "\n", "Get-Alias\n", " \n", " To get particular aliases, use the Name parameter of the Get-Alias cmdlet.\n", " For example, to get aliases that begin with \"p\", type:\n", "\n", "Get-Alias -Name p*\n", "\n", " To get the aliases for a particular item, use the Definition parameter.\n", " For example, to get the aliases for the Get-ChildItem cmdlet type:\n", "\n", "Get-Alias -Definition Get-ChildItem\n", "\n", " GET-ALIAS OUTPUT\n", "\n", " Get-Alias returns only one type of object, an AliasInfo object \n", " (System.Management.Automation.AliasInfo). However, beginning in\n", " Windows PowerShell 3.0, the name of aliases that don't include a\n", " hyphen, such as \"cd\" are displayed in the following format:\n", " \n", " -> \n", "\n", " For example,\n", "\n", " ac -> Add-Content \n", "\n", " This makes it very quick and easy to get the information that you\n", " need. \n", "\n", " The arrow-based alias name format is not used for aliases that\n", " include a hyphen. These are likely to be preferred substitute \n", " names for cmdlets and functions, instead of typical abbreviations\n", " or nicknames, and the author might not want them to be as evident.\n", "\n", "\n", "ALTERNATE NAMES FOR COMMANDS WITH PARAMETERS\n", " You can assign an alias to a cmdlet, script, function, or executable file.\n", " However, you cannot assign an alias to a command and its parameters.\n", " For example, you can assign an alias to the Get-Eventlog cmdlet, but you\n", " cannot assign an alias to the \"Get-Eventlog -LogName System\" command.\n", "\n", " However, you can create a function that includes the command. To create a\n", " function, type the word \"function\" followed by a name for the function.\n", " Type the command, and enclose it in braces ({}).\n", "\n", " For example, the following command creates the syslog function. This\n", " function represents the \"Get-Eventlog -LogName System\" command:\n", "\n", "function syslog {Get-Eventlog -LogName System}\n", "\n", " You can now type \"syslog\" instead of the command. And, you can create\n", " aliases for the syslog function.\n", "\n", " For more information about functions, type:\n", "\n", "Get-Help about_Functions\n", "\n", "ALIAS OBJECTS\n", " Windows PowerShell aliases are represented by objects that are instances\n", " of the System.Management.Automation.AliasInfo class. For more information\n", " about this type of object, see \"AliasInfo Class\" in the Microsoft \n", " Developer Network (MSDN) library at \n", " http://go.microsoft.com/fwlink/?LinkId=143644.\n", "\n", " To view the properties and methods of the alias objects, get the\n", " aliases. Then, pipe them to the Get-Member cmdlet. For example:\n", "\n", "Get-Alias | Get-Member\n", "\n", " To view the values of the properties of a specific alias, such as the \n", " \"dir\" alias, get the alias. Then, pipe it to the Format-List cmdlet. For\n", " example, the following command gets the \"dir\" alias. Next, the command\n", " pipes the alias to the Format-List cmdlet. Then, the command uses the \n", " Property parameter of Format-List with a wildcard character (*) to display\n", " all the properties of the \"dir\" alias. The following command performs\n", " these tasks:\n", "\n", "Get-Alias -Name dir | Format-List -Property *\n", "\n", "WINDOWS POWERSHELL ALIAS PROVIDER\n", " Windows PowerShell includes the Alias provider. The Alias provider lets you\n", " view the aliases in Windows PowerShell as though they were on a file system\n", " drive. \n", "\n", " The Alias provider exposes the Alias: drive. To go into the Alias: drive,\n", " type:\n", "\n", "Set-Location Alias:\n", "\n", " To view the contents of the drive, type:\n", "\n", "Get-ChildItem\n", "\n", " To view the contents of the drive from another Windows PowerShell drive,\n", " begin the path with the drive name. Include the colon (:). For example:\n", "\n", "Get-ChildItem -Path Alias:\n", "\n", " To get information about a particular alias, type the drive name and\n", " the alias name. Or, type a name pattern. For example, to get all the \n", " aliases that begin with \"p\", type:\n", "\n", "Get-ChildItem -Path Alias:p*\n", "\n", " For more information about the Windows PowerShell Alias provider,\n", " type:\n", "\n", "Get-Help Alias\n", "\n", "\n", "SEE ALSO\n", "\n", " New-Alias\n", " Get-Alias\n", " set-alias\n", " export-alias\n", " import-alias\n", " get-psprovider\n", " get-psdrive\n", " about_functions\n", " about_profiles\n", " about_providers\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] } ], "source": [ "Help about_alias" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "PowerShell", "language": "powershell", "name": "powershell" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".ps1", "mimetype": "text/x-sh", "name": "powershell" } }, "nbformat": 4, "nbformat_minor": 2 }