0
0
PowerShellscripting~15 mins

Command discovery (Get-Command) in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Discovering Commands with Get-Command in PowerShell
📖 Scenario: You are learning how to find commands in PowerShell. Sometimes you want to know what commands are available or find commands related to a topic.
🎯 Goal: You will create a simple script that uses Get-Command to find commands related to a specific word and then display them.
📋 What You'll Learn
Create a variable with a search keyword
Use Get-Command with the keyword
Store the results in a variable
Display the found commands
💡 Why This Matters
🌍 Real World
PowerShell users often need to discover commands to automate tasks or learn new features.
💼 Career
Knowing how to find and filter commands helps system administrators and automation engineers write effective scripts.
Progress0 / 4 steps
1
Create a search keyword variable
Create a variable called $keyword and set it to the string Get.
PowerShell
Need a hint?

Use $keyword = 'Get' to create the variable.

2
Use Get-Command with the keyword
Create a variable called $commands and set it to the result of Get-Command using the -Name parameter with $keyword and a wildcard * after it (like $keyword*).
PowerShell
Need a hint?

Use Get-Command -Name "$keyword*" to find commands starting with the keyword.

3
Filter commands by command type
Filter $commands to only include commands where the CommandType property equals Cmdlet. Store the filtered list back in $commands.
PowerShell
Need a hint?

Use Where-Object { $_.CommandType -eq 'Cmdlet' } to filter the commands.

4
Display the filtered commands
Use Write-Output to display the Name property of each command in $commands.
PowerShell
Need a hint?

Use ForEach-Object { Write-Output $_.Name } to print each command name.