PowerShell. Scripting in Windows Environments Gergő Ládi

Size: px
Start display at page:

Download "PowerShell. Scripting in Windows Environments Gergő Ládi"

Transcription

1 PowerShell Scripting in Windows Environments Gergő Ládi

2 About Me MSc BUTE (BME) Member of KSZK since 2011 Relevant certifications: Gergő Ládi (me@gergoladi.me) 2

3 Outline What is PowerShell? Versions Features Scripting in PowerShell PowerShell 101: cmdlets, aliases, comments, variables, (using) operators, control structures, working with files Advanced scripting: functions of your own, custom aliases, using.net classes, loading dynamic code PSProviders & PSDrives, remoting, package management Gergő Ládi 3

4 CLIs in 2016 :O?! Gergő Ládi

5 CLIs in 2016 :O?! One might be tempted to think that Command Line Interfaces are a thing of the past Both GUIs and CLIs have their own strengths and weaknesses CLIs are more efficient, Less RAM, CPU, disk usage Operations usually take less time to perform Possibility of automation but have a steeper learning curve Unusual, confusing at first Tens (hundreds) of commands with different syntaxes Feedback: less, later Gergő Ládi (me@gergoladi.me) 5

6 What is PowerShell? Gergő Ládi

7 A bit of history COMMAND.COM MS-DOS cmd.exe Windows NT cscript.exe / wscript.exe Windows 98 Monad (2002) -> Windows PowerShell 1.0 (2006) XP SP2, Server 2003, Vista, (WS 2008) 2.0 (2009) Windows 7, Windows Server 2008 R2 3.0 (2011) Windows 8, Windows Server (2013) Windows 8.1, Windows Server 2012 R2 5.0 (2015) Windows 10, Windows Server Gergő Ládi (me@gergoladi.me) 7

8 Notable features Object oriented (1.0) Modular (2.0) PowerShell Remoting (2.0, 3.0) Integrated Scripting Environment (2.0, 3.0) Supports debugging (breakpoints) (2.0) Asynchronous operations (2.0) Transactions (2.0) Desired State Configuration support (4.0, 5.0) Package management support (5.0) Syntax highlighting inside the command line (5.0) Gergő Ládi 8

9 Where is PowerShell used? Windows client operating systems App-V Windows server operating systems Active Directory Microsoft Exchange Skype for Business (formerly Lync) Computer viruses CryptoWall, POSHCODER Gergő Ládi 9

10 PowerShell Gergő Ládi

11 PS Cmdlets Cmdlet: a command that performs operations Not a separate executable May take input from the pipeline and may have an input parameter list Has the form Verb-Noun Get-Help Get-Help Get-Command Get-Help Get-ChildItem Examples Remove-Item C:\Windows\notepad.exe -WhatIf Get-ChildItem -File -Path "C:\Windows" Select-Object Name, Length Sort-Object -Descending Length Gergő Ládi (me@gergoladi.me) 11

12 PS Aliases Alias: a shortcut that invokes a different command (usually one of a longer name) gci, ls, dir -> Get-ChildItem del, rm -> Remove-Item cat, gc -> Get-Content gh, man -> Get-Help To list all available aliases Get-Alias Gergő Ládi (me@gergoladi.me) 12

13 PS Comments Comment: line(s) that are not meant to be interpreted by the parser, but convey information to the (other) programmers # This is a comment. <# This is a multi-line comment #> Get-Help Get-ChildItem # This is an in-line comment Gergő Ládi (me@gergoladi.me) 13

14 PS Variables Variable: a language construct that can be used to store values Must begin with the $ sign, e.g. $MyVariable Working with variables $Name = "Jonathan" # String $Age = 42 # Integer $Hobbies "Sleeping", "F...") # Array $John Name = $Name; Age = $Age; Hobbies = $Hobbies } # Hash $UserDirContents = Get-ChildItem -Path "C:\Users\$Name" Gergő Ládi (me@gergoladi.me) 14

