Neil Iversen Inetium

Slides:



Advertisements
Similar presentations
Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
Advertisements

DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
Jason Himmelstein, MVP Senior Technical Director,
James Boother Blog: INTRODUCTION TO POWERSHELL.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Linux+ Guide to Linux Certification, Second Edition
Neil Iversen Inetium justaddcode.com. The Plan  PowerShell Sales Pitch  Creating Scripts  Type Extensions  Rolling your own Cmdlets  Other Extensionibility.
1 Classic ASP vs. ASP.NET Technical Information and Market Adoption Lance Welker University of San Diego Dr. Rebman MSIT 526 December 20, 2005.
Great people, great experience, great passion Administering SharePoint with Windows PowerShell Go Beyond the Management Shell with SharePoint and Windows.
Basic.  Powershell scripts are flat text files that end with “.ps1” (e.g. myscript.ps1)  Similar to other scripting languages, whatever you can do on.
SharePoint 2010 Administration using PowerShell Brian Caauwe Senior Consultant – SharePoint – MCTS March 20, 2010.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Scripting Languages CS351 – Programming Paradigms.
INTRODUCTION TO POWERSHELL Neil Iversen. Points of Interest  Introduction  Getting Around  Basic Syntax  Making yourself at ~  Not-So-Basic Syntax.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Basic.  PS is a command line interpreter/scripting environment  Designed for.Net  Similar to C#  Easy to instantiate.Net classes  Standardized syntax.
Introduction to UNIX A User’s Perspective: Day 2 – Command Basics.
POWERSHELL Dr. Sarah Gothard CEG 233 Spring 2010.
Connect with life L.Srividya Architect Advisor | Microsoft India.
Overview of Microsoft.Net and Vb.Net ITSE 2349 Spring 2002 Material from Microsoft.Net an Overview for ACC faculty by Stuart Laughton and Introduction.
© 2007 Asynchrony Solutions, Inc. 1 10/29/07 Introduction to PowerShell Brian Button VP Engineering Asynchrony Solutions, Inc
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
 Adnan Niazi November UNIX Lecture Goals  Goal 1: Know basic UNIX commands and their use.  Goal 2: Understand the basic structure of a common.
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Introduction to Shell Script Programming
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Windows PowerShell Deep Dive 1 Morgan Simonsen Ementor.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Microsoft ® Official Course Module XA Using Windows PowerShell ®
PowerShell Basics. o PowerShell is a great way to manipulate server and/or workstation components o It’s geared toward system administrators by creating.
An Introduction to Unix Shell Scripting
July 17, 2003Serguei A. Mokhov, 1 Shells and Shell Scripts COMP 444/5201 Revision 1.3 January 25, 2005.
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
Linux+ Guide to Linux Certification, Third Edition
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 11: Shell.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Good Morning and Thank You!.  Have some Fun!  Learn at least one thing new!  Make myself available to you So please …  Ask questions and enjoy!
Module 1: Configuring Windows Server Module Overview Describe Windows Server 2008 roles Describe Windows Server 2008 features Describe Windows Server.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
Univ. of TehranDistributed Operating Systems1 Advanced Operating Systems University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani.
Kemtis Kunanuraksapong MSIS with Distinction MCTS, MCDST, MCP, A+
PowerShell For SharePoint Developers Neil Iversen Inetium
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
Linux and Java Basics. What is Linux? Operating system by Linus Torvalds that was a clone of Unix (thus Linux) Free and open source – this is the reason.
What’s New in SharePoint 2010 SharePoint 2010 Development Primer New Developer Tools for SharePoint 2010 SharePoint 2010 Integration with PowerShell.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
CS252: Systems Programming Ninghui Li Slides by Prof. Gustavo Rodriguez-Rivera Topic 7: Unix Tools and Shell Scripts.
Windows PowerShell Introduction 1 Morgan Simonsen Ementor.
 An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is.
POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access.
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Windows PowerShell. What is Windows PowerShell? A command-line interface (CLI) A new way of developing Windows and other products to be more manageable.
Module 14: Advanced Topics and Troubleshooting. Microsoft ® Windows ® Small Business Server (SBS) 2008 Management Console (Advanced Mode) Managing Windows.
Linux Administration Working with the BASH Shell.
Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.
Ravikanth C.
PowerShell 5 & Windows 10. What are we covering today? What is PowerShell? Why is PowerShell important? Some simple demos on Windows 10.
Start-SPPowerShell – Introduction to PowerShell for SharePoint Admins and Developers Paul BAker.
INF230 Basics in C# Programming
The Linux Operating System
INTRODUCTION TO UNIX: The Shell Command Interface
Introduction to PowerShell
SharePoint Saturday Omaha April 2016
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Cmdlets “Command-lets”
Lab 4: Introduction to Scripting
Bash Scripting CS 580U - Fall 2018.
Presentation transcript:

Neil Iversen Inetium

Introduction  Developer at Inetium  Watch out for the tumbleweeds  Vocal PowerShell Enthusiast

The Plan  Introduction to PowerShell  I sell you on PowerShell  You sell PowerShell

What’s this PowerShell Nonsense?

cmd.exe

+

unix cmdline

+

.net

=

An ugly, but powerful shell

Great, cmd.exe was fine for me  Talk to MS Marketing Initially promoted as a fancy shell Currently primarily marketed to Administrators Starting to gain traction among the developer set ○ (that’s you)

Why do I care?  It’s a good shell  You can do dev in it  You can do dev for it  Reduce time spent testing  Reduce time spent debugging

