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