Basic.  PS is a command line interpreter/scripting environment  Designed for.Net  Similar to C#  Easy to instantiate.Net classes  Standardized syntax.

Slides:



Advertisements
Similar presentations
Types and Arithmetic Operators
Advertisements

Fundamentals of Python: From First Programs Through Data Structures Chapter 2 Software Development, Data Types, and Expressions.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
The scanf Function The scanf function reads input from the standard input device into one or more variables Example: scanf(“%lf”, &miles); Reads a real.
Some basic I/O.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 – Part 2 Wanda M. Kunkle.
1 Data types, operations, and expressions Overview l Format of a Java Application l Primitive Data Types l Variable Declaration l Arithmetic Operations.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
Basic Input/Output and Variables Ethan Cerami New York
POWERSHELL Dr. Sarah Gothard CEG 233 Spring 2010.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
Presenters: Winfred Wangeci Jignash Reddy.  It is Microsoft's new task-based command- line shell and scripting language designed especially for system.
Python Programming Fundamentals
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
Module 1: Introduction to C# Module 2: Variables and Data Types
1 2 2 Introduction to Java Applications Introduction Java application programming –Display messages –Obtain information from the user –Arithmetic.
Windows PowerShell Deep Dive 1 Morgan Simonsen Ementor.
Fundamentals of Python: First Programs
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
General Features of Java Programming Language Variables and Data Types Operators Expressions Control Flow Statements.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Basic Java Syntax CSE301 University of Sunderland Harry R Erwin, PhD.
C Programming n General Information on C n Data Types n Arithmetic Operators n Relational Operators n if, if-else, for, while by Kulapan Waranyuwat.
Monad The New Microsoft Command Shell Peter Provost
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Chapter 2: Using Data.
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!
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Beginning C++ Through Game Programming, Second Edition
Console Quick Script Functions Advanced Functions Modules Console Quick Script Functions Advanced Functions Modules.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Variables, Expressions and Statements
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript, Fourth Edition
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Chapter 2 Variables.
Windows PowerShell Introduction 1 Morgan Simonsen Ementor.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
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.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
 Version 1.0[edit]edit  Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003,
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
PowerShell SUNISH SURENDRAN KANNEMBATH
Java Primer 1: Types, Classes and Operators
Computing with C# and the .NET Framework
Starting JavaProgramming
Cmdlets “Command-lets”
Module 2 Variables, Data Types and Arithmetic
DATA TYPES There are four basic data types associated with variables:
Presentation transcript:

Basic

 PS is a command line interpreter/scripting environment  Designed for.Net  Similar to C#  Easy to instantiate.Net classes  Standardized syntax  PS is object based – not text based  This includes pipeline processing  Reduces need for reading process to parse data  V1.0 does not naturally support remote execution.

Start->Programs->Windows Powershell->Windows Powershell

 Expressions  Cmdlet  PowerShell Functions  PowerShell Scripts  Native Windows Commands - Also -  Supports direct interpolation

 Let’s start by looking at the environment  PS Drives give you access to resources in a consistent manner – similar to Unix’s approach to files and devices  PS Drives provide access to folders/files, the registry, existing functions and variables etc  Enter the following at the command line:

Enter the following lines at the command prompt and observe the behavior: #Key in this line and the rest below 54 (54 * 3 ) – 2 "Patrick is " + 54 Get-Date

() {} - Grouping ++, -- Increment, decrement, respectively +, - Unary operator * or *= Multiplication. / or /= Division. % or %= Modulus + or += Addition. - or -= Subtraction. = Assigns a value to a variable Standard rules of precedence apply.

In.Net everything is an object.

TypeDescription [int]32-bit signed integer [long]64-bit signed integer [string]Fixed-length string of Unicode characters [char]A Unicode 16-bit character [byte]An 8-bit unsigned character [bool]Boolean True/False value [decimal]An 128-bit decimal value [single]Single-precision 32-bit floating point number [double]Double-precision 64-bit floating point number [xml]Xml object [array]An array of values [hashtable]Hashtable object

129 + "1" "1" [int]"0129" + 1 [datetime]"10/20/2009" "We are meeting on " + get-date "We are meeting on " + (get-date)

 Let’s explore this by entering the following (120).GetType() "Patrick Bailey".GetType() "Patrick Bailey".ToUpper() “Pat has " + "Pat".Length + " letters." (Get-Date).AddYears(-5)

$a = $a.GetType() $b = "Patrick" $b.GetType()

$a = 1,2,3,4,7,"How do you do", 9,(Get-Date) $a $a[2] $a[3..6] $a[-1]

$list Paul" = [datetime]"10/20/2009"; ` "Minneapolis" = [datetime]"11/17/2009"} $list $list["St Paul"] Line continuation

 Cmdlets are instances of.NET Framework classes; they are not stand-alone executables.  Cmdlets do not generally do their own parsing, error presentation, or output formatting. Parsing, error presentation, and output formatting are handled by the Windows PowerShell runtime.  Cmdlets process input objects from the pipeline rather than from streams of text, and cmdlets typically deliver objects as output to the pipeline.  Cmdlets are record-oriented because they process a single object at a time.

 131 Cmdlets in v1.0, 237+ in V2.0  verb-noun naming (e.g. get-childitem)  Elements of a command : command -parameter1 -parameter2 arg1 arg2 Command Name Switch Parameter Parameter with argument Positional Argument Ref:

 Enter each of these and observe Get-Command Get-Command -Verb Set notepad Get-Process Get-Process notepad Get-Service -Name *sql* Ref:

 -ErrorAction Behavior when an error occurs. Values include SilentlyContinue, Continue (defualt), Stop  -Confirm Before execution the command will ask user for continuation option. Mostly available with commands that alter resources.  -ErrorVariable Variable to assign error object to.  -WhatIf Describes the action that would be taken – does not execute command

Set-Content demofile.txt "Hello`nThis is the second line." –Confirm Get-Content demofile.txt -OutVariable txtContent $txtContent Remove-Item demofile.txt –WhatIf Remove-Item demofile.txt Remove-Item demofile.txt #yes this repeats it Remove-Item demofile.txt -ErrorAction SilentlyContinue

 Most cmdlets, as you have seen, produce objects for their output. Literal values do the same.  Get-Member provides a listing of the public members of those objects  By default it displays public instance members

 Similar to traditional scripting languages  BUT it “pipes” objects – specifically.Net objects  Access to data is through methods and properties – not string parsing* *Of course, any property of type string has the expected set of methods for returning modifications of the string.

"Pat winks" | Get-Member Get-Process | Get-Member [Int32] | Get-Member [Int32] | Get-Member –Static [Int32]::MaxValue

“It’s not rude to point” notepad;notepad $plist = Get-Process notepad $p1 = $plist[0] $p1 | Get-Member $p1.HasExited Stop-Process -Id $p1.Id $p1.HasExited

notepad;notepad;notepad Get-Process | Where-Object { $_.Name -eq "notepad" } Get-Process | Select-Object Handles, Id, ProcessName Get-Process -Name notepad | ForEach-Object { Stop-Process $_.Id }

 Script blocks – think of them as anonymous methods or short inline scripts  $_ is similar to Perl’s use as the current value in process

 get-service  new-service  restart-service  set-service  stop-service  start-service