
PowerShell is widely recognized as an essential tool for IT administrators focusing on scripting and automation. However, its robust capabilities extend well beyond the IT sector, making it invaluable for anyone grappling with disorganized files and directories. Personally, I utilize PowerShell commands to sift through outdated code, structure client files, and mitigate the disorder that accumulates from months of fast-paced, deadline-driven projects.
As a powerful command-line shell and scripting platform, PowerShell simplifies a variety of tasks. Although earlier versions of Windows featured a standalone PowerShell application, users now favor Windows Terminal for executing shell environments—including PowerShell and Command Prompt—thanks to its versatility and modern interface.
All commands can be executed within both the dedicated PowerShell app and Windows Terminal. To start using them, simply open a PowerShell tab in Windows Terminal.
1.Get-Help

When I first explored PowerShell through YouTube tutorials, one command frequently highlighted by users was Get-Help. This command serves as an introductory resource, allowing you to access detailed information about any PowerShell cmdlet along with its syntax, parameters, and usage examples.
To retrieve specific information on a command, type:
Get-Help Get-Process
This will display the command’s synopsis, syntax details, and input parameters. For further information, append the -Examples parameter:
Get-Help Get-Process -Examples
Moreover, you can refer to Microsoft’s official documentation by using the -Online switch:
Get-Help Get-Process -Online
This command directs you to the Microsoft website for comprehensive command documentation.
2.Get-Command

While Get-Help focuses on delivering information about cmdlets, Get-Command is essential for locating and listing all available commands at your disposal. If you’re aware of the function you wish to perform but can’t recollect the command name, simply utilize Get-Command to search for commands based on partial names or patterns.
For example, to find all commands containing the word process, enter:
Get-Command *process*
This command reveals every command that includes “process”in its name. You can further refine your search based on command types, such as if you only want cmdlets:
Get-Command -Name Get* -CommandType Cmdlet
Additionally, for module-specific searches, like those pertaining to networking:
Get-Command -Module NetTCPIP
Using Get-Command is significantly more efficient than searching the web for command names.
3.Test-NetConnection

Do you often switch between various tools like ping, telnet, and traceroute? The Test-NetConnection cmdlet consolidates these functionalities into one. This cmdlet is crucial for network troubleshooting, as it helps diagnose whether an issue stems from your network, the server, or other sources.
To determine if a website is reachable, execute:
Test-NetConnection makeuseof.com
This command provides ping results and fundamental connectivity info. To test a specific port, incorporate the port number into the command:
Test-NetConnection server.company.com -Port 443
For detailed network path tracing, use the -TraceRoute parameter:
Test-NetConnection 8.8.8.8 -TraceRoute
This command sends test packets to 8.8.8.8 while tracing the hops between your computer and the destination, assisting you in pinpointing any connection issues.
4.Get-ChildItem

The Get-ChildItem cmdlet enables you to view files and folders in any specified directory. For instance, to list contents in the Documents folder, simply input:
Get-ChildItem C:\Users\Username\Documents
To identify PDF files modified in the last week, use the following command:
Get-ChildItem C:\Users\YourName\Documents -Filter *.pdf | Where-Object {$_. LastWriteTime -gt (Get-Date).AddDays(-7)}
The -Recurse parameter allows you to search through all subfolders. If you want to locate all log files in your Projects folder and its subdirectories:
Get-ChildItem C:\Projects -Recurse -Filter *.log
If disk space is low, you can identify large files exceeding 1GB:
Get-ChildItem C:\ -Recurse -File | Where-Object {$_. Length -gt 1GB} | Select-Object FullName, @{Name="SizeGB";Expression={$_. Length/1GB}}
The Get-ChildItem cmdlet is a powerful ally for automating batch tasks, file organization, and audits.
5.Where-Object

