| Both sides previous revision Previous revision Next revision | Previous revision |
| powershell [2021/12/19 17:14] – [Powershell] mgupton | powershell [2024/11/08 14:27] (current) – [History] mgupton |
|---|
| ======Powershell====== | ======Powershell====== |
| * {{ :wiki:comparitech-powershell-cheatsheet.pdf |}} | * {{ :wiki:comparitech-powershell-cheatsheet.pdf |}} |
| * [[qnd:Powershell]] (quick-n-dirty) | * [[powershell:qnd:Powershell]] (quick-n-dirty) |
| * [[Powershell Configuration]] | * [[Powershell Configuration]] |
| * [[Running Powershell Scripts]] | * [[Running Powershell Scripts]] |
| * [[https://ss64.com/ps]] | * [[https://ss64.com/ps]] |
| * [[powershell_git|Powershell Git]] | * [[powershell_git|Powershell Git]] |
| | |
| | * [[https://jdhitsolutions.com/blog/|The Lonely Administrator]] |
| |
| |
| |
| * Use ''get-history | out-gridview -Passthru | invoke-history'' to get and invoke command from history using a grid view. Alternatively, ''h | ogv -p | r''. Or, just create a function for it, ''function hh {get-history | out-gridview -Passthru | invoke-history}'' | * Use ''get-history | out-gridview -Passthru | invoke-history'' to get and invoke command from history using a grid view. Alternatively, ''h | ogv -p | r''. Or, just create a function for it, ''function hh {get-history | out-gridview -Passthru | invoke-history}'' |
| | * Use ''Ctrl+r'' to interactively search backward through history and ''Ctrl+s'' to search forward |
| | * Use ''Esc'' to recall command to current command line |
| | * Use ''Esc'' again to remove it from the current command line |
| | * Alternatively, use left/right arrow keys or ''end'' to select the current search result |
| | * Use ''Esc'' to clear the current line |
| | * Use ''Ctrl+l'' to clear whole screen |
| ======Operators====== | ======Operators====== |
| * [[https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_comparison_operators|Comparison Operators]] | * [[https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_comparison_operators|Comparison Operators]] |
| |
| ======Variables====== | ======Variables====== |
| | * ''Get-Variable'', to list all variables in the current session |
| | ==== Basic Scalar Example ==== |
| <code powershell> | <code powershell> |
| $fname = "Spunky" | $fname = "Spunky" |
| * ''$ARGS'', array of arguments passed to script. | * ''$ARGS'', array of arguments passed to script. |
| * ''$NULL'', variable that represents //null// value, big surprise. | * ''$NULL'', variable that represents //null// value, big surprise. |
| | * ''$true'' and ''$false'' represent the boolean values |
| | * ''env:'', pseudo drive for environment variables |
| |
| | ====== Input/Output ====== |
| | |
| | Example of using Out-GridView for handy way to get output |
| | <code powershell> |
| | Get-Alias | Out-GridView |
| | </code> |
| | |
| | Example of selecting a property from objects |
| | <code powershell> |
| | $files = ls .\* -Exclude @("*.tmp") |
| | |
| | $files | select -Property FullName |
| | |
| | # Alternative: this method does not include the property header that is included with the Select-Object method above |
| | $files | foreach {$_.FullName} |
| | </code> |
| ======Conditionals====== | ======Conditionals====== |
| |
| |
| * [[qnd:Sign Powershell Script]] | * [[qnd:Sign Powershell Script]] |
| | |
| | ====== Related ====== |
| | * [[azure:qnd:azure_powershell|Azure Powershell (QnD)]] |
| | |