Very Scientific Language Usefulness Continuum (Patent Pending) SysAdmin Printer Drivers C++.NET (C#/VB.NET) Scripting Languages (Ruby, Python) BASH, SH  PowerShell

Developing Faster  Traditional SharePoint Development Time wasted during Testing  PowerShell /.NET Hybrid Development ‘Risky’ development done in PoSH Code converted to.NET (C#/VB) Shorter Deploy/Test Cycle CodeCompileDeployTest Prototype (PoSH) CodeCompileDeployTest CodeCompileDeploy

PowerShell as a Shell

PowerShell as a Shell Getting Around  dir  cd  del  Mkdir  help  ls  cd  rm  mkdir  man

PowerShell as a Shell Core Components  Alias  cd = set-location  Dir = get-childitem  Cmdlet  Workhorse of PowerShell

PoSH Basics  Verb-noun: write-host, where-object,get-content  Help is your friend help write-host help write-host –detailed Help *write*

PS> Lets see that shell

PowerShell as a Scripting Language  Luckily PowerShell is more than a cmd.exe replacement  Loosely typed variables $foo = “bar” (implicit string) $ary = 1,2,3,4 (object array)  Strongly typed variables [string]$foo = “bar”  Enhanced Types [xml]$d = “ c stuff 1 c stuff 2 ” $d.a.b.c (array of strings)

PowerShell as a Scripting Language  Providers Emulate a ‘drive’ navigation structure Extensible Examples ○ Registry ○ Active Directory ○ SharePoint

Conditions and Flow Control  Some Operators  -eq  -lt / -gt  -le / -ge  -like / -notlike  -match / -imatch  Control  If  switch  help about_comparison_operators

The Pipeline  First some background: In DOS/Unix ○ Dir | more Run a directory and ‘pipe’ the output to the More command Actually passes the resulting text to the next command Unix has advanced text manipulation functions to parse In PowerShell ○ Dir | more Passes the.NET Objects between commands System.IO.FileInfo in this case

The Pipeline  The most unique feature of PowerShell  Since everything in PowerShell is a.NET type, it can be passed as an argument  Enables a LINQ-esque experience  C#: foo = Class.Method(); Bar = OtherClass.Method(foo); Baz = OtherOtherClass.Method(bar)  PowerShell: Class.Method() | OtherClass.Method() | OtherOtherClass.Method()

Common Pipeline Commands  Foreach-object  dir | foreach-object { $_.Name }  Alias: dir | % { $_.Name }  Where-object  dir | where-object {$_.Length –gt 10}  Alias: dir | ? {$_.Length –gt 10}  Select-object  dir | select-object –first 5  Alias: none  Honorable Mentions: Sort-Object, Group- Object

Dealing with Output FormattingOutput  Format-Custom  Format-List  Format-Table  Format-Wide  Out-Default  Out-Null  Out-Host  Out-Printer  Out-String

Making yourself at ~  Microsoft.PowerShell_profile.ps1 .bashrc .tcshrc .whatEverKSHuses  Be lazy, $profile tells you where to go  PS> notepad $profile  Common Uses  Custom prompt()  Load custom variables and scripts  Snapins  Make it Less Ugly

PS> Lets see that scripting language

PowerShell as a Programming Language  Everything in PowerShell is a.NET type $foo = “bar” (System.String) $ary = 1,2,3,4 (System.Object[])  Using this knowledge we can call anything we’d use in C# or VB.NET  Couple Language Things [System.Drawing.Color]::Blue – Enum [System.Reflection.Assembly]::Load() - Static Method

PowerShell as a Programming Language  Loading.NET Assemblies [System.Reflection.Assemby]::LoadFrom(‘some. dll’)  Get-Member – Describes functions and properties on an object  New-object – creates a new object COM or.NET object Calls the constructor $someObject = new-object System.ArrayList

PowerShell as a Programming Language  PowerShell has build in Reflection  Get-Member Returns all the Properties and Methods for an object Ex: ls | get-member  Provides a good interface to explore objects

PowerShell as a Programming Language  Updating Types  Similar to Extension Types  Add-Member Add new Methods/Properties to an instance  Use ps1xml file to make changes semi-permanent and always applied for a specific.NET type

PS> Lets see that programming language

Interesting PowerShell Bits  Reading/Parsing Native CSV,XML read/write  Serialization Import-CLIXML, Export-CLIXML Save off.NET objects and then rehydrate them

Advanced V2 Features  Threading Start-PSJob Stop-PSJob Wait-PSJob Receive-PSJob  Remoting Enables Remote PowerShell calls to be performed Implemented using the Threading commands  Combine the two, and you have a pretty compelling option for distributing load.

Enhancing the Experience  The default shell is ugly Setup your $profile Get Intellisense ○ Customizations allow inline intellisense Community kit ○ Lots of good discussion and controls 3 rd Party Shells ○ Host PowerShell in a different UI PowerShell Plus PowerShell Analyzer PoshConsole

PS> Lets see some extensible examples

Extensibility Points  Ps1xml  Cmdlets  Script cmdlets (v2)  Snapins  Modules (v2)

Creating a Cmdlet  Compiled and Portable  Bundled together in a Snapin  Inherit from CmdLet  WriteObject() Sends data back to the Pipeline  [ Cmdlet(VerbsCommon.Get, “CmdletName“]  Script Only CmdLets in V2

Hosting PowerShell  Two Levels of Difficulty Execute Commands Host the UI

Hosting PowerShell  Execute Commands The easiest option  RunspaceInvoke.Invoke(“dir”)  Returns PSObject(s)

Hosting PowerShell  Host the UI Very difficult  Can provide immense amounts of power  Examples: PowerShellPlus PoshConsole

PS> Lets see it all together

Reducing Testing/Debugging Time  Eliminate Arguments It works on my pc Its impossible to know what that server is thinking  Delve Deeper See the running state as a problem occurs No need to redeploy code to test theories PSUnit for Unit Testing

Other Interesting Uses  PowerShell ASP  PowerShell as an Extensibility Methog  PowerBoots  PowerShell as a DSL

PS> Lets see something…different

References  PoshCode –  PowerTab - PowerTab/default.aspx  PowerShell Community Extensions  PowerShell Plus -  PoshConsole  PowerBoots – PowerBoots.codeplex.com  Huddled Masses (Jaykul) – huddledmasses.org

Questions?

Thanks! Neil Iversen Inetium