SlideShare a Scribd company logo
Windows PowerShell  The Next Generation Command Line Scripting Phan Quoc Hien  B110077
Agenda Introduction What is Windows PowerShell? Using PowerShell How can I script with Windows PowerShell? PowerShell and .net How .net developers will benefit from PowerShell
Introduction What is PowerShell?
What is PowerShell Revolutionary new interactive shell and scripting language Based on .NET New set of built-in tools (+120) Can continue to use current tools Can continue to use current automation (COM) Allows access to data stores as  easy  to access  as file systems
Why? Try things out in an interactive shell Stitch things together with utilities Put the results in a script file  Generalize Clean it up    production-quality Be more Productive Secure by default
Where ? Supported on Windows XP and above Microsoft Products Exchange 2007 System Center (Family) 2007 New Management Architecture based on PowerShell Windows Server 2008 None Microsoft Products IBM WebSphere MQ 6 VMWare InfrastructureToolkit
Using PowerShell
How to start? PowerShell is a free download from Microsoft Separate download for each windows version
The basics Syntax:  verb-noun  –parameter   arguments Always singular, parameters starts with “ - ” Examples: > Get-Process –name ie* > Get-Process ie* > Get-Service > Read-Host “Please Enter a number”
The basics (cont’d) You can alias Set-Alias gps Get-Process Parameters can be positional gps –ProcessName notepad gps notepad Many parameters can be wildcarded gps note* Partial parameter names allowed Gps –p notepad
Variables Not case-sensitive Default value is $null Cmdlets to manage variables Clear-Variable Get-Variable New-Variable Remove-Variable Set-Variable
Variables (cont’d) Types User created variables Automatic variables Created by PowerShell to maintain its state Cannot be modified Examples: $PSHome, $$, $^, $?, etc Preference variables Created by PowerShell to store user preferences Can be modified Examples: $MaximumHistoryCount, etc
Aliases Alternate names for cmdlets Cmdlets to manage aliases Export-Alias Get-Alias Import-Alias New-Alias Set-Alias Cannot take parameters Workaround: put the statement in a script and alias to that Example: Dir, ls, gcm, gci, etc
Conditional & Looping Conditional statements If Switch l.ooping For For ($i=0;$i –le 10;$i++)  {Write-Host $i} Foreach Used on a collection of items Foreach ($name in $namesArray) { Write-Host $name } Do Do { Write-Host $i; $i++ } while ($i –le 10) Do { Write-Host $i;$i++} Until ($i –lt 10) While While ($i –le 10) { Write-Host $i;$i++ }
Operators Comparison operators -ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, -notcontains, -match, -notmatch Logical operators -or, -and, -xor, -not, ! Arithmetic operators Assignment operators
Getting Help Get-Command Gets a list of all commands  Get-Help Shows help for a given cmdlet Get-Member Gets members of an object Get-PSDrive Shows information stores in PowerShell About_Topics Get-Help about*
Trusting Operations Commands with side-effects support: Whatif Stop-Service win* –WhatIf Confirm Stop-process S* -Confirm Verbose
Security is key for PowerShell By default, only interactive usage allowed If you want to use scripting, you need to change the  ExecutionPolicy Get-ExecutionPolicy / Set-ExecutionPolicy PS1 files opened with Notepad by design
Finding Data in Data Stores Data stores surfaced as “Drives” Filesystem, Registry, Alias, Certs, Env, Functions, Variables, etc. > Get-PSDrive > dir  HKLM:\SOFTWARE\Microsoft Rich common semantics > Dir  \logs –Include *.txt –Exclude A* -Recurse Tab-Completion in all Drives > Dir HKLM:\So<TAB>\Mi<TAB> => HLKM:\Software\Microsoft Demo 1 : File System Navigation Demo 2 : Registry Navigation Demo 3 : Environment Variables Navigation
 
Out-Thankyou PS C:\> Thank you for your time and attention. Good luck in your PowerShell Adventures! PS C:\>

More Related Content

What's hot (20)

PDF
Is writing performant code too expensive?
Tomasz Kowalczewski
 
PDF
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
ODP
Php in 2013 (Web-5 2013 conference)
julien pauli
 
PPTX
PHP for hacks
Tom Praison Praison
 
PDF
Php extensions workshop
julien pauli
 
PPT
Php mysql
Manish Jain
 
PPTX
Php server variables
JIGAR MAKHIJA
 
PDF
New Features in PHP 5.3
Bradley Holt
 
PDF
What's new in PHP 5.5
Tom Corrigan
 
