PowerShell Misc Examples
Misc common tasks in PowerShell.
clear
,cls
- (
Clear-Host
) Clear screen. mv
- (
Move-Item
) Move a file/dir to another dir. echo
- (
Write-Output
) Print to next pipe or screen. ps
- (
Get-Process
) Lists proceses. kill
- (
Stop-Process
) Stop one process or more.
Run as Admin
start powershell -Verb RunAs
or
start pwsh -Verb RunAs
start
is alias ofStart-Process
Empty Trash
Clear-RecycleBin
Clear Shell Command History
Set-Content (Get-PSReadlineOption).HistorySavePath -value ""
the
(Get-PSReadlineOption).HistorySavePath
returns the PowerShell command history file at
~\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
start app, launch app, run script/code
invoke-item
(aliasii
)-
Start default app on a file or app, e.g. open default app on a image file, pdf file, folder path.
ii photo.jpg ii ~/
start-process
(aliassaps
,start
)- Start a processes. e.g. launch notepad, browser.
start notepad start chrome
Start-Job
(aliassajb
)- Start a PowerShell background job.
invoke-expression
(aliasiex
)- run a PowerShell expression from a string. Normally, a string is printed as is. This is similar to
eval
in many langs. invoke-command
(aliasicm
)- run a command.