Git Product home page Git Product logo

pskoans's Introduction

PowerShell Koans

PSKoans Logo
Build Status

Inspired by Chris Marinos's fantastic F# koans, the goal of the PowerShell koans is to teach you PowerShell by presenting you with a set of questions. Each kōan (each question) is represented by a failing Pester test. Your goal is to make those tests pass by filling out the correct answer, or writing the correct code. The koans start very simple to get you familiar with the basic concepts and progress towards more difficult. Teaching you multiple beginner, intermediate and advanced aspects of PowerShell in the process.

To get started please navigate to prerequisites and getting started.

Table of Contents

Prerequisites

  • Windows PowerShell version 5.1 / PowerShell 6+
  • Pester

To install the latest version of Pester, use the appropriate command for your version of PowerShell:

# PS 5.1 (upgrade to latest Pester)
Install-Module Pester -Force -SkipPublisherCheck -Scope CurrentUser

# PS 6.0+ (Install Pester under current user)
Install-Module Pester -Scope CurrentUser

Getting Started

Install from Gallery

  1. Install-Module PSKoans -Scope CurrentUser

Or clone the Repo

  1. git clone the repository into your desired directory, or download the repository as a .zip file and extract into a directory of your choice.
  2. From a normal powershell session run Get-ChildItem -Recurse | Unblock-File in that directory to remove the "downloaded from internet" flag that blocks them from running.
  3. Check Get-ExecutionPolicy: if it says 'Restricted' or 'Undefined', you need to also run Set-ExecutionPolicy RemoteSigned in order to allow the scripts to run.
  4. Add the repository folder to $env:PSModulePath so that PowerShell can see it.
    • From the repository main folder, run: $env:PSModulePath = "$(Get-Location)$([IO.Path]::PathSeparator)${env:PSModulePath}"

Start your Journey

1. Run Measure-Karma to start your journey towards PowerShell enlightenment

You will be presented with a page describing your goal:

    Welcome, seeker of enlightenment.
    Please wait a moment while we examine your karma...

Describing 'Equality' has damaged your karma.

    You have not yet reached enlightenment.

    The answers you seek...

Expected strings to be the same, but they were different.
Expected length: 5
Actual length:   2
Strings differ at index 0.
Expected: 'True!'
But was:  '__'
-----------^

    Please meditate on the following code:

[It] expects you to fill in values
at <ScriptBlock>, C:\Users\Joel\PSKoans\Foundations\AboutAssertions.Koans.ps1: line 32
32:        '__' | Should -Be 'True!'

    ▌ Mountains are merely mountains.

    You examine the path beneath your feet...

 [AboutAssertions]: [――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――] 0/4

 [Total]: [―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――] 1/279

Type 'Measure-Karma -Meditate' when you are ready to begin your meditations.

Inspect the red messages carefully, most importantly the last one. The error message contains path to the file that you need to edit in order to progress forward. In this case, you'll need to examine Foundations\AboutAssertions.Koans.ps1.

2. Run Measure-Karma -Meditate to open your Koans folder

Navigate to Foundations\AboutAssertions.Koans.ps1. Near the top you'll see:

It 'is a simple comparison' {
    # Some truths are absolute.
    '__' | Should -Be 'True!'
}

The __ represents a blank for you to fill, and | Should -Be 'True!' shows the expected result. To pass this koan you need to replace __ with True!, like this: 'True!' | Should -Be 'True!'.

3. Run Measure-Karma again to see how you did

You passed your first koan! You'll notice that your overall progress updated to 1/279 and you are presented with the next challenge.

    Welcome, seeker of enlightenment.
    Please wait a moment while we examine your karma...

Describing 'Equality' has damaged your karma.

    You have not yet reached enlightenment.

    The answers you seek...

Expected 3, but got .

    Please meditate on the following code:

[It] expects you to fill in values
at <ScriptBlock>, C:\Users\Joel\PSKoans\Foundations\AboutAssertions.Koans.ps1: line 32
32:        __ | Should -Be (1 + 2)

    ▌ The most important thing is to find out what is the most important thing.

    You examine the path beneath your feet...

 [AboutAssertions]: [▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰―――――――――――――――――――――――――――――――――――――――――――――] 1/4

 [Total]: [―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――] 1/279

Type 'Measure-Karma -Meditate' when you are ready to begin your meditations.

You are on your own from here, but the progression should be fairly smooth. If you need help, you can always ask around in the PowerShell communities:

Good luck!

Contributing

We have a great many topics to cover, including the near-infinite slew of PowerShell cmdlets that all deserve koan coverage. Naturally, we're happy to accept any and all help that comes our way!

There are two main ways you can contribute:

  1. Feel more than free to clone the repository, make some changes, and submit a pull request!
  2. Submit any small changes you'd like make to any of the koans as an issue on the repository, and either myself or one of the helpers here will be happy to talk it over and get it sorted out.

Writing Koans

If you are writing a koan file, the header of the file must follow this format.

using module PSKoans
[Koan(Position = $Index)]
param()

Comments can be placed around this area if you feel the need to as well.

$Index should be an unsigned integer. The index indicates the order in which the koans should be sorted. Try to pick an index that is unused and makes sense in the progression of lessons. If you think it should be placed between two existing koan files, make sure to modify other indexes as necessary so that we can properly review the pull request.

The goal of the koans is to help those who have very limited knowledge learn PowerShell. In order to do that, simplicity and accessibility are key. There are some advanced topics out there that deserve coverage, and in order to cover them effectively we need to deal with them as clearly and simply as possible. If you need a hand, don't be afraid to simply submit the pull request before it's ready. You're more than welcome to submit WIP pull requests for early feedback and to ask for help if you're not sure how to proceed. We're more than happy to offer our own suggestions and help for your ideas!

If you just want to make a general comment, some recommendations, or if you want to suggest a koan topic to cover, feel free to submit your thoughts as an issue. I try to keep up to speed with those as best I can. 😄

pskoans's People

Contributors

brianmakes avatar chrislgardner avatar friedrichweinmann avatar gpduck avatar indented-automation avatar nohwnd avatar nqui avatar puthuppu avatar rdbartram avatar steviecoaster avatar thomasrayner avatar vexx32 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.