How do I practice PowerShell?

“How do I stay in touch with PowerShell practice?”
Yes, this is one question is surely asked in all my PowerShell batches.
It’s obvious that people get overwhelmed with capabilities of PowerShell and wonder how do I keep practising. The biggest question is where do I start?

Well!!! PowerShell can answer that, PowerShell can solve that for you with following steps,

  1. Update-Help
  2. $PROFILE (Set up your PowerShell profile)
  3. Get-Help (Automated)

Lets try to understand more about the solution.

Step 1 – Update-Help

  • Update-Help cmdlet downloads the newest help files for Windows PowerShell modules and installs them on your computer.
  • You do not have to restart Windows PowerShell to make the change effective.
  • With this you will also get several about_* topics downloaded on your computer at C:\Windows\System32\WindowsPowerShell\v1.0\en-US and inside modules where latest help manuals are available.
  • This will lay the foundation for further steps.

Step 2 – $PROFILE

  • The $Profile automatic variable stores the paths to the Windows PowerShell profiles that are available in the current session.
  • A Windows PowerShell profile is a script that runs when Windows PowerShell starts.
  • You can use the profile as a logon script to customise the environment.
  • You can add commands, aliases, functions, variables, snap-ins, modules, and Windows PowerShell drives.
  • You can also add other session-specific elements to your profile so they are available in every session without having to import or re-create them.
  • Windows PowerShell supports several profiles for users and host programs. However, it does not create the profiles for you by default.
  • The Windows PowerShell console supports the following basic profile files. The profiles are listed in precedence order. The first profile has the highest precedence.

 

Different PowerShell Profiles

Different PowerShell Profiles

HOW TO CREATE A PROFILE :

To create a profile for the current user in the current Windows PowerShell host application, use the following command:

if (!(test-path $profile)) {

new-item -type file -path $profile -force

}

HOW TO EDIT A PROFILE:

You can use either of the following options at PowerShell prompt

  • Option 1
notepad $profile

opens profile file in notepad to edit.

  • Option 2
ISE $profile

opens profile file in PowerShell ISE (Integrated Scripting Environment) to edit.

ADD FOLLOWING CODE TO A PROFILE:

help about_* | 

ForEach-Object{

if (($_.Split())[0] -match 'about_'){

($_.Split())[0]

}

} |

Select-Object @{n='name';e={$_}} |

Get-Random |

Get-Help -ShowWindow

SAVE PROFILE CHANGES AND EXIT

Step 3 – Just Open PowerShell to Get-Help

The above code will execute every time you open PowerShell.

Technically,
- It pulls all the about topics
- Filters empty line and header row 
- From the output and just get the topic name as about_[topic] string
- Get-Random picks a random about_topic and passes to Get-Help
- Get-Help opens a topic in new window.
  • It will present you with one of the about_[topic] randomly. This will take out the burden of choosing topic.
  • Just make sure you read the presented topic at least for 5-10 minutes maximum.
  • I used to do this at least 3 times a day. Morning before starting work, just after lunch (before starting other work) and before I shutdown my computer at the end of the day.
  • So essentially minimum 15 minutes to maximum 30 minutes a day spent reading something about the PowerShell topics. Whenever I had extra time, I used to practice some of the examples from the about_topic.
  • This helped me register most of the topics in my head within 3-4 weeks of time.
  • Few years back, I was talking to someone on learning new skills and the person pointed out Rule Of 21 to me.
  • There are many articles if Google Or Bing it. Some of them even call it myth. I don’t want to talk PRO or CONS here about the same.
  • In my personal case it worked to gain good knowledge. Some of my participants also have responded that it was a helpful tip.

This slideshow requires JavaScript.

Food for thought: If you want to plan focused learning in every week, then you can extend the code. Have a starting and ending date. At the launch check if current dates falls in First, Second or Third week or more. Depending on that Get a random topic from the focused bucket.
i.e. Below command will select one command randomly from module NetAdapter. This was you can focus only on commands from selected module/area of learning.

Get-Command -Module NetAdapter | Get-Random | Select-Object Name

*Replace the Select-Object with Get-Help and you will get the help file.

That’s it for now.

If you like this tip do share your feedback. If you try this and find valuable, then do write me to with your experience.

