INTRODUCTION TO POWERSHELL Neil Iversen. Points of Interest  Introduction  Getting Around  Basic Syntax  Making yourself at ~  Not-So-Basic Syntax.

Slides:



Advertisements
Similar presentations
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Advertisements

Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
Jason Himmelstein, MVP Senior Technical Director,
Find Command Characteristics –Locate files descending from multiple starting points –Employs regular expressions Examples On entire system: >find / -name.
James Boother Blog: INTRODUCTION TO POWERSHELL.
Neil Iversen Inetium justaddcode.com. The Plan  PowerShell Sales Pitch  Creating Scripts  Type Extensions  Rolling your own Cmdlets  Other Extensionibility.
Neil Iversen Inetium
SharePoint 2010 Administration using PowerShell Brian Caauwe Senior Consultant – SharePoint – MCTS March 20, 2010.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
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.
Kirk Jackson Senior Developer, Xero Wellington.NET Users Group SVR308.
© 2007 Asynchrony Solutions, Inc. 1 10/29/07 Introduction to PowerShell Brian Button VP Engineering Asynchrony Solutions, Inc
Managing Citrix Farms Using MFCOM and Powershell.
Presenters: Winfred Wangeci Jignash Reddy.  It is Microsoft's new task-based command- line shell and scripting language designed especially for system.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
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.
PowerShell Basics. o PowerShell is a great way to manipulate server and/or workstation components o It’s geared toward system administrators by creating.
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
Module 3 Administering and Automating SharePoint.
Monad The New Microsoft Command Shell Peter Provost
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
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!
CN1266 Network Scripting V1.2 Kemtis Kunanuraksapong MSIS with Distinction MCTS, MCDST, MCP, A+
Next Unix Topics Tuesday, 2/11 & 18/2014. Change Password (by 2/14/14) ssh to account on – faclinux.cse.ohio-state.edu – stdlinux.cse.ohio-state.edu passwd.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
Kemtis Kunanuraksapong MSIS with Distinction MCTS, MCDST, MCP, A+
PowerShell For SharePoint Developers Neil Iversen Inetium
Unix, Linux, DOS, Windows Command Line CSE 660 May 12, 2008.
Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output.
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.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
File and Folder CLI Commands 12/24/ Agenda Overview of OS functions and the SHELL Internal v External Commands Command History Making & Modifying.
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.
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
Sed. Class Issues vSphere Issues – root only until lab 3.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
The Unix File sytem. Introduction Tree structure …
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
Ravikanth C.
Introduction to Unix for FreeSurfer Users
PowerShell SUNISH SURENDRAN KANNEMBATH
Operating Systems Shell Commands & Script Programming
PowerShell Introduction Copyright © 2016 – Curt Hill.
CSC 352– Unix Programming, Spring 2016, Final Exam Guide
Andy Wang Object Oriented Programming in C++ COP 3330
Linux/Unix - Download Ubuntu Linux :
Introduction to PowerShell
02 | The Help system Jeffrey Snover | Distinguished Engineer & Lead Architect Jason Helmick | Senior Technologist, Concentrated Technology.
02 | The Help system Jeffrey Snover | Distinguished Engineer & Lead Architect Jason Helmick | Senior Technologist, Concentrated Technology.
© 2007 Asynchrony Solutions, Inc. 1 10/29/07 Introduction to PowerShell Brian Button VP Engineering Asynchrony Solutions, Inc
Introduction to PowerShell
SharePoint Saturday Omaha April 2016
Making PowerShell Useful
Technology Methos IT Making your PowerShell scripts X times faster… with logical thinking and PowerShell v3 Jeff Wouters Technology Specialist.
PowerShell Best Practices for SQL DBA’s
Making PowerShell Useful
Andy Wang Object Oriented Programming in C++ COP 3330
Cmdlets “Command-lets”
Introduction to Bash Programming, part 3
Chapter 4: The Linux Filesystem
Presentation transcript:

INTRODUCTION TO POWERSHELL Neil Iversen

Points of Interest  Introduction  Getting Around  Basic Syntax  Making yourself at ~  Not-So-Basic Syntax  Questions

Introduction  Developer at Inetium   Really late breaking news  I am not an Administrator

What is PowerShell?  Different things to different people  It’s a  Shell  Cool.bat file  VBScript replacement  Admin’s Best Friend  Developer’s Best Friend  …

cmd.exe

+

unix cmdline

+

.net

=

An ugly, but powerful shell

Getting Around  dir  cd  del  Mkdir  help  ls  cd  rm  mkdir  man

Core Components  Alias  cd = set-location  Dir = get-childitem  Cmdlet  Workhorse of PowerShell  Function  Block of script  Provider  Adds alternate ‘directory structure’  Think ‘/proc’ only niftier  Get-PSdrive  Snapin  Group of PowerShell functionality

PS> Lets see that shell

PoSH Basics  Verb-noun: write-host, where-object,get-content  Help is your friend  help write-host  help write-host –detailed  Help *write*  $variable  Scopes: global, script,local  {} scriptblocks

PoSH Basics - Variables  $foo = “bar”  $anArray = 1,2,3,4  [int]$someInt = 5  [xml]$xmlDoc = “ stuff ”  [MyClass.MyType]$someThing

PS> Lets see that shell

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

More PoSH Basics: Pipeline  Everything is a System.Object  Unless its something more useful  dir | where-object {$_.Length –gt 5} | select- object –last 2 | sort-object -prop Extension – desc  $anArray | sort

The Most Useful 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

PS> Lets see that shell

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

PS> Lets see that shell

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 shell

Not-So-Basic Syntax  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

Pseudo-Reflection  Get-Member  List out Methods, Properties and their arguments  Add-Member – Adds a Property or Method  dir | add-member -passthru -membertype scriptmethod -name Something {write-host "Some file: "$this.Name} | %{$_.Something()}  ps1XML Files – Extend Object Types  Example: ConvertToBase64 on Files

PS> Lets see that shell

LINQ and PowerShell LINQPowerShell int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; var lowNums = from n in numbers where n < 5 select n; Console.WriteLine("Numbers < 5:"); foreach (var x in lowNums) { Console.WriteLine(x); } $numbers = 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 Write-host “Numbers < 5:” $numbers | ?{$_ -lt 5}

Other Practical Uses  Exchange 2007  The Admin UI calls PowerShell  Active Directory Manipulation  New-Object DirectoryServices.DirectoryEntry "LDAP://cn=kenmyer, ou=Finance, dc=fabrikam, dc=com" | Select-Object name, telephoneNumber  Full suite of WMI calls

Useful Projects  PowerShell Analyzer –  PowerTab - /tags/PowerTab/default.aspx  Console.exe -  PowerShell Community Extensions -  PowerShell Remoting -

Diversions  WPF in PoSH  Space Invaders  Text to Speech

Questions?

Giveaway 2 Copies of PowerShell Analyzer – Final Version Using PowerShell of Course! (gc names.txt)[(get-random -min 0 -max ((gc names.txt).Length-1))] OR (Get-Date).AddDays((get-random -min 1 -max 365))

Thanks!