Featured

Are you Mature..?

Towards Maturity

In the Beginning

How did it all start?

Like any other day I’m trying to work My PowerShell Fu-Do to create a tool to aid my cohorts, aid me.

The tool a mashup of Win32_DiskDrive and Win32_Volume classes to create a new Custom Object. The point of which is to gather the information I need to extend storage on the SAN .

Little Google Fu-Do and a great article from @Don Jones

Windows PowerShell: The Many Ways to a Custom Object gets me started

Which Led to My 12 PowerShell Best Practices

By the way of the 12 Practices

  1. Never use Write-Host …. I don’t I love Puppies!!
  2. Avoid $ErrorActionPreference … Wasn’t aware of it Score for ignorance
  3. Indent your Code
    1. {
      1. Fine
      2. }
  4. Spell out cmdlet and and parameter names I do mostly
  5. Don’t use Hungarian Notation … Ok … but can I still use Camel-Case?
  6. Use Multi-Purpose comments
  7. Use mostly single quotes
  8. Use Source control –Working on with internal Team Foundation Server our Dev group uses, we are moving InfraScrum to it from Jira… Maybe.
  9. Use Code signing already implemented in house with our internal CA
  10. Use cmdlet style naming
  11. Avoid Global scope
  12. Output objects… The reason this article started

And…..

That got me to thinking. Best practice implementation leads to maturity as you strive to make your enterprise the best it can be.

My take ways were

  • Security First
  • Use good coding practice
  • Don’t use Write-Host puppies puppies puppies
  • Get Ops to learn good Development Skills and practices
  • Use a repository like GIT stop storing your scripts all over the environment. They end up like being pockets of Ebola.
  • Standardization
  • Repeatability
  • Code Re-use
  • Ad Nauseum

As Operations folks we need to learn some better practices around how we write code and we are going to write more code in future infrastructure operations.

To me maturity is indicated by standard processes that are repeatable by all team members. Standard repeatability is aided by templating your environment. Maturity aids workflow reduces chaos.

Some of the process areas I’m thinking through involve the use of a TFS Git repository as we consider moving our Agile SCRUM process from Jira to the Team Foundation Server. Our team has seen this as positive move to help merge our teams as we move into the DevOps culture.

This is the first of hopefully many Blog Posts…

 

 

 

 

Footer ONe

Spelunking PowerShell

Where We compare exploring PowerShell to caving…

Jeffery Snover encourages us to explore PowerShell, spelunking I believe he calls it. Spelunking is the art of cave exploring the Urban dictionary has other definitions NSF. Spelunking is pursued due to the great enjoyment practitioner’s experience, Snover wants us to experience the same joy with PowerShell.

Steve Knutson editor of the National Speleological society termed the untrained and inexperienced  as a ‘spelunker’ and denoted  those who were trained and experienced ‘cavers’. Our goal is to go from Spelunker to PowerSheller, I suppose spelunkers probably wear the title like some of us wear the title hacker, and those who see the term as derogatory. For my Brothers in the UK I believe the correct term is Potholer, and you say we yanks screw up the language..

Spelunkers have tools helmets, head lamps, rope, knee and elbow pads and apparently cups thanks @jsnover. These tools help them explore the caves they seek out. PowerShellers have tools too, Get-Help, Get-Command, Help about_*, and don’t forget the helmet or -Whatif  and cup -CONFIRM which are parameters which let you explore safely. Get-Help along with Help about_ are like guidebooks written by the original explorers.

This article will teach the basic use of these tools let’s enter the cave.

Down the Rabbit Hole
Down the Rabbit Hole

Get-Command think of get command as the flashlight which let’s you see in the dark. Caves have features Powershell has cmdlets. These cmdlets follow a basic semantic pattern of verb+noun.

Get-Command
#alias
GCM

Get-Help Get-Help allows you to further explore commands once you’ve discovered them.  Get-Help is like the guidebook that helps you navigated an already discovered cave feature.

Get-Help Get
#Alias
Help
Man

Get-Verb  Gets the list of approved verbs. You can find guidance here https://msdn.microsoft.com/en-us/library/ms714428(v=vs.85).aspx . They get pretty pissy if you deviate… For good reason. Although I wonder if they have a User voice for dictionary adds.
Cavers write guides and maps to the caves they have explored and for PowerShell this guidebook is Get-Verb.

Entering Get-Verb at the PowerShell prompt yields the following truncated, for space ,results.

Get-Verb
Verb        Group
----        -----
Add         Common
Clear       Common
Close       Common
Copy        Common
Enter       Common
Exit        Common
Find        Common
Format      Common
Get         Common
Hide        Common
Join        Common
Lock        Common
Move        Common
New         Common

Help About_*  IF Get-Command is a flashlight, the about _* is the full guidebook. The About topics cover the core topics and concepts of PowerShell.  About topics are part of the help system

Helpful parameters

Helpful comment from the father of PowerShell in terminology

-Whatif  Put on your helmet and add this to parameter as you crawl to end of your Pipeline.

Set-ADForest -Windows2012Forest -Whatif

-Confirm Definitely a cup it’s your last form of protection from a mistake that could indeed leave you breathless

 Set-ADForest -Windows2012Forest -Confirm

These are the basic commands to let you explore the cave that is PowerShell.

Cavers Resources

The cavers Guidebook to PowerShell starts with Learn Windows PowerShell in a Month of Lunches, Third Edition Don Jones@concentrateddon and  Jeff Hicks @JeffHicks . Note this is a MEAP which means the book is being published in chapters. The 2nd Edition can be found on the same site.

Learn PowerShell Toolmaking in a Month of Lunches also by Don Jones and Jeff Hicks also on the Manning Press site.

Lee Holmes @Lee_Holmes PowerShell Cookbook

Video Resources

The video responsible for this mess

Explore PowerShell unplugged with Jeffrey Snover & Don Jones

Stephen Owens Gave his first Big Talk at ignite on the basics of PowerShell and the response was so great he got his own ignite Video

MVP HubTalk Stephen Owen – Intro to PowerShell

Stephen is a real up and comer Check out his blog below in the Link to Fox Deploy in the Blogs I follow section.

 

 

Enjoy!