KEY
Using PHP
Mark Casias
 
PDF
Pycon - Python for ethical hackers
Mohammad Reza Kamalifard
 
PDF
Profiling php5 to php7
julien pauli
 
PPTX
利用Init connect做mysql clients stat 用户审计
Dehua Yang
 
PDF
DIG1108C Lesson3 Fall 2014
David Wolfpaw
 
PPTX
Phphacku iitd
Sorabh Jain
 
PDF
Review unknown code with static analysis
Damien Seguy
 
PDF
Diving into HHVM Extensions (PHPNW Conference 2015)
James Titcumb
 
PDF
PHP 7 new engine
julien pauli
 
Is writing performant code too expensive?
Tomasz Kowalczewski
 
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
Php in 2013 (Web-5 2013 conference)
julien pauli
 
PHP for hacks
Tom Praison Praison
 
Php extensions workshop
julien pauli
 
Php mysql
Manish Jain
 
Php server variables
JIGAR MAKHIJA
 
New Features in PHP 5.3
Bradley Holt
 
What's new in PHP 5.5
Tom Corrigan
 
Using PHP
Mark Casias
 
Pycon - Python for ethical hackers
Mohammad Reza Kamalifard
 
Profiling php5 to php7
julien pauli
 
利用Init connect做mysql clients stat 用户审计
Dehua Yang
 
DIG1108C Lesson3 Fall 2014
David Wolfpaw
 
Phphacku iitd
Sorabh Jain
 
Review unknown code with static analysis
Damien Seguy
 
Diving into HHVM Extensions (PHPNW Conference 2015)
James Titcumb
 
PHP 7 new engine
julien pauli
 

Viewers also liked (20)

PPT
Are you ready for camp?
Siu Fai Cheong
 
KEY
Community building 541
Janice Bezanson
 
PPTX
PostgreSQL - Features and application of PostgreSQL database management systems
Phan Hien
 
PDF
Intervento del presidente
mattone84
 
KEY
Internet for instruction 541
Janice Bezanson
 
PDF
Intervento del presidente
mattone84
 
PPS
Chinacityinthemountains
PACE Kiprovska
 
PPTX
ISOTECH ASC Wax
Anh Tuan Ngo
 
PPT
Corporate parent linkages.pdf
tn yogesh
 
PPTX
Artforms of the 20th century
Bev Rosario Sapungan
 
PPS
Istina.o.raku.pluca
PACE Kiprovska
 
PPT
да здравствует вежливость и доброта
resnichka63
 
KEY
Community building 541
Janice Bezanson
 
KEY
Internet for instruction 541
Janice Bezanson
 
KEY
Internet for instruction 541
Janice Bezanson
 
PPS
Thebirds sex1
PACE Kiprovska
 
PDF
CONSIUS IT CONSULTING AND HR SERVICES (P) LTD
Rare Holidays India
 
PPTX
541networking
Janice Bezanson
 
PPS
Kapky
PACE Kiprovska
 
PPTX
541networking
Janice Bezanson
 
Are you ready for camp?
Siu Fai Cheong
 
Community building 541
Janice Bezanson
 
PostgreSQL - Features and application of PostgreSQL database management systems
Phan Hien
 
Intervento del presidente
mattone84
 
Internet for instruction 541
Janice Bezanson
 
Intervento del presidente
mattone84
 
Chinacityinthemountains
PACE Kiprovska
 
ISOTECH ASC Wax
Anh Tuan Ngo
 
Corporate parent linkages.pdf
tn yogesh
 
Artforms of the 20th century
Bev Rosario Sapungan
 
Istina.o.raku.pluca
PACE Kiprovska
 
да здравствует вежливость и доброта
resnichka63
 
Community building 541
Janice Bezanson
 
Internet for instruction 541
Janice Bezanson
 
Internet for instruction 541
Janice Bezanson
 
Thebirds sex1
PACE Kiprovska
 
CONSIUS IT CONSULTING AND HR SERVICES (P) LTD
Rare Holidays India
 
541networking
Janice Bezanson
 
541networking
Janice Bezanson
 
Ad

Similar to NIIT ISAS Q5 Report - Windows PowerShell (20)

PPT
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
PPTX
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
PPTX
PowerShell 101
Thomas Lee
 
PPTX
PowerShell-1
Saravanan G
 
PDF
PowerShell_LangRef_v3 (1).pdf
outcast96
 
PPT
Introduction to PowerShell
Salaudeen Rajack
 
PPTX
Powershell Tech Ed2009
rsnarayanan
 
