Friday 7 September 2018

PowerShell - Introducing the “Body of Water”

What is PowerShell?

PowerShell is (and will remain to be) used in most of Microsoft’s current line of server products. Although basic administrative tasks can usually be performed through a GUI, administrators must often delve into PowerShell to make infrastructure level configuration changes.  While this certainly does not hold true in every case, it is becoming more and more common to have to perform tasks using PowerShell.

But What is PowerShell?

PowerShell is the Microsoft Command Line Interface (CLI) for Windows based systems, products and the automation framework.  It consists of a command-line shell/editor (Input) and a scripting language that is built on top of the .NET Framework.
PowerShell provides full command-line access to the component object model (COM), data stores (such as the registry and the file system) and Windows Management Instrumentation (WMI). It enables the performing of administrative tasks on both local and remote Windows systems undertaken by suitably qualified technicians or systems administrators. 

PowerShell includes (but is not limited to):
  • Cmdlets for system administration tasks such as:
    • Managing the registry
    • Managing services, processes and event logs
  • Cmdlets that use common syntax and naming conventions (data can be shared; with the output from one cmdlet being used as the input to another cmdlet.)
  • Powerful object manipulation capabilities.
  • Extensible interface. Enterprise developers and/or administrators can build custom cmdlets or tools and utilities to administer software.
Output from a PowerShell cmdlet is always a .NET object. This could be a:
  • System.Diagnostics.Process object.
  • System.IO.FileInfo object.
  • System.String object, or
  • any .NET object whose assembly is loaded into PowerShell including custom .NET objects
Windows PowerShell can execute four kinds of commands:
  • cmdlets
  • PowerShell scripts
  • PowerShell functions
  • Standalone executable programs


If a command is a standalone executable program “PowerShell.exe” launches in a separate process. 
If it is a cmdlet, it is executed within the PowerShell process.

Why use PowerShell?

The extent to which software/product administration (of any kind) requires PowerShell (and by extension PowerShell knowledge) is intended to protect less experienced (or less knowledgeable) “administrators” from making “novice or simple” (often destructive) mistakes.

A basic administrative task can normally be performed through a products management console, but for many Microsoft server products, low level installation and/or configuration changes, and potentially destructive operations have to be performed through PowerShell.
It is presumed that “if an administrator knows enough to use a relevant PowerShell cmdlet”, then that person should know enough to safely perform the intended action and understand the expected outcome whilst mitigating any business risk.

In summary: performing an administrative task using PowerShell requires knowledge and intent and a deep founded interest and understanding of the expected outcome and potential business risk.

PowerShell: A History Lesson


Let us take a trip down PowerShell lane and revisit the versions and the main features introduced in each version.

A Long Time Ago, in a Developers Conference Far, Far Away

PowerShell (as we now know it) was publicly revealed at the Professional Developers Conference (Los Angeles) in October 2003. Code named "Monad", all major releases since are still supported with full backwards compatibility.  Following the public reveal, the first public beta release occurred on June 17, 2005, Beta 2 on September 11, 2005, and Beta 3 on January 10, 2006.
On April 25, 2006 Microsoft formally announced that "Monad" had been renamed "Windows PowerShell" followed quickly by Release Candidate 1.

PowerShell Version 1.0

Release Candidate 2 of PowerShell version 1.0 was released on September 26, 2006 with final RTW on November 14, 2006 for Windows XP SP2, Windows Server 2003 and Windows Vista.

PowerShell Version 2.0

PowerShell Version 2.0 was (still is) integrated with Windows 7 and Windows Server 2008 R2 and was released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2, and Windows Vista with Service Pack 1.
PowerShell 2.0 included changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.

New features of PowerShell 2.0 included:
  • PowerShell Remoting 
  • Background Jobs 
  • Transactions 
  • ScriptCmdlets 
  • Modules 
  • Script Debugging 
  • Windows PowerShell Integrated Scripting Environment (ISE) 
  • Exception Handling with Try-Catch-Finally 
  • Block Comments
  • Modules - allows script developers and administrators to partition PowerShell scripts in self-contained, reusable units. Code from a module executes in its own self-contained context and does not affect the state outside the module. Modules have a persistent state as well as public and private members.
  • ISE - a GUI-based PowerShell host that provides integrated debugger, syntax highlighting, tab completion in a tabbed UI, as well as the ability to run only the selected parts in a script.

PowerShell Version 3.0

PowerShell Version 3.0 is integrated with Windows 8 and with Windows Server 2012. It is also available for Windows 7 with Service Pack 1, Windows Server 2008 with Service Pack 1, and for Windows Server 2008 R2 with Service Pack 1.
PowerShell 3.0 is part of the Windows Management Framework (WMF) 3.0, which also contains the Windows Remote Management (WinRM) service to support PowerShell remoting.

