Saturday, 5 July 2014

Basic understandings about Windows PowerShell.

What is Powershell ???

Windows PowerShell is a task automation and object-oriented management engine based on .NET Framework which is designed especially for system administration and automate batch processing. PS is Object Oriented, but that doesn't mean you have to become a programmer to use it. PS is an extendable command shell as well.

Other PowerShell definitions are ...

PowerShell is an automation engine
PowerShell is a scripting environment
PowerShell is a command-line shell

PowerShell Versions

PowerShell v1 - November 2006. The codename for the PowerShell project was Monad ( Between 2002 and 2006 )

PowerShell 2.0 - October 2009 - This version supports remoting and enhances the capabilities of PowerShell like transactions, background jobs, events, debugging etc-:

PowerShell 3 -  September 2012 - PowerShell 3.0 doesn't support Windows XP. In this version, You can add and scheduled jobs, session connectivity, automatic module loading etc-:

PowerShell 4.0 - October 2013 - Added support for desired state configuration, enhanced debugging, network diagnostics etc-:

Is Powershell available in all the OS by default?

No. Windows Powershell is not available in all Operating systems by default. It is available from Windows 7 and it's latest and from windows-2008 R2 and its latest. We can download and install PowerShell in Windows-XP, Windows-Vista, and Windows-2003

Basic Short Notes !!! Must read.

What is a Class - In an object-oriented programming language, a class is a blueprint for an object. Classes describe the types of an object

What is an Object  - An object is an instance of a class that created dynamically.

What is a Method - A method is a code block that contains a series of statement

What is Powershell Function - Function is the way of packaging the codes that does something and return the value

What is Parameter and Argument - In general, we can think of a Parameter as a receiver of a piece of information and The argument is the information itself.

What is Enumerator - Enumerator or enum is a value data type. It is used to represent a constant set of value

What is Constructor in PowerShell - A constructor is a special method of a class which gets automatically invoked at the time of object creation.

What is an Array in PowerShell  - An array is a data structure that is designed to store a collection of items. The items can be the same type or different types - Indexes are used in arrays

What is a Hash Table - A PowerShell hash table is a data structure of key/value pairs. A key/value pair is essentially a set of two elements that are related in some manner. In its the simplest form, a hash table is just a way to store one or more sets of item names and item values.

How to Use Powershell?

Powershell engine is a set of .Net framework classes stored in a DLL file. You can not interact with it directly.

When we talk about "Using Powershell" we are most often talking about using it through a host that looks like a command-line.  Microsoft provides two host for that purpose.

Console and ISE (Integrated Scripting Environment).

Console(PowerShell.exe) is an application that runs in the command line and ISE is basically a graphical PowerShell application which is using for scripting purpose and we can have different run-space in a single window to run multiple scripts. Power GUI and SAPIEN PS Editor are the examples of some other third party host which enables more features.

Powershell and old command prompt (cmd) use the same underlying console technology, which means that you can type PowerShell in command prompt and cmd in PowerShell to switch the other shell. The exit will revert back the starting shell.

What is 64-Bit and 32-Bit Console?

This is basically pointing to PowerShell extensions. If you are loading an extension, you can only load which is built on the same architecture. The 64-Bit shell can only load the 64-Bit extension. And if you have 32-Bit extension you have to load 32-Bit shell.

Brackets in PowerShell

Parenthesis Brackets (): Curved parenthesis style brackets are used for compulsory arguments.
Braces Brackets {} : Curly brackets are employed in blocked statements
Square Brackets []: They define optional items and they are not frequently used

Why Should we learn PowerShell?

  • Believe it or not, As per my experience from the past year using the command line made my life easier. This means that I completed a task that required 6 hours in 10 Minutes by writing scripts. :) 
  • Almost all the latest products from Microsoft can be manageable by using PowerShell, like System Center Products, Active Directory, Exchange Server, SQL, Share Point Etc :
  • As we all know, there is a big competition for new IT jobs that are available. Therefore it's better if you can list Windows Powershell among your skillset.