Finding commands

The verb-noun pairing can make it a lot easier to find commands (without resorting to search engines).

For example, if we want to list firewall rules and we already know of the NetSecurity module that's available in Windows PowerShell, we can run the following command, which shows the Get commands in that module:

PS> Get-Command Get-*Firewall* -Module NetSecurity

CommandType Name Version Source
----------- ---- ------- ------
Function Get-NetFirewallAddressFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallApplicationFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallInterfaceFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallInterfaceTypeFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallPortFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallProfile 2.0.0.0 NetSecurity
Function Get-NetFirewallRule 2.0.0.0 NetSecurity
Function Get-NetFirewallSecurityFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallServiceFilter 2.0.0.0 NetSecurity
Function Get-NetFirewallSetting 2.0.0.0 NetSecurity

From the previous list, Get-NetFirewallRule closely matches the requirement (to see a list of firewall rules) and should be explored.

Taking a broader approach, if the module was not known, we might still be able to guess by searching for commands containing specific nouns, for example, commands to get existing items that mention a firewall:

Get-Command Get-*Firewall* 

Once a potential command has been found, Get-Help can be used to assess whether or not the command is suitable.

NetSecurity and PowerShell Core

The NetSecurity module is not available using PowerShell Core by default. Using modules such as NetSecurity in PowerShell Core is discussed in Chapter 2, Modules and Snap-ins.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.60