New features in PowerShell 3.0 included:
  • Job Scheduling 
  • Session connectivity 
  • IntelliSense and Snippets 
  • Help update 
  • Automatic module detection

PowerShell Version 4.0 

PowerShell Version 4.0 is integrated with Windows 8.1 and with Windows Server 2012 R2. It has also been made available for Windows 7 SP1, Windows Server 2008 R2 SP1 and Windows Server 2012.

New features in PowerShell 4.0 included:
  • Desired State Configuration 
  • Default Execution Policy set to RemoteSigned 
  • Save-Help 
  • Enhanced debugging

PowerShell Version 5.0

An initial public preview of PowerShell 5.0 was made available with Windows Management Framework 5.0 (WMF5) on April 3, 2014.
On November 18th, 2014, Microsoft released the November 2014 Preview of the Windows Management Framework Core 5.0 package. Improvements were made to Desired State Configuration (DSC), OneGet, PowerShellGet, PowerShell class definitions, and debugging for PowerShell background jobs.

New features in PowerShell 5.0 include:
  • PowerShell class definitions (properties, methods) 
  • PowerShell .NET Enumerations 
  • Debugging for PowerShell Runspaces in remote processes 
  • Debugging for PowerShell Background Jobs 
  • Desired State Configuration (DSC) Local Configuration Manager (LCM) version 2.0 
  • DSC partial configurations 
  • DSC Local Configuration Manager meta-configurations 
  • Authoring of DSC resources using PowerShell classes

Basic Command Syntax

PowerShell is based around the use of cmdlets. 
Each cmdlet is constructed in a “verbnoun” combination.  The verb component refers to a word that describes an action to be undertaken, whilst the noun component refers to the object.  With that understanding, a PowerShell cmdlet is made up of two words, the first word (the verb) tells Windows what action you want to perform, while the second word (the noun) tells Windows what type of object you want to perform the action on.

Consider the following command:
Clear-Host
The verb (or action) in this case is “Clear”. 
What needs to be cleared (the Object)? The “host”.

This command will clear the screen back to the command prompt (in the PowerShell window).

To find a list of default PowerShell Verbs enter the following in a PowerShell console window:

Get-Verb
The verb (or action) in this case is “Get”. 
What needs to be returned? a list of accepted verbs thus the noun is “Verb”.

PowerShell vs DOS (Showing your Age)

If (like me) you grew up with MS-DOS, most of the old DOS commands work in a PowerShell environment. For example, the DOS command for clearing the screen was CLS. The CLS command can be used in PowerShell as an alternative(Alias) to the Clear-Host command.
There are many other PowerShell cmdlets that have a recogniseable Alias.

To find a list of default PowerShell cmdlets with an Alias enter the following in a PowerShell console window:
Get-Alias
The verb (or action) in this case is “Get”. 
What needs to be returned? a list of Aliases “Alias”.

Summary – The Ripple Effect

The Ripple Effect is based on the understanding that we are all connected. These connections stretch like an incredibly interwoven and complicated tapestry. Each of us exists within this tapestry. Thoughts and actions are like stones dropped in a pond and they create ripples that travel outward.

Now extend that into the world of PowerShell. Every action (be it, cmdlets or scripts) we undertake and the affects those actions have can cause a reaction – an orchestrated change (it is better planned than unplanned) within a controlled environment.  The nature of PowerShell means that many differing products and technologies can be administered via a PowerShell session.  These sessions can cross boundaries, can provide remote administration in place of actually needing to be present in front of a hardware or software platform.  These actions are informed choices made by a suitably experienced administrator that can have huge impacts and risks to a business, but are still under the control of the administrator to “press the execute” button.

How Many Cmdlets?

Windows Server 2012 R2 has many PowerShell cmdlets built into the operating system. PowerShell is fully extensible - You can even develop your own custom cmdlets.  Microsoft also provides modules that add additional PowerShell cmdlets that allow you to perform more specialised tasks. Microsoft server products based around PowerShell also have their own sets of cmdlets.  The sheer number of PowerShell cmdlets is vast.


Next Time...

Next time we will create our first splash in this ever increasing "body of Water"

Thanks for Reading

Mark


Saturday 1 September 2018

Skills, Common Sense and Making a Difference


The Weavers, Luddendenfoot

So it all started with "Mark, I have a little project for you". 

