Windows Logo + X = Access Shortcut
15 of the most commonly used PowerShell functions
Get-Help: Provides detailed information about PowerShell cmdlets, including syntax and examples. It’s essential for learning how to use other cmdlets.
Get-Command: Lists all available cmdlets, functions, workflows, aliases installed on your system. It’s useful for discovering new commands.
Get-ChildItem: Retrieves the items and child items in one or more specified locations. It’s commonly used for directory and file listings.
Set-Location: Changes the current directory to a specified path. It’s similar to the
cd
command in other shells.Get-Process: Displays a list of processes running on your local or a remote computer. It’s useful for monitoring system activity.
Stop-Process: Stops one or more running processes. It’s handy for terminating unresponsive applications.
Get-Service: Retrieves the status of services on a local or remote machine. It’s useful for managing Windows services.
Start-Service: Starts a stopped service. It’s often used in scripts to ensure necessary services are running.
Stop-Service: Stops a running service. It’s useful for stopping services that are no longer needed.
Get-EventLog: Retrieves the events from event logs on the local or remote computers. It’s essential for system diagnostics and troubleshooting.
Export-Csv: Converts objects into a series of comma-separated values (CSV) and saves them in a file. It’s useful for exporting data for analysis.
Import-Csv: Reads a CSV file and converts it into objects. It’s commonly used for importing data into PowerShell.
New-Item: Creates a new item, such as a file or directory. It’s useful for setting up new files and folders.
Copy-Item: Copies an item from one location to another. It’s used for file and directory duplication.
Remove-Item: Deletes an item, such as a file or directory. It’s essential for cleaning up files and directories.
Syntax
Get-Help
Get-Help Get-Process
Get-Command
Get-Command -Name Get-*
Get-ChildItem
Get-ChildItem -Path C:\Users
Set-Location
Set-Location -Path C:\Users
Get-Process
Get-Process -Name notepad
Stop-Process
Stop-Process -Name notepad
Get-Service
Get-Service -Name wuauserv
Start-Service
Start-Service -Name wuauserv
Stop-Service
Stop-Service -Name wuauserv
Get-EventLog
Get-EventLog -LogName System -Newest 10
Export-Csv
Get-Process | Export-Csv -Path C:\Temp\processes.csv
Import-Csv
Import-Csv -Path C:\Temp\processes.csv
New-Item
New-Item -Path C:\Temp\NewFolder -ItemType Directory
Copy-Item
Copy-Item -Path C:\Temp\file.txt -Destination C:\Backup
Remove-Item
Remove-Item -Path C:\Temp\file.txt
More Syntax You Can Use
Installing a Package (e.g., from NuGet)
Install-Package <Package Name> -Scope CurrentUser
Creating a Hidden Folder
New-Item -ItemType Directory -Path "C:\HiddenFolder" -Force -Attributes Hidden
Creating a Directory
New-Item -ItemType Directory -Path "C:\NewDirectory"
Requesting Administrator Permission
Start-Process PowerShell -Verb RunAs
Viewing Users
Get-ADUser -Filter *
Preventing Access to a Folder
Using File System Permissions:
icacls "C:\RestrictedFolder" /deny Everyone:(F)
Using Windows Security:
# This requires administrative privileges
icacls "C:\RestrictedFolder" /inheritance:disable
icacls "C:\RestrictedFolder" /deny Everyone:(F)
"Please keep your comments respectful and on-topic."
"Your email address will not be published."
"HTML tags are not allowed in comments."
"Spam comments will be deleted."