PDF
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
ClapperboardCinemaPV
 
PPTX
Power shell training
David Brabant
 
PPT
No-script PowerShell v2
Concentrated Technology
 
PPTX
Introduction to powershell
Salaudeen Rajack
 
PPT
PowerShell Core Skills (TechMentor Fall 2011)
Concentrated Technology
 
PDF
Sql Server & PowerShell
Aaron Shilo
 
PPTX
Get-Help: An intro to PowerShell and how to Use it for Evil
jaredhaight
 
PPTX
Windows PowerShell
Sandun Perera
 
PPTX
Introduction to windows power shell in sharepoint 2010
Binh Nguyen
 
PDF
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Hitesh Mohapatra
 
PPTX
PowerShell 101
Thomas Lee
 
PPTX
learn ps new advance for all powershell.pptx
Ronnie Kapoor
 
PDF
Windows Powershell Step By Step 3rd Edition Wilson Ed
forsenqenan
 
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
PowerShell 101
Thomas Lee
 
PowerShell-1
Saravanan G
 
PowerShell_LangRef_v3 (1).pdf
outcast96
 
Introduction to PowerShell
Salaudeen Rajack
 
Powershell Tech Ed2009
rsnarayanan
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
ClapperboardCinemaPV
 
Power shell training
David Brabant
 
No-script PowerShell v2
Concentrated Technology
 
Introduction to powershell
Salaudeen Rajack
 
PowerShell Core Skills (TechMentor Fall 2011)
Concentrated Technology
 
Sql Server & PowerShell
Aaron Shilo
 
Get-Help: An intro to PowerShell and how to Use it for Evil
jaredhaight
 
Windows PowerShell
Sandun Perera
 
Introduction to windows power shell in sharepoint 2010
Binh Nguyen
 
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Hitesh Mohapatra
 
PowerShell 101
Thomas Lee
 
learn ps new advance for all powershell.pptx
Ronnie Kapoor
 
Windows Powershell Step By Step 3rd Edition Wilson Ed
forsenqenan
 
Ad

Recently uploaded (14)

PPTX
Emotional Intelligence Understanding and Recognition
ssuser9fcca3
 
PPTX
Presentatiof local anaesthesiaonon1.pptx
harmanjotsingh483731
 
PPTX
UP SDRF History English.pptxdownload it is easy to understand
aanyatiwari1015
 
PPTX
09CHAPTER-O1-Areas-Exposed-to-Hazards-Disaster-from-Difft.-Perspectives.pptx
jeromedmangino23
 
DOCX
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
ERKhelemba
 
PPTX
Banking_Fraud_Presentation_with_Visuals.
johnwick25061999
 
PPTX
Jurnal international conferences ISSRESTEC
TheodoraSinta
 
PPTX
Positive Role Modeling for Personal Growth.pptx
StrengthsTheatre
 
PPTX
what is personality and Personality Development.pptx
Teenu10
 
PDF
self love, mindfulness, psychology, growth
tanya99budhiraja
 
PPTX
why-journaling-helps-in-self-growth.pptx
StrengthsTheatre
 
PDF
Why Tripura Now Relies Heavily on Civil Services Over IAS Officers.pdf
blogging022
 
PDF
Make an IMPACT: A Framework to Transform People, Teams, and Futures
Chandan Patary
 
PPT
Assessment according to 19011-3 presentation.ppt
ibr1722011
 
Emotional Intelligence Understanding and Recognition
ssuser9fcca3
 
Presentatiof local anaesthesiaonon1.pptx
harmanjotsingh483731
 
UP SDRF History English.pptxdownload it is easy to understand
aanyatiwari1015
 
09CHAPTER-O1-Areas-Exposed-to-Hazards-Disaster-from-Difft.-Perspectives.pptx
jeromedmangino23
 
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
ERKhelemba
 
Banking_Fraud_Presentation_with_Visuals.
johnwick25061999
 
Jurnal international conferences ISSRESTEC
TheodoraSinta
 
Positive Role Modeling for Personal Growth.pptx
StrengthsTheatre
 
what is personality and Personality Development.pptx
Teenu10
 
self love, mindfulness, psychology, growth
tanya99budhiraja
 
why-journaling-helps-in-self-growth.pptx
StrengthsTheatre
 
Why Tripura Now Relies Heavily on Civil Services Over IAS Officers.pdf
blogging022
 
Make an IMPACT: A Framework to Transform People, Teams, and Futures
Chandan Patary
 