All the best and enjoy PowerShell Scripting!!!

Reading, The Phoenix Project…

Last two months were exciting & pleasantly busy which took toll on my new year (2017) resolution to blog more regularly & consistently. It also broke the rhythm of reading books more often and as much as I can. To add to this my new kindle (Thanks to my wife Smita for an advance anniversary gift) was staring at me daily for attention :-). So… I decided to start reading something immediately.

I am currently working on revising my training content & demos for PowerShell DSC (Desired State Configuration). Sometime back I had heard recommendation from Jeffrey Snover @jsnover about this book titled The Phoenix Project: A Novel About IT, DevOps, and Helping Your Business Win

(Blog post images copyright & courtesy IT Revolution Press @ http://itrevolution.com)

Having followed Jeffrey over these years it was easy decision to pick a book from my wish list. I was lucky to find kindle edition available at very good price. I grabbed it immediately and started reading it. After going through Wikipedia, the Introduction and Chapter 1, sounds like… its going to an interesting read for sure with some fictionalization of real world problems and solutions.

Hope to finish this soon to get myself a new knowledge/perspective on DevOps, Continuous Delivery and related areas. And of course pass that to the participants during my upcoming batches.

(Help-Learn -ne Share-Knowledge)

Last week I was in Chennai delivering a training on PowerShell, at a very short notice.

This was a very different experience. I was called to deliver a batch on Automating Administration with Windows PowerShell®

More than the content, the context was different this time. This was started by another trainer but the participants were not happy with the delivery. The requirement came to me on Monday evening after 7:00 PM. I was expected to start the batch on Tuesday morning at 9:00 AM. That was definitely tough. I spoke to the vendor requesting at least a day to understand something about background and the context, which he agreed to. There were other surprises as well

One, 5 days content squeezed to 3 days.
Two, client was in Chennai.

While the first one was not quite a surprise as most people are trying to get the staff back to production/delivery sooner. I made sure that the expectation was set so that there are no arguments later over the duration and overall feedback. Thankfully, the vendor team agreed to the assumptions to avoid feedback risk. Fundamental assumption was most of the participants are experienced server admins and they know some level of PowerShell already. Therefore, 3 days were planned to cover the agenda.

The second surprise however was a bit hard to manage as I had to start travel in few hours. Having managed to get ready, it was fortune testing time for me.

The flight was scheduled for a 10:30 PM departure. After getting on the runway the pilot decided to go back to parking bay. The aircraft had some technical glitches making it unsafe for take off. It got rescheduled to 12:30 AM and eventually I reached Chennai at 3:00 AM on Wednesday. I barely slept for three and half hours. The training was to commence at 9:00 AM and I reached at 8:20 AM to class room.

Participants were told 9:30 AM so I got some preparation time. That’s the only hour I got to plan my delivery to ensure that the training goes smooth. By the time everyone joined it was 9:45 AM and the training eventually started. I had to share the last evening experience with participants before setting the tone for agenda.

Introductions are generally 10 to 20 minutes but this time I extended to almost an hour. It was not just to get names, I wanted to understand there area of work, expertise and what they expect from the training. That conversation helped me so much to get an exact idea about what needs to be done to help them learn. The day one feedback was 4.8 out of 5.

chennaiday1feedback

After seeing that, all the stress taken 24 hours before was flushed. It also gave me a motivation to finish on a higher note (which did happen with similar feedback).

In my last 5 training’s, I was able to help the participant implement PowerShell learning to solve their existing problem. For some, it was a migration from the batch files to PowerShell and for some it was how to approach automation with PowerShell learning.

I repeated my practice of encouraging participants to talk about real-life technical issues they face. By the third day there was one participant who could change his two batch file approach to a single PowerShell script for their production. This was an acknowledgement for me that I delivered a successful training in true sense.

So my learning,

  • Be real about your capabilities and limitations and overcome inhibitions.
  • As a trainer focus should be on enabling learning & discovering than knowledge sharing & content delivery.
  • Knowledge sharing may limit to content delivery however learning enablement pushes students/participants to think about solving technical problems.
  • Knowledge sharing may remain as notes with participants but enablement helps them accomplish something real and remember for a long time.
  • While planning is good, sometimes one has to take bold steps/risks to establish credibility.