MS WINDOWS POWER SHELL - PowerPoint PPT Presentation

About This Presentation
Title:

MS WINDOWS POWER SHELL

Description:

MS WINDOWS POWER SHELL CSE 535 Operating Systems What is Power Shell PowerShell is Microsoft Windows object-oriented programming language interactive command line ... – PowerPoint PPT presentation

Number of Views:151
Avg rating:3.0/5.0
Slides: 27
Provided by: Deve83
Category:

less

Transcript and Presenter's Notes

Title: MS WINDOWS POWER SHELL


1
MS WINDOWS POWER SHELL
  • CSE 535 Operating Systems

2
What is Power Shell
  • PowerShell is Microsoft Windows
  • object-oriented programming language
  • interactive command line shell
  • PowerShell designed to
  • automate system tasks
  • such as batch processing
  • create systems management tools
  • for commonly implemented processes

3
What is it for?
  • The PowerShell language is similar to Perl.
  • PowerShell includes
  • more than 130 standard command line tools
  • for functions that formerly required users
  • to create scripts in VB, VBScript or C.

4
Where to Download?
  • http//www.microsoft.com/downloads/details.aspx?Fa
    milyID50633a1f-a665-425d-923c-1a269f8ac084displa
    yLangen

5
Windows PowerShell Cmdlet
  • Cmdlet (or Command-let)
  • which .NET objects can be accessed
  • from the command line.
  • A Cmdlet name consists of two elements
  • a verb and a noun
  • Example
  • one of the most useful Cmdlets
  • Get-help

6
Automating Tasks
  • PowerShell offers ways
  • to automate tasks
  • Cmdlets
  • very small .NET classes
  • appear as system commands
  • Scripts
  • combinations of cmdlets and associated logic.
  • Executables
  • standalone tools
  • Instantiation of standard .NET classes.

7
Integrating with .NET
  • PowerShell
  • integrates with the .NET environment
  • Can be embedded within other applications.
  • Over a hundred cmdlets are included
  • to be used separately
  • or combined with others
  • to automate more complex tasks
  • Users can
  • also create and share cmdlets.

8
Abbreviations for Cmdlets
  • there are abbreviations
  • for some of the Cmdlets, for example
  • Get-Process
  • Can also be typed as
  • ps

9
Linux-similar Cmdlets
  • ps
  • is command familiar to Linux users
  • as the command
  • to view details about currently running
    processes.
  • there are a number of
  • other Linux-PowerShell parallels
  • man is the same as Get-Help detailed
  • ls is the same as Get-ChildItem
  • pwd is the same as Get-Location

10
Understanding Aliases
  • PowerShell commands are usually long.
  • example Get-ChildItem.
  • However, PowerShell has aliases.
  • Example
  • dir is the same as Get-ChildItem
  • get-alias
  • get-alias dir

11
Obtaining PowerShell
  • PowerShell is installed
  • in Windows Server 2008
  • is also part of Windows 7,
  • it does not come ready loaded with XP or Vista!

12
Running PowerShell
  • Once PowerShell has been installed
  • then it can be run in two ways
  • Click on Start, Run
  • and then type in powershell
  • Start a new command prompt
  • and then type in powershell
  • the user can start using
  • the PowerShell commands.

13
Cmdl ps
  • One very useful Cmdlet is ps
  • or get-process
  • lists the currently running processes
  • the number of memory page (frame)s
  • the percentage of processor usage

14
Pipe and Sort
  • The list is sorted alphabetically
  • according to the process name.
  • You can sort WS field
  • According to the memory usage
  • To do this the user
  • pipes the output of ps
  • to a second Cmdlet sort-object
  • ps sort-object WS descending

15
Sorting wrt Memory Usage
16
Filtering Splitting the Commands
  • User can filter that
  • the powershell not to be seen in output
  • Add a filter
  • piped Cmdlets can be
  • split over multiple lines
  • ps where-object FilterScript
  • _.processname -ne "powershell"
  • sort-object WS descending

17
Filtered
18
To concatenation symbol
  • The concatenation symbol (gt)
  • will send the result output file
  • after the information has been converted to HTML
  • so that it can then be viewed in a web browser
  • ps
  • where-object -FilterScript
  • _.processname -ne "powershell"
  • sort-object WS descending
  • convertto-html -property Name,
  • WS gt ps.html

19
Displaying in Browser
20
Find all the processes on a computer that started
today
  • Get-Process Where _.starttime -ge
    datetimetoday

21
Find the processes that use more than 1000 MB of
memory and kill them
  • get-process where-object _.WS -gt 1000MB
    stop-process -whatif

22
Calculate the number of bytes in the files in a
directory
  • get-childitem measure-object -property length
    -sum

23
Defining Variables
  • PS C\gt a 5
  • PS C\gt a
  • 5
  • PS C\gt

24
Determine Variable
  • PS C\gt a.GetType()

25
Piped Commands
  • dir sort LastWriteTime more

26
  • PS C\WINDOWSgt a dir sort LastWriteTime
  • PS C\WINDOWSgt a0
  • PS C\WINDOWSgt a1
Write a Comment
User Comments (0)
About PowerShow.com