SlideShare a Scribd company logo
1 of 14
In Just One Hour I Will 
Make You A PowerShell 
Ninja 
A Flying Start Into PowerShell
What you should have 
In 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.
What we will do 
A 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
Getting Started 
This is a hands-on lab. Fire Up PowerShell 
The icon looks like this:
Getting started with Cmdlets 
Cmdlets are what they sound like. They’re little commands 
They do stuff, usually fairly simple stuff 
They Get- stuff. They Set- stuff. They Invoke- stuff. They 
Test- stuff 
They’re the tiny engines of powershell 
Many of them have quick, snappy aliases
A thing called the pipeline 
the pipeline allows you to string commands 
together, shunting data from left to right
OK, Yeah, but it’s better than that 
Consider the following code snippet
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 this 
Because….
Powershell is internally-documented 
There are Cmdlets that tell you about Cmdlets 
● Get-Command 
● Get-Help 
● Get-Alias 
● Get-Module 
● Get-Member
Environment Variables 
You’ll also want to know about environment 
variables 
$Env: 
$home 
$psversiontable
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
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 it 
Then we’re going to run it 
Then (bonus!) we’re going to make it run whenever 
we start powershell
In summary 
You now have the tools you need to: 
● Run commands 
● Write scripts 
● Find help 
● Customise your environment 
So go forth and be a ninja

More Related Content

What's hot

Inter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message QueuesInter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message Queueswamcvey
 
Locker: distributed consistent locking
Locker: distributed consistent lockingLocker: distributed consistent locking
Locker: distributed consistent lockingKnut Nesheim
 
Go performance tooling
Go performance toolingGo performance tooling
Go performance toolingAdil Hafeez
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQBuild reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQRobin Xiao
 
PHP tutorial | ptutorial
PHP tutorial | ptutorialPHP tutorial | ptutorial
PHP tutorial | ptutorialPTutorial Web
 
TDD in the Web with Python and Django
TDD in the Web with Python and DjangoTDD in the Web with Python and Django
TDD in the Web with Python and DjangoCarlos Ble
 

What's hot (7)

Inter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message QueuesInter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message Queues
 
Locker: distributed consistent locking
Locker: distributed consistent lockingLocker: distributed consistent locking
Locker: distributed consistent locking
 
Go performance tooling
Go performance toolingGo performance tooling
Go performance tooling
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQBuild reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
 
PHP tutorial | ptutorial
PHP tutorial | ptutorialPHP tutorial | ptutorial
PHP tutorial | ptutorial
 
PHP at Density and Scale
PHP at Density and ScalePHP at Density and Scale
PHP at Density and Scale
 
TDD in the Web with Python and Django
TDD in the Web with Python and DjangoTDD in the Web with Python and Django
TDD in the Web with Python and Django
 

Viewers also liked

Skepticamp in theory and practice
Skepticamp in theory and practiceSkepticamp in theory and practice
Skepticamp in theory and practiceJason Brown
 
Agile australia dealing with disruption
Agile australia   dealing with disruptionAgile australia   dealing with disruption
Agile australia dealing with disruptionMark Cohen
 
Talk - Skepticamp Melbourne 2011
Talk - Skepticamp Melbourne 2011Talk - Skepticamp Melbourne 2011
Talk - Skepticamp Melbourne 2011Jason Brown
 
Domain's Robot Army
Domain's Robot ArmyDomain's Robot Army
Domain's Robot Armydomaingroup
 
Why and how to test logging - DevOps Showcase North - Feb 2016 - Matthew Skelton
Why and how to test logging - DevOps Showcase North - Feb 2016 - Matthew SkeltonWhy and how to test logging - DevOps Showcase North - Feb 2016 - Matthew Skelton
Why and how to test logging - DevOps Showcase North - Feb 2016 - Matthew SkeltonSkelton Thatcher Consulting Ltd
 

Viewers also liked (6)

Skepticamp in theory and practice
Skepticamp in theory and practiceSkepticamp in theory and practice
Skepticamp in theory and practice
 
Agile australia dealing with disruption
Agile australia   dealing with disruptionAgile australia   dealing with disruption
Agile australia dealing with disruption
 
Talk - Skepticamp Melbourne 2011
Talk - Skepticamp Melbourne 2011Talk - Skepticamp Melbourne 2011
Talk - Skepticamp Melbourne 2011
 
DevOps at Domain
DevOps at DomainDevOps at Domain
DevOps at Domain
 
Domain's Robot Army
Domain's Robot ArmyDomain's Robot Army
Domain's Robot Army
 
Why and how to test logging - DevOps Showcase North - Feb 2016 - Matthew Skelton
Why and how to test logging - DevOps Showcase North - Feb 2016 - Matthew SkeltonWhy and how to test logging - DevOps Showcase North - Feb 2016 - Matthew Skelton
Why and how to test logging - DevOps Showcase North - Feb 2016 - Matthew Skelton
 

Similar to In just one hour i will make you a power shell ninja

Topic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.pptTopic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.pptralph581247
 
Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...Holden Karau
 
Getting big without getting fat, in perl
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perlDean Hamstead
 
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Holden Karau
 
PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)Concentrated Technology
 
Introducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betaIntroducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betadigitalzombie
 
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptxThe-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptxalo154283
 
Improving your shell usage - 2009
Improving your shell usage - 2009Improving your shell usage - 2009
Improving your shell usage - 2009Chris Sinjakli
 
Contents Pre-requisites Approximate .docx
   Contents Pre-requisites  Approximate .docx   Contents Pre-requisites  Approximate .docx
Contents Pre-requisites Approximate .docxShiraPrater50
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdflailoesakhan
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the ToolmakersCaleb Callaway
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksGlen Ogilvie
 
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfDatabase & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfInSync2011
 

