IT Questions and Answers :)

Friday, April 20, 2018

In PowerShell, which of the following is a feature that you use to assign a set of commands (optionally with input parameters) to execute by a single name?

In PowerShell, which of the following is a feature that you use to assign a set of commands (optionally with input parameters) to execute by a single name?

  • subroutine
  • procedure
  • function
  • method 

 
In PowerShell, which of the following is a feature that you use to assign a set of commands (optionally with input parameters) to execute by a single name?

EXPLANATION


In PowerShell, functions can act like miniature scripts within scripts which are executed by name, and they can be everything from a few commands, to full blown cmdlets written entirely in PowerShell (called Advanced Functions).
about_Functions on MSDN: https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/about/about_func...
about_Functions_Advanced on MSDN: https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/about/
Methods exist in PowerShell as well, as members of .NET objects: https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/about/about_meth...
Note: you can also access the above three directly in PowerShell with the commands:
Get-Help about_Functions
Get-Help about_Functions_Advanced
Get-Help about_Methods
Going beyond PowerShell, this is mostly a naming convention: the differences between the four names seem to vary from language to language.  While there are general technical definitions for each of the terms (for instance, "functions return a value; procedures do not"), these are not used universally among languages and programmers; as such, it's generally best to follow the naming convention common to the specific language.For more reading on the terms: http://softwareengineering.stackexchange.com/questions/20909/method-vs-function-vs-procedure

Share:

Followers

Popular Posts