Within the previous example, the use of Where-Object highlights its functionality in filtering data based on specific property criteria—operating comparably to conditional statements in programming. The syntax inside the curly braces allows representation of each item under evaluation.
To visualize all running services, input the following:
Get-Service | Where-Object {$_. Status -eq "Running"}
If you’re interested in processes consuming more than 100MB of memory, try:
Get-Process | Where-Object {$_. WorkingSet -gt 100MB}
Combining multiple conditions is also possible. For example, to locate large Word documents modified within the last month:
Get-ChildItem -Filter *.docx | Where-Object {$_. Length -gt 5MB -and $_. LastWriteTime -gt (Get-Date).AddMonths(-1)}
Organize complex conditions across multiple lines for enhanced script readability:
Get-ChildItem | Where-Object { $_. Length -gt 1MB -and $_. Extension -eq ".log"}
6.Select-Object

Often, the output from commands is more extensive than necessary. The Select-Object cmdlet allows you to filter only the pertinent data, which can then be exported to a CSV file using the Export-Csv cmdlet. For example, if you wish to see only the names and statuses of services:
Get-Service | Select-Object Name, Status
If your goal is to identify the top five processes consuming the most CPU, execute:
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 Name, CPU
Additionally, you can create calculated properties. To display file sizes in megabytes rather than bytes:
Get-ChildItem | Select-Object Name, @{Name="SizeMB";Expression={$_. Length/1MB}}
To extract a single property value, utilize the -ExpandProperty parameter:
Get-Process notepad | Select-Object -ExpandProperty Id
This command yields only the process ID, which can be particularly useful when piping to additional commands that require a single value.
7.Get-Member

PowerShell operates primarily through objects, and the Get-Member cmdlet reveals their associated properties and methods. For instance, when retrieving information about a process, you can check its size, creation date, and other metrics. Use the following command to view the attributes within a process object:
Get-Process | Get-Member
This will list properties such as CPU, Id, and WorkingSet, in addition to methods like Kill() and Refresh().Should you wish to see just properties, you may specify:
Get-Process | Get-Member -MemberType Property
For file-related operations:
Get-ChildItem C:\temp\test.txt | Get-Member
This displays details like Length and LastWriteTime, alongside methods such as Delete() and MoveTo().You can filter files by size using Length or identify recently modified files based on LastWriteTime.
8.Set-Clipboard and Get-Clipboard

If you ever find yourself facing an overwhelming output from PowerShell that requires copying, manually selecting can be cumbersome. However, Set-Clipboard and Get-Clipboard streamline this process significantly.
To copy command results to your clipboard, input:
Get-Process | Select-Object Name, CPU | Set-Clipboard
This enables you to paste outcomes into Excel or any text editor with ease. Conversely, to retrieve clipboard contents back into PowerShell, simply run:
$text = Get-Clipboard
This feature is particularly useful when processing lists. For instance, you can copy a range of computer names from Excel and subsequently execute:
Get-Clipboard | ForEach-Object { Test-NetConnection $_ }
This command tests connectivity to each computer name listed. The seamless integration between PowerShell and other applications accelerates repetitive tasks considerably.
9.Out-GridView

There are moments when interactive sorting and filtering of results is necessary. The Out-GridView cmdlet opens a separate window featuring a sortable and searchable table format.
Get-Process | Out-GridView
This action launches a new window displaying a list of current processes in a grid interface. Click on column headers to sort, or filter by keyword in the search field. To select items from the grid and pass them to another command, utilize:
Get-Service | Out-GridView -PassThru | Restart-Service
With the -PassThru parameter, you can select multiple rows and execute actions, such as restarting only those chosen services.
For log analysis, you can also apply:
Get-EventLog -LogName Application -Newest 1000 | Out-GridView
This allows for quick event filtering by keyword entry, sorting by time, and revealing patterns within the dataset.
10.Get-Process

The Get-Process cmdlet displays all applications currently running on your computer, providing insights into their memory usage, CPU time, and process IDs.
To list all currently active processes, execute:
Get-Process
If you’re searching for a specific application, such as Google Chrome, simply specify:
Get-Process chrome
If you need to terminate a non-responsive program, you can chain commands as follows:
Get-Process notepad | Stop-Process
To identify processes consuming substantial memory resources, implement:
Get-Process | Sort-Object WorkingSet -Descending | Select-Object -First 10
This command offers a quick overview of memory-hogging programs when your system performance slows down.
Leave a Reply ▼