No edit summary |
No edit summary |
||
Line 36: | Line 36: | ||
Get-Process | Get-Member #Get members of the object | Get-Process | Get-Member #Get members of the object | ||
Get-Process| format-list -properties * #Get-Process as list with all properties | Get-Process| format-list -properties * #Get-Process as list with all properties | ||
</syntaxhighlight> | |||
== Scripts == | |||
<syntaxhighlight lang="powershell"> | |||
Set-ExecutionPolicy -ExecutionPolicy #Bypass set ExecutionPolicy to allow all scripts | |||
."\\c-is-ts-91\c$\scripts\script.ps1” #Run Script.ps1 script in current scope | |||
&"\\c-is-ts-91\c$\scripts\script.ps1" #Run Script.ps1 script in script scope | |||
.\Script.ps1 #Run Script.ps1 script in script scope | |||
$profile #Your personal profile that runs at launch | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 10:47, 2 March 2023
Basic Commands
Cmdlet #Commands built into shell written in .NET
Functions #Commands written in PowerShell language
Parameter #Argument to a Cmdlet/Function/Script
Alias #Shortcut for a Cmdlet or Function
Script #Text files with .ps1 extension
Applications #Existing windows programs
Pipelines #Pass objects Get-process word | Stop-Process
Ctrl+c #Interrupt current command
Left/Right #Navigate editing cursor
Ctrl+Left/Right #Navigate a word at a time
Home/End #End Move to start / end of line
Up/Down #Move up and down through history
Insert #Toggles between insert/overwrite mode
F7 #Command history in a window
Tab/Shift-Tab #Command line completion
Variables
$var = "string" #Assign Variable
$a,$b = 0 or $a,$b = 'a','b' #Assign Multiple Variables
$a,$b = $b,$a #Flip Variables
$var=[int]5 #Strongly Typed Variable
Help
Get-Command #Get all commands
Get-Command -Module RGHS #Get all commands in RGHS module
Get-Command Get-p* #Get all commands starting with get-p
Get-help get-process #Get help for command
Get-Process | Get-Member #Get members of the object
Get-Process| format-list -properties * #Get-Process as list with all properties
Scripts
Set-ExecutionPolicy -ExecutionPolicy #Bypass set ExecutionPolicy to allow all scripts
."\\c-is-ts-91\c$\scripts\script.ps1” #Run Script.ps1 script in current scope
&"\\c-is-ts-91\c$\scripts\script.ps1" #Run Script.ps1 script in script scope
.\Script.ps1 #Run Script.ps1 script in script scope
$profile #Your personal profile that runs at launch