Basic fundamentals of PowerShell made easy.

In this session will start from when, what, where and cover the basic fundamentals of PowerShell that will get you started on the right track. If you ask what PowerShell is to people around you, you will get variety of answers. Do not get confused. I will take you step by step with appropriate examples.

Windows user/admins has never enjoyed the magnificent shell scripting environments that Linux have. This phenomenal change happened with addition of PowerShell as a feature within Windows Server 2008, and now the inclusion of PowerShell as part of the Windows as Microsoft’s command-line shell and scripting language.

Time when I thought to try PowerShell, and it was a hard time to get answer o
What to write? Where to write? AND many more….

Let’s start answering top 10 questions one by one that has arrived at first time.

  1. What is PowerShell?

PowerShell is Microsoft in-built Command Line Interface feature of Windows Operating System.

  1. How to Open Interface?

Start

Fig 0.1 Start

Right Click

Fig 0.2 Right Click

  1. How it Look?

Console and ISE

Fig 0.3 Console and ISE

  1. Which host to use for writing scripts?

The Windows PowerShell Console and Integrated Scripting Environment (ISE) are two hosts for the Windows PowerShell engine and language. With ISE you can write, run, and test scripts in ways that are not available in the Windows PowerShell Console. The ISE adds syntax-coloring, tab completion, IntelliSense, visual debugging, and context sensitive Help.

Console pane is attached to ISE.

  1. What is the version I am using?

Command to get PowerShell version is $PSVersionTable.PSVersion.

Version

Fig 0.4 Version

PowerShell 1.0 is the first version released on November 2006 for Windows Server 2008.

Latest version of PowerShell is PowerShell 5.1 as shown above which is the first version to come in two editions of “Desktop” and “Core”. Latest in core is PowerShell Core 6.0.

  1. What are other Operating Systems which support PowerShell?

PowerShell uses .NET on Windows OS, you can run PowerShell on any operating system that has the Common Language Runtime (CLR).

For other operating systems (Like Linux), you can use the CoreCLR, an open-source, cross-platform subset of the .NET Framework.

  1. Which Sample Command I should Run?

PowerShell Commands are called Cmdlets and pronounced as command-let (not CMD-let)

Cmdlets are in the form of singular Verb-Noun syntax such as Get-Service is pronounced Get Service ignoring the dash

As a first command you can start with Get-ChildItem, gci, dir, ls in any folder location.

Sample Command

Fig 0.5 Sample Command

  1. How to get Help?

Get-Command

The Get-Command is one of the most useful cmdlets in the whole of PowerShell, as it will help you getting to grips with PowerShell by letting you search for certain cmdlets.

Get-Command

Fig 0.6 Get-Command

Get-Help

Once you have found the cmdlet you are looking for using Get-Command, you would want to know the syntax of that specific cmdlet. This is where Get-Help comes in picture.

Command Help

Fig 0.7 Command Help

And if you want to find CMDlets related to disk.

Word Help

Fig 0.8 Word Help

  1. How to change format of result?

Let’s use Get-Service cmdlet.

Default Result –

Default Table Format

Fig 0.9 Default Table Format

Table Format – Desired column sequence

Table Format

Fig 0.10 Table Format

List Format

List Format

Fig 0.11 List Format

Format Wide

Wide Format

Fig 0.12 Wide Format

HTML Format

HTML Format

Fig 0.13 HTML Format

HTML Output as a File

Out Put as HTML File

Fig 0.14 Out Put as HTML File.

  1. What PowerShell uses from Windows System?
  • Administer processes — To list, monitor, stop, and start processes.
  • Manage the file system — To create, delete, modify, and set permissions for files and folders.
  • Administer services — To list, stop, start, restart, and even modify services.
  • Manage the Registry — To list, monitor, stop, and start processes.
  • Use Windows Management Instrumentation (WMI) — To manage other platforms such as IIS and Terminal Services.
  • Use existing Component Object Model (COM) objects — To complete an extensive variety of automation tasks.
  • Administer several Windows roles and features — To add or remove roles and features.

PowerShell modules bring extendibility to the systems administrator, DBA, and developer.

In my next article I will talk about

What is WMI?
How to write Scripts?
How to automate daily work?

Happy Coding.
Thanks for reading
Keep reading , share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.
Stay tuned on Knowledge-Junction, will come up with more such articles / news

Advertisements

Leave a Reply