Exercise - Locate commands
In this unit, you'll use Azure Cloud Shell on the right as your Linux terminal. You can access Cloud Shell through the Azure portal or the Cloud Shell sign-in. You don't have to install anything on your PC or laptop to use it.
Here, you'll run commands that will help you learn more about PowerShell. PowerShell isn't something you learn overnight; it's learned command by command. You can speed up your learning by effectively using the core cmdlets.
Locate a command
Locate commands by running the
Get-Command cmdlet. The cmdlet helps you search all of the cmdlets installed on your system. Use flags to narrow down your search results to just the cmdlets that fit your scenario.
In this scenario, you're looking for a cmdlet that can help you work with files.
Run the command
Get-Commandwith the flag
File*to find anything related to files.
Get-Command -Noun File*
The response shows something similar to the following text:
CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-FileHash 188.8.131.52 Microsoft.PowerShell.Utility Cmdlet Out-File 184.108.40.206 Microsoft.PowerShell.Utility Cmdlet Unblock-File 220.127.116.11 Microsoft.PowerShell.Utility
Unblock-Fileall match your query. Now, you have a manageable response. To further filter the response, add the
-Verbparameter to your query.
Get-Command. Specify the flags
Get-Command -Verb Get -Noun File*
The result is similar to the following output:
CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-FileHash 18.104.22.168 Microsoft.PowerShell.Utility
This time, only one record matches your search, because you specified both the
-Nounparameter and the
Because the domain you work in is file management, you specified
File as the noun. If you know what you want to do within that domain, you can specify
-Verb parameters. By using one or possibly two parameters, you can quickly find the cmdlet you need.
Need help? See our troubleshooting guide or provide specific feedback by reporting an issue.