From the course: PowerShell 7 Essential Training

Discover commands - PowerShell Tutorial

From the course: PowerShell 7 Essential Training

Start my 1-month free trial

Discover commands

- [Instructor] So PowerShell itself uses a verb-hyphen-noun naming system. The PowerShell cmdlet name consists of a standard verb hyphenated with a specific noun. So for example, Get-Service New-service or something like Suspend-Service. Each of the PowerShell commands are named this way. Now, for example, if we wanted to review all of the commands that are available within a specific cmdlet, we can use what's called the Get-Command. This enables discovery of accessible cmdlets. We then have the ability to filter by using various properties, such as CommandType, the name, and of course the version. We can also then utilize the filtered parameter to do a free text search for a specific command or command type. Now in order for us to actually view types of commands, we're able to, for example, type Get-Command and then use the verb parameter, and then specify the type of verb. In this instance, we're looking for verbs that would begin with add, so add computer or add something. We could also then view all noun commands by utilizing the dash noun property. And then for example, here, we're going to find all of the noun commands that have the word computer in that second noun part. So this would be Get-Computer, New-Computer, Stock-Computer, et cetera. We could also then view everything that's classed as a cmdlet by utilizing command type, which then allow us to specify that. If we just want to actually do a free text search, we can actually type Get-Command. And then in asterisk or star, whatever you want to call it, we can type the free text value that we're looking for. Now, we also have the ability to find commands that would exist within a PowerShell module. So for example, the find cmdlet finds PowerShell commands such as cmdlets, aliases, functions and workflows. The Find-Command will search the modules in the registered repositories that we're kind of looking against. For each command found by the Find-Command, it will return what's called a PSGetCommandInfo object. The PSGetCommandInfo object can then be sent down the pipeline, for example, to use install module. The Install-Module command will then install the module that contains that specific command. So if we're trying to identify a command that will let me perform a certain action on a computer, if I use the Find-Command, retrieve the object, I can do a pipe command and then join that together with the install.

Contents