(Project = I need your help doing something......

Task: Help dad fix his band-saw.

On further investigation it appears that the good old band-saw in question had snapped a belt.

Dad had checked and asked around a number of ~ahem "engineering/tool repairers" with all saying..  NOOOOO that make is not in manufacture anymore, we can't fix that or some other lame assed excuse.

Fast forward to the day for me to earn browny points.. 💪😊

Jayne (she who must be obeyed) had already spoken to her dad about me not "bodging" stuff, that I'm slightly OCD when it comes to repairs or DIY or Anything really - After all that's what spirit levels and tape measures were invented for 👍

Where was I? Oh yes browny points... 

So we show up at mum and dads, and after the always warm greetings and small chit chat etc etc etc. me and dad enter his Man Cave..
  
There on the bench lies said pulley with a rubber belt that looks way too small.




We chat, we look at options using a vice, clamps and other methods, and agree that the said 1" wide belt needed to be stretched (it is rubber after all) to stand any chance of fitting.

Now I am no physics expert but understand resistance. After thinking about clamps and a vice, I discounted it as too dangerous, but it gave me an idea.. 

Enter a Caveman reference - Caveman relied on brute force and intelligence to overcome obstacles and challenges back in the day -

By changing the position of the pulley and using weight via my right foot I was able to pull/stretch said rubber belt vertically with ease and sufficient enough to allow dad to slide said belt successfully over the pulley.  

Job done, band-saw assembled and tested equals one happy dad (more browny points). 

Sometimes brawn and brains can work together.


The purpose for me telling this story is it made me realise just how many skills of yesteryear are being lost. Joinery, Carpentry, Brickies, Engineers (proper engineers, not those that have everything given electronically to them on a tablet. No use of Google to search for answers either!) the list goes on... 

In a society where people throw away stuff (not broken necessarily) and buy new (instead of repairing) it saddened me to think just how difficult it must be for people like dad who have the knowledge, have the skills, but physically are not able to do stuff themselves anymore, and go to "specialists" looking for help or advice only to be told "No" it cannot be fixed... 

This just feels like all people do these days is follow instructions.... What happened to Common Sense?

The reality is that today's society cannot be arsed with fixing stuff when it appears cheaper to replace than repair.  The skills of our fathers are slowly being forgotten and will soon go the way of the dodo.

Anyhow apologies if I offend, but as mentioned in my welcome blog, these are my own opinions.

Until next time.

Mark

Welcome to My World

Weird, Wacky, Remarkably Quiet (in this picture) - The glorious Hebden Bridge (Best Little Town in the World - IMO)

Hi and Welcome. 

So in a world that seems to be constantly evolving (naturally, socially, politically and technologically) I woke up and decided to join the stampede.  I can honestly say that at this time I have no idea what will flow from my brain to the canvas.  What I can say is that I am quite opinionated on certain things, things that seem blindingly obvious (in my eyes anyway), things where common sense should prevail, but is oft forgotten or disregarded.

Do I have an agenda? 

No, but I would like to write about things that drive me, my imagination and my interests.  This could (and almost certainly will) include Office 365, SharePoint, Productivity and Process Automation, Collaboration, Front End and Back End development (the Dark Arts) and supporting technologies.  
Also expect random posts on topics that are media (ed: modern day propaganda) driven, the state of our education 👨‍🎓👩‍🎓 system, social interests, personal interests and occasionally political ermmmm discussions (I am sure I forewarned you that these are my opinions 🤔).
  
Each post I will tag appropriately so that over time the tag cloud will grow. 
This may evolve and change into separate pages per topic. I honestly cannot see that far ahead yet. 
So welcome to My World 🌍 I hope you enjoy the Journey with me.

About Me

I live in a little village between Hebden Bridge and Halifax in West Yorkshire with my partner Jayne 👩‍❤️‍💋‍👨 and Sparky the cat 🐈(or fuzzbutt as she is oft called).
I can often be found staring out the window, blank faced (thinking about nothing) at the scenery surrounding us. "How can you be thinking about nothing?" I get asked. Quite easy really, it is my way of realising that being at peace and being happy can often open the mind to opportunities outside of the "black box". That no matter what the day may bring it always starts with a good morning and ends with a good night (before Mrs Bear 🐻 makes an appearance). 

Hebden Bridge really is the best little town in the world, nestled between converging valleys, the people can only be described as "peculiar" in the most amazing way.  
Great food and drink 🍻🥂, parades, gala's and festivities are always friendly and welcoming.  
A haven for Bikers 🏍️ and Cyclists (Road 🚴‍♀️ and mountain 🚵‍♀️) and let's not forget the walkers 🚶‍♂️, all exist in happy go-lucky tranquility. Giving us plenty of excuses to drink 🍺 while "people watching 👀". 

That's it for now, but expect more blathering 🔊 soon. 

Mark