Command-Lets and Module

In Previous blog I have explained briefly about Powershell and uses of Help command. In this blog we'll discuss in detail about Command Lets and Module. So let's begin!!

What are Command Lets??

Command lets are the in built functions or in other word you say commands which are used in various powershell scripting. These commands can get values of object properties or even can modify its values for example you have a service and you want to stop that command, well in that case stop-service command let is used to stop the service. Note these command lets are powerful enough that it can break your production environment and you may be in trouble. My motive is not make you fear for powershell, its just a FYI that what a powershell can do to your live running environment. I would suggest you to play around Get Command let this will not break anything :)

Every Command let in powershell is made up of two basic parts of speech from english grammer, Verb and Noun.

Get-Service
Verb-Noun

Here Get is a verb and Service is a Noun which means, you are asking powershell to GET all the Services you have in your server. Get is actually fetching all the services from your server and displays it on your powershell console. Similarly you have Set-Service, this will set a new service to your service console and would set whatever parameter you provide to it. There are numerous command lets out there which are used in scripting. You can check them all via using Get-Command -All, as this command-let will show you the list of command-lets present in powershell currently. You can also search particular command-lets by using verb switch or noun switch etc. You can make your own command-lets or you can also create your own functions, modules, scripts etc using appropriate command-lets. My suggestion to you is, to open powershell in your laptops or desktops and start researching on the command lets using help command. Always open powershell in ISE (Integrated Scripting Environment) mode as in ISE mode you can see the command lets and their respective modules in powershell ISE's right pane. We'll discuss this on other blog.

Example for Get-Command

What are Modules?

A module is a package which has functions, command-lets, variables, workflows etc which is basic need for a powershell. Without modules you can not have a command let or any function. There are pre-existing modules in powershell which comes when powershell is installed. You can view it by simply running Get-Module -ListAvailable command and see what all modules are available in your powershell, this will also show you the directory of the modules where they are kept. It is recommended not to make any changes in the pre-existing Modules, unless you are aware of the change. You can create your own Modules with powershell where you would have your own defined functions, command lets, variables etc. These modules are generally kept on "C:\windows\system32\WindowsPowerShell\v1.0\Modules" path.

Example of Get-Module cmdlt.


Comments

Popular posts from this blog

PowerShell and 'Get-Help' Basics

Getting started with Powershell