in just one hour i will make you a power shell ninja

14
In Just One Hour I Will Make You A PowerShell Ninja A Flying Start Into PowerShell

Upload: jason-brown

Post on 05-Dec-2014

130 views

Category:

Software


1 download

DESCRIPTION

A one-hour blast through the basics of PowerShell with particular focus on discovery within the environments, and with a demo at the end of a PowerShell take on Wordpress's Hello Dolly plugin

TRANSCRIPT

Page 1: In just one hour i will make you a power shell ninja

In Just One Hour I Will Make You A PowerShell

Ninja

A Flying Start Into PowerShell

Page 2: In just one hour i will make you a power shell ninja
Page 3: In just one hour i will make you a power shell ninja

What you should haveIn your meeting invite, you should have received a list of pre-reqs

● Laptop running Windows 7 or later (not RT)● A text file containing, line-by-line, the lyrics to your favourite

song ● Your typing fingers● Optional: exposure to other programming languages such as C,

C#, Java, Perl, Python, JavaScript or VBScript● Distractions are strictly banned. Close all non-powershell

windows and put your phone face down on the table.

Page 4: In just one hour i will make you a power shell ninja

What we will doA crash course into Powershell Basics, including:

● The Raw Language Basics - covered more fully in a later module

● The Help System and exploring the environment● The Pipeline● Working with files and folders● A quick peek at Profiles - covered more fully in a later module

It’s a lot to cover in an hour, and we’re bound to get sidetracked, so let’s get started

Page 5: In just one hour i will make you a power shell ninja

Getting StartedThis is a hands-on lab. Fire Up PowerShellThe icon looks like this:

Page 6: In just one hour i will make you a power shell ninja

Getting started with CmdletsCmdlets are what they sound like. They’re little commandsThey do stuff, usually fairly simple stuffThey Get- stuff. They Set- stuff. They Invoke- stuff. They Test- stuffThey’re the tiny engines of powershellMany of them have quick, snappy aliases

Page 7: In just one hour i will make you a power shell ninja

A thing called the pipelinethe pipeline allows you to string commands together, shunting data from left to right

Page 8: In just one hour i will make you a power shell ninja

OK, Yeah, but it’s better than thatConsider the following code snippet

Page 9: In just one hour i will make you a power shell ninja

The basics summarised● Variables are prefixed with a dollar sign● Code blocks are delimited with curly braces● Assignment operators are =, +, etc● Comparison Operators are -lt, -gt, -eq, -like etc● Commands (called Cmdlets in PS World) follow a

Verb-Noun convention● Powershell is extensible via Modules● But you REALLY don’t need to remember thisBecause….

Page 10: In just one hour i will make you a power shell ninja

Powershell is internally-documentedThere are Cmdlets that tell you about Cmdlets

● Get-Command● Get-Help● Get-Alias● Get-Module● Get-Member

Page 11: In just one hour i will make you a power shell ninja

Environment VariablesYou’ll also want to know about environment variables

$Env:$home$psversiontable

Page 12: In just one hour i will make you a power shell ninja

OK, so what next?So far you’ve just been working at the prompt

Now it’s time to start writing basic scripts.

First, let’s get set up

Page 13: In just one hour i will make you a power shell ninja

Simple functions Functions allow you to package up lumps of code and call them from other lumps of code.We’re going to write a function now.Then we’re going to modify itThen we’re going to run itThen (bonus!) we’re going to make it run whenever we start powershell

Page 14: In just one hour i will make you a power shell ninja

In summaryYou now have the tools you need to:● Run commands● Write scripts● Find help● Customise your environmentSo go forth and be a ninja