15 PS Variables Working with variables (cont'd) Write-Host "$Name is $Age years old." # Will be substituted Write-Host '$Name is $Age years old.' # Won't be substituted Write-Host "Next year, he'll be $($Age + 1)" # In-line eval. Write-Host "$($John.Name) is a nice guy." # Accessing a member write-host "$NAME FOR PRESIDENT!" # Cmdlet and variable names are case-insensitive Gergő Ládi (me@gergoladi.me) 15

16 PS 101 Operators -lt, -le, -gt, -ge : <, <=, >, >= -eq, -ne : ==,!= -band, -bor, -bxor, -bnot : bitwise operators -contains, -notcontains -like, -notlike, -match, -notmatch Gergő Ládi (me@gergoladi.me) 16

17 PS 101 Using operators Using comparison operators $Age -lt 18 $Name -eq "jonathan" $Name -ceq "jonathan" $Hobbies -contains "Eating" $Name -like "Jo?ath*" " Epoch" -match "\d{4}\.[0-9]{1,2}\.\d{1,2}\. [a-za-z]*" Gergő Ládi 17

18 PS Control structures Control structure: a structure that analyses state information and changes the execution path based on this If, If-Else, If-ElseIf-Else, For, ForEach, While, Examples If ($John.Age -lt 18) { Write-Host "John is under 18!" } ElseIf ($John.Age -eq 18) { Write-Host "John is exactly 18!" } Else { Write-Host "John is over 18! } Gergő Ládi (me@gergoladi.me) 18

19 PS Control structures For ($i = 0; $i -lt 60; ++$i) { Write-Host $i Start-Sleep Milliseconds 100 } ForEach ($Hobby in $Hobbies) { Write-Host "John likes $Hobby" } Gergő Ládi (me@gergoladi.me) 19

20 PS Control structures Write-Host "Starting countdown!" $i = 10 While ($i gt 0) { Write-Host ($i--) Start-Sleep -Milliseconds 100 } Write-Host "Done." Gergő Ládi (me@gergoladi.me) 20

21 PS 101 Working with files $Hobbies Out-File "JohnsHobbies.txt" $Contents = Get-Content JohnsHobbies.txt # Quotes can be omitted $UserDirContents Export-Csv JohnsFiles.csv $ImportedData = Import-Csv JohnsFiles.csv Gergő Ládi (me@gergoladi.me) 21

22 PowerShell Gergő Ládi

23 PS 201 Functions of your own Function: a block of code that can be called multiple times Function Touch-File($File) { If (Test-Path -Path $File) { (Get-ChildItem -Path $File).LastWriteTime = [System.DateTime]::Now } Else { New-Item -Path $File Out-Null } } Gergő Ládi (me@gergoladi.me) 23

24 PS 201 Aliases, $PROFILE New-Alias -Name touch -Value Touch-File touch MyFile.txt # is equivalent to Touch-File File MyFile.txt $PROFILE: a script that is executed each time a shell is opened Add custom function declarations and aliases here to make them permanent Gergő Ládi (me@gergoladi.me) 24

25 PS 201 Using.NET classes It is possible to use any BCL classes from the respective.net Framework version You can also load classes from an external assembly or compile code on-the-fly $Date = [System.DateTime]::Now Gergő Ládi (me@gergoladi.me) 25

26 PS 201 Using.NET classes $TcpClient = New-Object System.Net.Sockets.TcpClient $TcpClient.Connect("max.sch.bme.hu", 25) $TcpClient.ReceiveTimeout = 5000 $Buffer = New-Object Byte[] 1024 $Recvd = $TcpClient.Client.Receive($Buffer) Write-Host ([System.Text.Encoding]::ASCII).GetString($Buffer, 0, $Recvd) Gergő Ládi (me@gergoladi.me) 26

27 PS 201 Using.NET classes $DataToSend = "EHLO" + [Environment]::NewLine $Buffer = [System.Text.Encoding]::ASCII.GetBytes($DataToSend) $TcpClient.Client.Send($Buffer) Out-Null $Buffer = New-Object Byte[] 1024 $Recvd = $TcpClient.Client.Receive($Buffer) Write-Host ([System.Text.Encoding]::ASCII).GetString($Buffer, 0, $Recvd) $TcpClient.Close() Gergő Ládi (me@gergoladi.me) 27

28 PS 201 Loading dynamic code $MyDynamicCode namespace MyNamespace { public static class MyClass { public static int MyFunction(int i){ return 42 2*i; } } } "@ Add-Type TypeDefinition $MyDynamicCode Language Csharp [MyNamespace.MyClass]::MyFunction(10) # Returns Gergő Ládi (me@gergoladi.me) 28

29 PS 201 PSProviders & PSDrives Get-PSProvider Get-PSDrive cd Variable: ls cd HKCU: New-Item -Name "MyKey" -ItemType DWORD -Value Gergő Ládi 29

30 PS 201 PowerShell remoting Enter-PSSession -ComputerName remoteapp whoami hostname Gergő Ládi 30

31 PS 201 Package management Install-Package -Provider bootstrap chocolatey Get-PackageProvider -Name chocolatey Install-Package vlc Gergő Ládi 31

32 Recommended homework Write a PowerShell script that calculates the size of each user's home folder then writes the results to a file, sorted by the total size occupied. Home folders having a size of less than 10 MBs should not appear on the list. Write a PowerShell function that takes a web site URL as a parameter and returns a list of all external JavaScript files on that site Gergő Ládi (me@gergoladi.me) 32

33 Sources Mastering PowerShell (Dr. Tobias Weltner) Windows PowerShell 3.0 Step by Step (Ed Wilson) PowerShell Magazine ( Microsoft Developer Network ( Wikipedia ( Gergő Ládi 33

34 Thank you for your attention! Gergő Ládi

35 Q & A Gergő Ládi (me@gergoladi.me)

Product Page: https://digitalrevolver.com/product/automating-administration-with-windows-powershell/

Product Page: https://digitalrevolver.com/product/automating-administration-with-windows-powershell/ Automating Administration with Windows PowerShell Course Code: Duration: 5 Days Product Page: https://digitalrevolver.com/product/automating-administration-with-windows-powershell/ This course provides

More information

: 10961C: Automating Administration With Windows PowerShell

: 10961C: Automating Administration With Windows PowerShell Module Title Duration : 10961C: Automating Administration With Windows PowerShell : 5 days About this course This course provides students with the fundamental knowledge and skills to use Windows PowerShell

More information

"Charting the Course... MOC C: Automating Administration with Windows PowerShell. Course Summary

Charting the Course... MOC C: Automating Administration with Windows PowerShell. Course Summary Course Summary Description This course provides students with the fundamental knowledge and skills to use Windows PowerShell for administering and automating administration of Windows servers. This course

More information

Automating Administration with Windows PowerShell

Automating Administration with Windows PowerShell Automating Administration with Windows PowerShell Course 10961C - Five Days - Instructor-led - Hands on Introduction This five-day, instructor-led course provides students with the fundamental knowledge

More information

Corporate Training Centre (306)

Corporate Training Centre   (306) Corporate Training Centre www.sbccollege.ca/corporate (306)244-6340 corporate@sbccollege.ca Automating Administration with Windows PowerShell: 10961C 5 Day Training Program November 5-9, 2018 Cost: $2,700.00

More information

Boulos Dib September 21, 2011

Boulos Dib September 21, 2011 Boulos Dib September 21, 2011 Independent Consultant Napeague Inc. Software Development since 1983 Few Facts (@boulosdib) First Personal Computer 1980 TRS-80 III First Z80 based product (EPROM based Protocol

More information

Govindaraj Rangan Technology Strategist Microsoft India

Govindaraj Rangan Technology Strategist Microsoft India Govindaraj Rangan Technology Strategist Microsoft India Agenda Introduction to Windows Powershell Scripting with Windows Powershell Working with Objects (WMI, COM,.NET) Scripting Best Practices Agenda

More information

Automating Administration with Windows PowerShell

Automating Administration with Windows PowerShell Course Code: M10961 Vendor: Microsoft Course Overview Duration: 5 RRP: POA Automating Administration with Windows PowerShell Overview This course provides students with the fundamental knowledge and skills

More information

John Savill s PowerShell Master Class

John Savill s PowerShell Master Class John Savill s PowerShell Master Class Who am I? NTFAQGuy MCSE NT 4, Server 2012, Private Cloud, Azure, VCP 4/5, CISSP, ITIL v3 Author of the Windows FAQ Senior Contributing Editor for Windows IT Pro magazine

More information

Appendix C SAMPLE CHAPTER

Appendix C SAMPLE CHAPTER SAMPLE CHAPTER Windows PowerShell in Action by Bruce Payette Appenidx C Copyright 2007 Manning Publications brief contents Part 1 Learning PowerShell 1 1 Welcome to PowerShell 3 2 The basics 25 3 Working

More information

Microsoft Automating Administration with Windows PowerShell

Microsoft Automating Administration with Windows PowerShell 1800 ULEARN (853 276) www.ddls.com.au Microsoft 10961 - Automating Administration with Windows PowerShell Length 5 days Price $4290.00 (inc GST) Version C Overview This course provides students with the

More information

Expert Reference Series of White Papers. Five Simple Symbols You Should Know to Unlock Your PowerShell Potential

Expert Reference Series of White Papers. Five Simple Symbols You Should Know to Unlock Your PowerShell Potential Expert Reference Series of White Papers Five Simple Symbols You Should Know to Unlock Your PowerShell Potential 1-800-COURSES www.globalknowledge.com Five Simple Symbols You Should Know to Unlock Your

More information

Building Powerful Workflow Automation with Cherwell and PowerShell

Building Powerful Workflow Automation with Cherwell and PowerShell Building Powerful Workflow Automation with Cherwell and PowerShell Agenda Welcome & Session Introduction What is PowerShell? PowerShell ISE Commands/Cmd-Lets Operators Variables Flow Control LAB 1 Exploring

More information

Automating Administration with Windows PowerShell 2.0

Automating Administration with Windows PowerShell 2.0 Automating Administration with Windows PowerShell 2.0 Course No. 10325 5 Days Instructor-led, Hands-on Introduction This course provides students with the knowledge and skills to utilize Windows PowerShell

More information

Automating Administration with Windows PowerShell (M10961)

Automating Administration with Windows PowerShell (M10961) Automating Administration with Windows PowerShell (M10961) COURSE OVERVIEW: In this PowerShell course, you will gain the fundamental knowledge and skills to use Windows PowerShell for administering and

More information

Microsoft PowerShell for Security Professionals. Lab Guide Basics

Microsoft PowerShell for Security Professionals. Lab Guide Basics Microsoft PowerShell for Security Professionals Lab Guide Basics 1 Table of Contents Setup the Console... 3 Help... 6 Find the Right Command... 7 Providers... 8 File System... 8 Registry... 8 Extending

More information

Automating Administration with Windows PowerShell (10961)

Automating Administration with Windows PowerShell (10961) Automating Administration with Windows PowerShell (10961) Duration: 5 Days Live Course Delivery Price: $2795 *California residents and government employees call for pricing. MOC On-Demand Price: $895 Discounts:

More information

Windows Server 2012 R2 Windows PowerShell Fundamentals

Windows Server 2012 R2 Windows PowerShell Fundamentals Windows Server 2012 R2 Windows PowerShell Fundamentals Windows Server 2012 R2 Hands-on lab Windows PowerShell is a command-line shell and scripting language that helps IT professionals achieve greater

More information

COURSE 10961B: AUTOMATING ADMINISTRATION WITH WINDOWS POWERSHELL

COURSE 10961B: AUTOMATING ADMINISTRATION WITH WINDOWS POWERSHELL ABOUT THIS COURSE Learn how with Windows PowerShell 3.0, you can remotely manage single or multiple Windows-based servers and automate day-to-day management and administration tasks. This five day course

More information

10961C: Automating Administration with Windows PowerShell

10961C: Automating Administration with Windows PowerShell 10961C: Automating Administration with Windows Course Details Course Code: Duration: Notes: 10961C 5 days This course syllabus should be used to determine whether the course is appropriate for the students,

More information

Windows PowerShell. The next generation command line scripting

Windows PowerShell. The next generation command line scripting The next generation command line scripting Presented by Bob McCoy, CISSP/ISSAP, MCSE Microsoft Services Cyber Security Forum 07/18/2007 Windows PowerShell cmd.exe and command.com Lack of scriptable functionality

More information

10961B: Automating Administration with Windows PowerShell

10961B: Automating Administration with Windows PowerShell 10961B: Automating Administration with Windows PowerShell Course Overview This course provides students with the knowledge and skills to automate administration with Windows PowerShell, using features

More information

Powershell. Working with Objects COMP2101 Winter 2018

Powershell. Working with Objects COMP2101 Winter 2018 Powershell Working with Objects COMP2101 Winter 2018 Objects An object is a data structure residing in memory That structure has places for code and data, those things are called members of the object

More information

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017 Linux Shell Scripting Linux System Administration COMP2018 Summer 2017 What is Scripting? Commands can be given to a computer by entering them into a command interpreter program, commonly called a shell

More information

This course incorporates materials from the Official Microsoft Learning Product M10961: Automating Administration with Windows PowerShell.

This course incorporates materials from the Official Microsoft Learning Product M10961: Automating Administration with Windows PowerShell. Microsoft - Automating Administration with Windows PowerShell Code: URL: OD10961 View Online In this course, you will gain the fundamental knowledge and skills to use Windows PowerShell for administering

More information

Powershell: Introduction and Practical Uses. Presentation URL:

Powershell: Introduction and Practical Uses. Presentation URL: Powershell: Introduction and Practical Uses Presentation URL: http://bit.ly/2ick4pt HELLO! I am Chris Wieringa CS Lab Manager for Calvin College cwieri39@calvin.edu 2 1. Goals What we will cover today...

More information

PowerShell 10961: Automating Administration with Windows PowerShell. Upcoming Dates. Course Description. Course Outline

PowerShell 10961: Automating Administration with Windows PowerShell. Upcoming Dates. Course Description. Course Outline PowerShell 10961: Automating Administration with Windows PowerShell Learn how with Windows PowerShell you can remotely manage single or multiple Windows-based servers and automate day-to-day management

More information

Essential PowerShell Survival Skills

Essential PowerShell Survival Skills Essential PowerShell Survival Skills Shawn Bolan Microsoft Certified Trainer, VMware Certified Instructor, PRINCE2 Instructor New Horizons of Nebraska Essential PowerShell Survival Skills Welcome! Thank

More information

Course Outline. Automating Administration with Windows PowerShell Course 10961B: 5 days Instructor Led

Course Outline. Automating Administration with Windows PowerShell Course 10961B: 5 days Instructor Led Automating Administration with Windows PowerShell Course 10961B: 5 days Instructor Led About this Course Learn how with Windows PowerShell 3.0, you can remotely manage single or multiple Windows-based

More information

Powershell. Working With Data COMP2101 Fall 2017

Powershell. Working With Data COMP2101 Fall 2017 Powershell Working With Data COMP2101 Fall 2017 Where-Object Collections of objects contain objects we are interested in and often also contain objects we are not interested in Where-Object is designed

More information

Useful Unix Commands Cheat Sheet

Useful Unix Commands Cheat Sheet Useful Unix Commands Cheat Sheet The Chinese University of Hong Kong SIGSC Training (Fall 2016) FILE AND DIRECTORY pwd Return path to current directory. ls List directories and files here. ls dir List

More information

Part I. PowerShell for Exchange Fundamentals. Chapter 1: Getting Started with Windows PowerShell. Chapter 2: Using Exchange Management Shell

Part I. PowerShell for Exchange Fundamentals. Chapter 1: Getting Started with Windows PowerShell. Chapter 2: Using Exchange Management Shell Part I PowerShell for Exchange Fundamentals Chapter 1: Getting Started with Windows PowerShell Chapter 2: Using Exchange Management Shell Chapter 3: Using PowerShell to Deploy Exchange Server 2007 Chapter

More information

Overview of Windows PowerShell 5.0

Overview of Windows PowerShell 5.0 CHAPTER 1 Overview of Windows PowerShell 5.0 After completing this chapter, you will be able to Understand the basic use and capabilities of Windows PowerShell. Install Windows PowerShell. Use basic command-line

More information

Fundamentals of Leveraging PowerShell

Fundamentals of Leveraging PowerShell Fundamentals of Leveraging PowerShell By Carlos Perez Instructor Carlos Perez (Twitter @carlos_perez) Day job is Director of Reverse Engineering at a security vendor. Microsoft MVP on Cloud and Server

More information

Assignment clarifications

Assignment clarifications Assignment clarifications How many errors to print? at most 1 per token. Interpretation of white space in { } treat as a valid extension, involving white space characters. Assignment FAQs have been updated.

More information

Automating Administration with Microsoft Windows PowerShell

Automating Administration with Microsoft Windows PowerShell Automating Administration with Microsoft Windows PowerShell Cursusduur: 5 Dagen Cursuscode: M10961 Beschrijving: This course provides students with the fundamental knowledge and skills to use Microsoft

More information

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017 bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017 Command Lists A command is a sequence of commands separated by the operators ; & && and ; is used to simply execute commands in

More information

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017 bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017 Command Lists A command is a sequence of commands separated by the operators ; & && and ; is used to simply execute commands in

More information

A layman s guide to PowerShell 2.0 remoting. Ravikanth Chaganti

A layman s guide to PowerShell 2.0 remoting. Ravikanth Chaganti A layman s guide to PowerShell 2.0 remoting Ravikanth Chaganti Learn the basics of PowerShell 2.0 remoting, methods of remoting and how to use remoting to manage systems in a datacenter. A layman s guide

More information

Qlik Sense Cmdlet for PowerShell. Sokkorn CHEAV

Qlik Sense Cmdlet for PowerShell. Sokkorn CHEAV Qlik Sense Cmdlet for PowerShell Sokkorn CHEAV Table of Contents 1. Introduction...2 2. Why this document?...2 3. Tested Environment...2 4. Installation...2 6. Command Test Case...4 6.1 View a list of

More information

Automating Administration with Windows PowerShell

Automating Administration with Windows PowerShell Automating Administration with Windows PowerShell 10961; 5 Days, Instructor-led Course Description Learn how with Windows PowerShell 4.0, you can remotely manage multiple Windows based servers and automate

More information

Automating Administration with Windows PowerShell V3

Automating Administration with Windows PowerShell V3 Automating Administration with Windows PowerShell V3 Course Details Duration: Course code: 5 Days M10961 Overview: In this course you will learn how with Windows PowerShell 3.0, you can remotely manage

More information

10961B: Automating Administration with Windows PowerShell

10961B: Automating Administration with Windows PowerShell 10961B: Automating Administration with Windows Course Details Course Code: Duration: Notes: 10961B 5 days Elements of this syllabus are subject to change. About this course Learn how with Windows 3.0,

More information

Microsoft Windows PowerShell v2 For Administrators

Microsoft Windows PowerShell v2 For Administrators Microsoft Windows PowerShell v2 For Administrators Course 50414 5 Days Instructor-led, Hands-on Introduction This four-day instructor-led course provides students with the knowledge and skills to leverage

More information

[MS10961]: Automating Administration with Windows PowerShell

[MS10961]: Automating Administration with Windows PowerShell [MS10961]: Automating Administration with Windows PowerShell Length : 5 Days Audience(s) : IT Professionals Level : 200 Technology : Windows Server Delivery Method : Instructor-led (Classroom) Course Overview

More information

Course Outline: Course Automating Administration with Windows PowerShell v3.

Course Outline: Course Automating Administration with Windows PowerShell v3. Course Outline: Course Automating Administration with Windows PowerShell v3. Learning Method: Instructor-led Classroom Learning Duration: 5.00 Day(s)/ 40 hr Overview: This five day course provides students

More information

The power of PowerShell

The power of PowerShell The power of PowerShell Created by Ryan Woodward North Central Missouri College Table of Contents H R P C U G 1. About me 2. What is PowerShell? 3. Installing/Starting PowerShell 4. PowerShell Basics Variables

More information

POWERSHELL. Best Practices, Remote Management, Automation and More

POWERSHELL. Best Practices, Remote Management, Automation and More POWERSHELL Best Practices, Remote Management, Automation and More POWERSHELL #ILTAG119 Best Practices, Remote Management, Automation and More @thejasonhelmick Jason-Helmick@Pluralsight.com Author/Evangelist

More information

Shell Programming Overview

Shell Programming Overview Overview Shell programming is a way of taking several command line instructions that you would use in a Unix command prompt and incorporating them into one program. There are many versions of Unix. Some

More information

Unix Scripts and Job Scheduling. Overview. Running a Shell Script

Unix Scripts and Job Scheduling. Overview. Running a Shell Script Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Shell Scripts

More information

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller and Ruth Anderson http://www.cs.washington.edu/391/

More information

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: Processes The Operating System, Shells, and Python Shell Commands a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: - Command prompt - Shell - CLI Shell commands

More information

Common File System Commands

Common File System Commands Common File System Commands ls! List names of all files in current directory ls filenames! List only the named files ls -t! List in time order, most recent first ls -l! Long listing, more information.

More information

COMP 4/6262: Programming UNIX

COMP 4/6262: Programming UNIX COMP 4/6262: Programming UNIX Lecture 12 shells, shell programming: passing arguments, if, debug March 13, 2006 Outline shells shell programming passing arguments (KW Ch.7) exit status if (KW Ch.8) test

More information

UNIX shell scripting

UNIX shell scripting UNIX shell scripting EECS 2031 Summer 2014 Przemyslaw Pawluk June 17, 2014 What we will discuss today Introduction Control Structures User Input Homework Table of Contents Introduction Control Structures

More information

Powershell. Testing, Loops, Modules, More WMI COMP2101 Fall 2017

Powershell. Testing, Loops, Modules, More WMI COMP2101 Fall 2017 Powershell Testing, Loops, Modules, More WMI COMP2101 Fall 2017 Testing - if To test things, we can use the if statement We have one or more expressions to evaluate inside parentheses Multiple expressions

More information

Part II: PowerShell s Basic Structure and Syntax... 47

Part II: PowerShell s Basic Structure and Syntax... 47 Contents at a Glance Introduction... 1 Part I: Get ting a Bird s-eye View of PowerShell 2... 9 Chapter 1: The Windows PowerShell Rap Sheet...11 Chapter 2: Customizing and Shortcutting the Environment...21

More information

Basic Linux (Bash) Commands

Basic Linux (Bash) Commands Basic Linux (Bash) Commands Hint: Run commands in the emacs shell (emacs -nw, then M-x shell) instead of the terminal. It eases searching for and revising commands and navigating and copying-and-pasting

More information

Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches Learn Windows PowerShell in a Month of Lunches by Don Jones Chapter 4 Copyright 2011 Manning Publications brief contents 1 Before you begin 1 2 Running commands 9 3 Using the help system 23 4 The pipeline:

More information

Cisco IOS Shell. Finding Feature Information. Prerequisites for Cisco IOS.sh. Last Updated: December 14, 2012

Cisco IOS Shell. Finding Feature Information. Prerequisites for Cisco IOS.sh. Last Updated: December 14, 2012 Cisco IOS Shell Last Updated: December 14, 2012 The Cisco IOS Shell (IOS.sh) feature provides shell scripting capability to the Cisco IOS command-lineinterface (CLI) environment. Cisco IOS.sh enhances

More information

Microsoft Official Course

Microsoft Official Course Microsoft Official Course Module 1 Deploying and Managing Microsoft Exchange Server 2013 Module Overview Exchange Server 2013 Prerequisites and Requirements Exchange Server 2013 Deployment Managing Exchange

More information

POWERSHELL. Introduction COMP2101 Winter 2019

POWERSHELL. Introduction COMP2101 Winter 2019 POWERSHELL Introduction COMP2101 Winter 2019 POWERSHELL VERSIONS Windows Powershell version 5.1 is the target version for this course The get-host command can be used to see your Windows Powershell version

More information

Advanced Automated Administration with Windows PowerShell

Advanced Automated Administration with Windows PowerShell Course 10962A: Advanced Automated Administration with Windows PowerShell Course Details Course Outline Module 1: Creating Advanced Functions In this module students will learn how to parameterize a command

More information

Linux Shell Script. J. K. Mandal

Linux Shell Script. J. K. Mandal Linux Shell Script J. K. Mandal Professor, Department of Computer Science & Engineering, Faculty of Engineering, Technology & Management University of Kalyani Kalyani, Nadia, West Bengal E-mail: jkmandal@klyuniv.ac.in,

More information

Shell Script Example. Here is a hello world shell script: $ ls -l -rwxr-xr-x 1 horner 48 Feb 19 11:50 hello* $ cat hello #!/bin/sh

Shell Script Example. Here is a hello world shell script: $ ls -l -rwxr-xr-x 1 horner 48 Feb 19 11:50 hello* $ cat hello #!/bin/sh Shell Programming Shells A shell can be used in one of two ways: A command interpreter, used interactively A programming language, to write shell scripts (your own custom commands) Shell Scripts A shell

More information

A shell can be used in one of two ways:

A shell can be used in one of two ways: Shell Scripting 1 A shell can be used in one of two ways: A command interpreter, used interactively A programming language, to write shell scripts (your own custom commands) 2 If we have a set of commands

More information

SHELL SCRIPT BASIC. UNIX Programming 2014 Fall by Euiseong Seo

SHELL SCRIPT BASIC. UNIX Programming 2014 Fall by Euiseong Seo SHELL SCRIPT BASIC UNIX Programming 2014 Fall by Euiseong Seo Shell Script Interactive shell sequentially executes a series of commands Some tasks are repetitive and automatable They are what programs

More information

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science CSCI 211 UNIX Lab Shell Programming Dr. Jiang Li Why Shell Scripting Saves a lot of typing A shell script can run many commands at once A shell script can repeatedly run commands Help avoid mistakes Once

More information

Powershell. Functions, Parameters, User Input, Providers, WMI Objects COMP2101 Fall 2017

Powershell. Functions, Parameters, User Input, Providers, WMI Objects COMP2101 Fall 2017 Powershell Functions, Parameters, User Input, Providers, WMI Objects COMP2101 Fall 2017 Script Parameters Scripts can have parameters Use the param statement as the first line in your script to add parameters

More information

Course 10961: Automating Administration with Windows PowerShell

Course 10961: Automating Administration with Windows PowerShell Course 10961: Automating Administration with Windows PowerShell Overview Learn how with Windows PowerShell 4.0, you can remotely manage multiple Windows based servers and automate day to day management

More information

Shell Start-up and Configuration Files

Shell Start-up and Configuration Files ULI101 Week 10 Lesson Overview Shell Start-up and Configuration Files Shell History Alias Statement Shell Variables Introduction to Shell Scripting Positional Parameters echo and read Commands if and test

More information

Lecture 5. Essential skills for bioinformatics: Unix/Linux

Lecture 5. Essential skills for bioinformatics: Unix/Linux Lecture 5 Essential skills for bioinformatics: Unix/Linux UNIX DATA TOOLS Text processing with awk We have illustrated two ways awk can come in handy: Filtering data using rules that can combine regular

More information

Bash command shell language interpreter

Bash command shell language interpreter Principles of Programming Languages Bash command shell language interpreter Advanced seminar topic Louis Sugy & Baptiste Thémine Presentation on December 8th, 2017 Table of contents I. General information

More information

Hands-On Perl Scripting and CGI Programming

Hands-On Perl Scripting and CGI Programming Hands-On Course Description This hands on Perl programming course provides a thorough introduction to the Perl programming language, teaching attendees how to develop and maintain portable scripts useful

More information

SHELL SCRIPT BASIC. UNIX Programming 2015 Fall by Euiseong Seo

SHELL SCRIPT BASIC. UNIX Programming 2015 Fall by Euiseong Seo SHELL SCRIPT BASIC UNIX Programming 2015 Fall by Euiseong Seo Shell Script! Interactive shell sequentially executes a series of commands! Some tasks are repetitive and automatable! They are what programs

More information

Shell Programming (Part 2)

Shell Programming (Part 2) i i Systems and Internet Infrastructure Security Institute for Networking and Security Research Department of Computer Science and Engineering Pennsylvania State University, University Park, PA Shell Programming

More information

Title:[ Variables Comparison Operators If Else Statements ]

Title:[ Variables Comparison Operators If Else Statements ] [Color Codes] Environmental Variables: PATH What is path? PATH=$PATH:/MyFolder/YourStuff?Scripts ENV HOME PWD SHELL PS1 EDITOR Showing default text editor #!/bin/bash a=375 hello=$a #No space permitted

More information

CSE 390a Lecture 5. Intro to shell scripting

CSE 390a Lecture 5. Intro to shell scripting CSE 390a Lecture 5 Intro to shell scripting slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/390a/ 1 2 Lecture summary basic script syntax and running

More information

Learn Windows PowerShell 3 in a Month of Lunches

Learn Windows PowerShell 3 in a Month of Lunches Learn Windows PowerShell 3 in a Month of Lunches Second Edition DON JONES JEFFERY HICKS 11 MANN I NG Shelter Island contents preface xx'ii about this booh author online xx xix about the authors acknowledgments

More information

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 Bashed One Too Many Times Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 What is a Shell? The shell interprets commands and executes them It provides you with an environment

More information

Computer Systems and Architecture

Computer Systems and Architecture Computer Systems and Architecture UNIX Scripting Bart Meyers University of Antwerp August 29, 2012 Outline Basics Conditionals Loops Advanced Exercises Shell scripts Grouping commands into a single file

More information

Introduc)on to Unix and Perl programming

Introduc)on to Unix and Perl programming CENTER FOR BIOLOGICAL SEQUENCE ANALYSIS Department of Systems Biology Technical University of Denmark Introduc)on to Unix and Perl programming EDITA KAROSIENE PhD student edita@cbs.dtu.dk www.cbs.dtu.dk

More information

Bash scripting basics

Bash scripting basics Bash scripting basics prepared by Anatoliy Antonov for ESSReS community September 2012 1 Outline Definitions Foundations Flow control References and exercises 2 Definitions 3 Definitions Script - [small]

More information

Shell and Utility Commands

Shell and Utility Commands Table of contents 1 Shell Commands... 2 2 Utility Commands... 3 1 Shell Commands 1.1 fs Invokes any FsShell command from within a Pig script or the Grunt shell. 1.1.1 Syntax fs subcommand subcommand_parameters

More information

LING 408/508: Computational Techniques for Linguists. Lecture 5

LING 408/508: Computational Techniques for Linguists. Lecture 5 LING 408/508: Computational Techniques for Linguists Lecture 5 Last Time Installing Ubuntu 18.04 LTS on top of VirtualBox Your Homework 2: did everyone succeed? Ubuntu VirtualBox Host OS: MacOS or Windows

More information

CSC148H Week 1 >> COURSE INFORMATION, RECAP, OOP. Sadia Rain Sharmin Week of May 7, 2018

CSC148H Week 1 >> COURSE INFORMATION, RECAP, OOP. Sadia Rain Sharmin Week of May 7, 2018 CSC148H Week 1 >> COURSE INFORMATION, RECAP, OOP Sadia Rain Sharmin Week of May 7, 2018 Welcome! What is CSC148 about? - Designing programs using OO programming principles - Reasoning about efficiency

More information

Multi-Environment PowerShell console AD, Exchange and PowerCLI in one happy place!

Multi-Environment PowerShell console AD, Exchange and PowerCLI in one happy place! Multi-Environment PowerShell console AD, Exchange and PowerCLI in one happy place! With the increase in the use of PowerShell as part of an administrator s toolkit, it can be challening with multiple shells

More information

PowerShell Master Class

PowerShell Master Class Region Example Creating a PowerShell Script Basics of PowerShell Script Best Practices for Script Authoring Interacting With Users 4 #region CIM Get-Command -Module CimCmdlets Get-CimClass -ClassName *disk*

More information

CS Unix Tools & Scripting

CS Unix Tools & Scripting Cornell University, Spring 2014 1 February 24, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater A note on awk for (item in array) The order in which items are returned

More information

Shell and Utility Commands

Shell and Utility Commands Table of contents 1 Shell Commands... 2 2 Utility Commands...3 1. Shell Commands 1.1. fs Invokes any FsShell command from within a Pig script or the Grunt shell. 1.1.1. Syntax fs subcommand subcommand_parameters

More information

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT Unix as a Platform Exercises + Solutions Course Code: OS 01 UNXPLAT Working with Unix Most if not all of these will require some investigation in the man pages. That's the idea, to get them used to looking

More information

Advanced Automated Administration with Windows PowerShell (MS-10962)

Advanced Automated Administration with Windows PowerShell (MS-10962) Advanced Automated Administration with Windows PowerShell (MS-10962) Modality: Virtual Classroom Duration: 3 Days SATV Value: 3 Days SUBSCRIPTION: Master, Master Plus About this Course: The course will

More information

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab Systems Programming and Computer Architecture (252-0061-00) Exercise Session 01 Data Lab 1 Goal Get familiar with bit level representations, C and Linux Thursday, September 22, 2016 Systems Programming

More information

Prof. Navrati Saxena TA: R. Sachan

Prof. Navrati Saxena TA: R. Sachan Prof. Navrati Saxena navrati@ece.skku.ac.kr TA: R. Sachan rochak@skku.edu What is UNIX Command What is UNIX Shell Linux file structure UNIX/LINUX Commands 2 A command is a program which interacts with

More information

Course Outline. Advanced Automated Administration with Windows PowerShell Course 10962: 3 days Instructor Led

Course Outline. Advanced Automated Administration with Windows PowerShell Course 10962: 3 days Instructor Led Advanced Automated Administration with Windows PowerShell Course 10962: 3 days Instructor Led Prerequisites: Before attending this course, students must have: Knowledge and experience working with Windows

More information

COURSE OUTLINE: OD10961B Automating Administration with Windows PowerShell

COURSE OUTLINE: OD10961B Automating Administration with Windows PowerShell Course Name OD10961B Automating Administration with Windows Course Duration 2 Days Course Structure Online Course Overview Learn how with Windows 4.0, you can remotely manage multiple Windows based servers

More information

SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell

SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell 55095A; 1 Days, Instructor-led Course Description This one day class is designed for SharePoint 2010 and 2013 server administrators

More information

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company

More information

Програмиранев UNIX среда

Програмиранев UNIX среда Програмиранев UNIX среда Използванена команден шел и създаванена скриптове: tcsh, bash, awk, python Shell programming As well as using the shell to run commands you can use its built-in programming language

More information

Assignment 3, Due October 4

Assignment 3, Due October 4 Assignment 3, Due October 4 1 Summary This assignment gives you practice with writing shell scripts. Shell scripting is also known as bash programming. Your shell is bash, and when you write a shell script

More information