PowerShell and 'Get-Help' Basics

Hi Viewers, hope you all are doing well!. This is my First blog of 2019.

In this blog we'll learn about a bit of powershell and its components and gradually we'll learn how to make scripts in upcoming blogs. We'll also get an idea of command-lets which would help in enhancing our scripting skills.

So lets get started with PowerShell Basics..

Firstly you should know What is PowerShell and why it was discovered.

PowerShell is not a scripting tool... Does this seems crazy?

Yes you heard it right PowerShell is not a scripting tool though its used to create scripts or to create automation tools or to do automation but the primary function of powershell tool is to perform real time management functions or you can say its a interactive real time management command tool which allows you or system engineer to manage system resources beat if its users, applications, servers or deployments etc...

This was Discovered by Jeffrey Snover who is currently Technical Fellow and Chief Architect for Azure Storage & Cloud Edge at Microsoft  and have 41 patents so far on his name.. wooohhh!!

For more details about Jeffrey refer below link from Wiki.
"https://en.wikipedia.org/wiki/Jeffrey_Snover"

Jeffrey with his other two designers from Microsoft lead this project, in order to make things much more easier for a System Administrator to work on a machine and figure out the things of his/her own by discovering cmdlets and create a autonomous script to perform his/her tasks of its own. So kind of you Jeff!!

PowerShell consists of command-lets or cmdlets which are kind of built in functions created in .NET framework. Powershell was first introduced in November 2006 is dependent on .NET Framework and Windows Management Framework (WMF) versions.

PowerShell VersionRelease Date and .NET Framework versionDefault Windows VersionsAvailable Windows Versions
PowerShell 1.0November 2006

2.0
Windows Server 2008 (*)Windows XP SP2
Windows XP SP3
Windows Server 2003 SP1
Windows Server 2003 SP2
Windows Server 2003 R2
Windows Vista
Windows Vista SP2
PowerShell 2.0October 2009

2.0, 3.0, or 3.5 with Service Pack 1
Windows 7
Windows Server 2008 R2 (**)
Windows XP SP3
Windows Server 2003 SP2
Windows Vista SP1
Windows Vista SP2
Windows Server 2008 SP1
Windows Server 2008 SP2
PowerShell 3.0September 2012

4.0
Windows 8
Windows Server 2012
Windows 7 SP1
Windows Server 2008 SP2
Windows Server 2008 R2 SP1
PowerShell 4.0October 2013

4.5
Windows 8.1
Windows Server 2012 R2
Windows 7 SP1
Windows Server 2008 R2 SP1
Windows Server 2012
PowerShell 5.0February 2016

4.5
Windows 10Windows 7 SP1
Windows 8.1
Windows Server 2012
Windows Server 2012 R2
PowerShell 5.1January 2017

4.5
Windows 10 Anniversary Update
Windows Server 2016
Windows 7 SP1
Windows 8.1
Windows Server 2008 R2 SP1
Windows Server 2012
Windows Server 2012 R2

So the above table would clear what version of Framework is required on which version of Powershell and also on which servers these are applicable. 

Lets start with scripting basics now.

Powershell provides you numerous command-lets in their inventory and there are around 1000+ cmdlets in 6th version of Powershell and its pretty hard to remember all cmdlets. So how can we remember all those command-lets? Is there any way to learn these command-lets?


You need Help...


Yes, you heard it right you need a Help command-let, which will help you to learn things easier and you do not have memorize the filthy commands. You can play around with this command as it won't harm your machine or prod servers. You can use it any time on any windows machine except the old legacy ones as MS do not support those now (2000, NT, etc). Help command-let is a very basic command-let which is a first step to understand the basics of Scripting.

This command-let is followed by a search keyword or a command-let which you are searching for. Get-Help command-let will provide you a detailed information of a command-let of which you are unclear where it will show syntax of command-let, aliases(if any), examples (if any) etc. Even get-help or help command-let can search a key word as well. Below is an example how to run help command-let in powershell, you can choose either way to run this command-let.

PS C:\>Get-Help Get-Service

Or

PS C:\>Help Get-Service

Get-Help command example.



Above command will provide you detailed information on Get-Service command-let and you can see what all properties a Get-Service command-let has, you can also refer to the examples. Suppose you are writing a script and you got stuck in-between as you are not getting the name of the command-let...

Now What??

Ghosh!! am I stuck again???

No, you are not. All you've to do is not to panic, sit back and relax. Powershell will help you. You've to run this command in your powershell console and see the Magic!!

PS C:\>Help *Service*

Now you might be thinking why I have use stars (*) before and after name service, well these asterisks are the Key Finders, which sends information to the powershell tool to find a command-let or any object with the name service beat what ever is in front or back of this word.

Below is the example for finding numerous command-lets/functions with the name service

PS C:\> help *service* | Format-Table -AutoSize
Help also get you information from a Key word as well.

There is one thing which needs to be noted is always update your help inventory. This will give you a updated inventory in your help bucket if there is any update from Microsoft. All you need to update help inventory is internet facing machine and run Update-Help command-let.


Try to Play with Help Command and explore more.

Comments

Popular posts from this blog

Command-Lets and Module

Getting started with Powershell