Assessment according to 19011-3 presentation.ppt
ibr1722011
 

NIIT ISAS Q5 Report - Windows PowerShell

  • 1. Windows PowerShell The Next Generation Command Line Scripting Phan Quoc Hien B110077
  • 2. Agenda Introduction What is Windows PowerShell? Using PowerShell How can I script with Windows PowerShell? PowerShell and .net How .net developers will benefit from PowerShell
  • 3. Introduction What is PowerShell?
  • 4. What is PowerShell Revolutionary new interactive shell and scripting language Based on .NET New set of built-in tools (+120) Can continue to use current tools Can continue to use current automation (COM) Allows access to data stores as easy to access as file systems
  • 5. Why? Try things out in an interactive shell Stitch things together with utilities Put the results in a script file Generalize Clean it up  production-quality Be more Productive Secure by default
  • 6. Where ? Supported on Windows XP and above Microsoft Products Exchange 2007 System Center (Family) 2007 New Management Architecture based on PowerShell Windows Server 2008 None Microsoft Products IBM WebSphere MQ 6 VMWare InfrastructureToolkit
  • 8. How to start? PowerShell is a free download from Microsoft Separate download for each windows version
  • 9. The basics Syntax: verb-noun –parameter arguments Always singular, parameters starts with “ - ” Examples: > Get-Process –name ie* > Get-Process ie* > Get-Service > Read-Host “Please Enter a number”
  • 10. The basics (cont’d) You can alias Set-Alias gps Get-Process Parameters can be positional gps –ProcessName notepad gps notepad Many parameters can be wildcarded gps note* Partial parameter names allowed Gps –p notepad
  • 11. Variables Not case-sensitive Default value is $null Cmdlets to manage variables Clear-Variable Get-Variable New-Variable Remove-Variable Set-Variable
  • 12. Variables (cont’d) Types User created variables Automatic variables Created by PowerShell to maintain its state Cannot be modified Examples: $PSHome, $$, $^, $?, etc Preference variables Created by PowerShell to store user preferences Can be modified Examples: $MaximumHistoryCount, etc
  • 13. Aliases Alternate names for cmdlets Cmdlets to manage aliases Export-Alias Get-Alias Import-Alias New-Alias Set-Alias Cannot take parameters Workaround: put the statement in a script and alias to that Example: Dir, ls, gcm, gci, etc
  • 14. Conditional & Looping Conditional statements If Switch l.ooping For For ($i=0;$i –le 10;$i++) {Write-Host $i} Foreach Used on a collection of items Foreach ($name in $namesArray) { Write-Host $name } Do Do { Write-Host $i; $i++ } while ($i –le 10) Do { Write-Host $i;$i++} Until ($i –lt 10) While While ($i –le 10) { Write-Host $i;$i++ }
  • 15. Operators Comparison operators -ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, -notcontains, -match, -notmatch Logical operators -or, -and, -xor, -not, ! Arithmetic operators Assignment operators
  • 16. Getting Help Get-Command Gets a list of all commands Get-Help Shows help for a given cmdlet Get-Member Gets members of an object Get-PSDrive Shows information stores in PowerShell About_Topics Get-Help about*
  • 17. Trusting Operations Commands with side-effects support: Whatif Stop-Service win* –WhatIf Confirm Stop-process S* -Confirm Verbose
  • 18. Security is key for PowerShell By default, only interactive usage allowed If you want to use scripting, you need to change the ExecutionPolicy Get-ExecutionPolicy / Set-ExecutionPolicy PS1 files opened with Notepad by design
  • 19. Finding Data in Data Stores Data stores surfaced as “Drives” Filesystem, Registry, Alias, Certs, Env, Functions, Variables, etc. > Get-PSDrive > dir HKLM:\SOFTWARE\Microsoft Rich common semantics > Dir \logs –Include *.txt –Exclude A* -Recurse Tab-Completion in all Drives > Dir HKLM:\So<TAB>\Mi<TAB> => HLKM:\Software\Microsoft Demo 1 : File System Navigation Demo 2 : Registry Navigation Demo 3 : Environment Variables Navigation
  • 20.  
  • 21. Out-Thankyou PS C:\> Thank you for your time and attention. Good luck in your PowerShell Adventures! PS C:\>

Editor's Notes

  • #2: INF210
  • #3: 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • #5: 10/02/11 11:24 MICROSOFT CONFIDENTIAL © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • #6: 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • #9: Start NOW !
  • #11: 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • #18: 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • #20: 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. Demo Get-PSDrive Show navigation in File System and Registry