Basic Powershell Commands Flashcards
Get-Command
When used by itself, the Get-Command cmdlet will display a list of every known PowerShell cmdlet.
Get-Help
Get-Help can show you how to use a cmdlet.
(Ex: Get-Help Get-Command)
Clear-Host
The cmdlet is used to clear the screen.
Set-Location
It can be used as an alternative to the CD command (CD is a DOS leftover and stands for Change Directory).
(Ex: Set-Location -Path “C:\Users\Brien”)
Get-ChildItem
When you type the Get-ChildItem cmdlet by itself, PowerShell will display the contents of the current folder.
Get-Process
The Get-Process command helps you retrieve and show a list of all the active system processes with their identifiers (IDs).
(Ex: Get-Process -ID 20496 | Stop-Process)
Start-Process
You can use the Start-Process cmdlet in PowerShell to start one or more processes on a local computer.
(Ex: Start-Process notepad )
Get-Service
The Get-Service cmdlet lets you view your computer’s status and list of services.
(Ex: Get-Service -Name “Win*”)
Get-ChildItem
The Get-ChildItem command is a handy cmdlet to look for folders and files and quickly perform content-based searches without using File Explorer.
(Ex: Get-ChildItem “C:")
Copy-Item
The Copy-Item cmdlet lets you copy-paste files and folders and their contents to a different directory.
(Ex: Copy-Item “E:\Folder1” -Destination “E:\Folder2” -Recurse)
Remove-Item
The Remove-Item cmdlet lets you delete files, folders, functions, and other data types from the specified directory.
(Ex: Remove-Item E:\Folder1\Test.txt)
Set-ExecutionPolicy
The default execution policy in PowerShell is set to Restricted. This prevents the execution of malicious scripts in the PowerShell environment. However, when you execute a local PowerShell script, you may encounter the execution script is disabled on this system error.
(Ex: Set-ExecutionPolicy RemoteSigned)
Get-History
You can use the Up-Down arrow key to scroll through the recently executed commands in PowerShell. However, to view a list of all the recently executed commands in your current session at once, you can use the Get-History cmdlet.