Similar to In just one hour i will make you a power shell ninja (20)

Linux shell ggsipu-lug
Linux shell ggsipu-lugLinux shell ggsipu-lug
Linux shell ggsipu-lug
 
Topic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.pptTopic2IntroductionToJavaProgramming.ppt
Topic2IntroductionToJavaProgramming.ppt
 
Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...Simplifying training deep and serving learning models with big data in python...
Simplifying training deep and serving learning models with big data in python...
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Getting big without getting fat, in perl
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perl
 
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...
 
PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)PowerShell Scripting and Modularization (TechMentor Fall 2011)
PowerShell Scripting and Modularization (TechMentor Fall 2011)
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
 
Introducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betaIntroducing Yeoman 1.0 beta
Introducing Yeoman 1.0 beta
 
Database Management Assignment Help
Database Management Assignment Help Database Management Assignment Help
Database Management Assignment Help
 
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptxThe-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
 
X page developer
X page developerX page developer
X page developer
 
Improving your shell usage - 2009
Improving your shell usage - 2009Improving your shell usage - 2009
Improving your shell usage - 2009
 
Contents Pre-requisites Approximate .docx
   Contents Pre-requisites  Approximate .docx   Contents Pre-requisites  Approximate .docx
Contents Pre-requisites Approximate .docx
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the Toolmakers
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
NANO266 - Lecture 9 - Tools of the Modeling Trade
NANO266 - Lecture 9 - Tools of the Modeling TradeNANO266 - Lecture 9 - Tools of the Modeling Trade
NANO266 - Lecture 9 - Tools of the Modeling Trade
 
Debugging ZFS: From Illumos to Linux
Debugging ZFS: From Illumos to LinuxDebugging ZFS: From Illumos to Linux
Debugging ZFS: From Illumos to Linux
 
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfDatabase & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Recently uploaded (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

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

  • 1. In Just One Hour I Will Make You A PowerShell Ninja A Flying Start Into PowerShell
  • 2.
  • 3. What you should have In 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.
  • 4. What we will do A 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
  • 5. Getting Started This is a hands-on lab. Fire Up PowerShell The icon looks like this:
  • 6. Getting started with Cmdlets Cmdlets are what they sound like. They’re little commands They do stuff, usually fairly simple stuff They Get- stuff. They Set- stuff. They Invoke- stuff. They Test- stuff They’re the tiny engines of powershell Many of them have quick, snappy aliases
  • 7. A thing called the pipeline the pipeline allows you to string commands together, shunting data from left to right
  • 8. OK, Yeah, but it’s better than that Consider the following code snippet
  • 9. 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 this Because….
  • 10. Powershell is internally-documented There are Cmdlets that tell you about Cmdlets ● Get-Command ● Get-Help ● Get-Alias ● Get-Module ● Get-Member
  • 11. Environment Variables You’ll also want to know about environment variables $Env: $home $psversiontable
  • 12. 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
  • 13. 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 it Then we’re going to run it Then (bonus!) we’re going to make it run whenever we start powershell
  • 14. In summary You now have the tools you need to: ● Run commands ● Write scripts ● Find help ● Customise your environment So go forth and be a ninja

Editor's Notes

  1. This is where we use the lyrics you brought along. We want to make something a little akin to Wordpress’s “Hello Dolly” plugin, which shows a random lyric from Hello Dolly on Admin pages First, we want to open that text file and load it into a variable. We have a cmdlet that can do that for us called Get-Content By default, Get-Content loads a file line-by line into an array of strings. This is perfect for our needs. Try it. Do $lines = Get-Content “filename.txt” and then write $lines to the screen. Good. We’re loading the lyrics Now we need a cmdlet that can pick a random number for us. Get-Help random should tell you what we have available. Now we could use that cmdlet with a -maximum value of the array length, then pick the corresponding element from the array, but we don’t have to, because Get-Random takes pipeline input Try it. Try $lines | Get-Random Ooooh look. Assign that to a variable, $line = ($lines | Get-Random) $line Now we can package that into a function Do ctrl-j, press F and pick Function put your code inside Function Get-Lyric { $lines = Get-Content $homelyrics.txt $randomline = ($filecontent | Get-Random) Write-Host $randomline -foregroundcolor yellow } Oooh, you have a function Highlight the function. Press F8 or hit the “run selection” button Your code is now interpreted and ready to use Type Get-Lyric in the command area Press enter Tada! You have a working function. But we can make it much more elegant, using the pipeline to shunt data from the left to the right Function Get-Lyric { Get-Content $homelyrics.txt | Get-Random | Write-Host -foregroundcolor yellow } Now we can get it to run every time we load powershell type ise $profile.CurrentUserAllHosts paste in your function Type a function call just underneath it Save it. Close all your powershell windows start a new powershell session TADA!! Now type Get-Lyric DOUBLE TADA!! And we’re done.
  2. You have all the information you need now to go ahead and start writing awesome powershell scripts You know how to query the help system you know how to call commands and use parameters you know how to write functions You know how to sort, query and filter you know about the ISE - and you should REALLY be using the ISE you know about the pipeline you know how to customise your powershell profile But most importantly you know how to find the information you don’t have Now, delete the shortcut to cmd.exe and replace it with powershell. Get into the habit of starting powershell instead of a command line and whenever you want to do something, consider if you can do it by typing a command Closing Test Questions What cmdlets might I use if I want to do something in PowerShell but can’t remember what the exact command is? What Cmdlet might I use to fire of a request to a REST Service? I want to do a wildcard search of a long array. What cmdlet and what comparison operator might I use? What’s the command to open my default profile in the ise? I need to know if a folder exists, what cmdlet might I use? I want to open a text file, what cmdlet do I use? Why is the pipeline important?