PowerShell Scripting Classroom Series 23/Nov

DOS Prompt

  • Legacy Terminal of Windows
  • Scripting is Batch Scripting.

Powershell

  • Is shipped along with windows.
  • Powershell Core can run on linux as well.
  • Windows Server Nano /Core Editions. These editions will not have GUI. They just have powershell terminal.
  • Powershell DSC which can be used like Ansible/Chef for Configuration Management.

Powershell Cmdlets

  • Cmdlets is a command that can be executed on Powershell Terminal.
  • Cmdlets are written in .net
  • Cmdlets have the following pattern <verb>-<noun>.
Get-Process
New-Item
Get-Help
  • Powershell also has huge module library called as Gallery. For now consider module as collection of cmd-lets

Practical Approach to a right cmdlet

  • There is a cmdlet called as Get-Command which lists the commands by search text.
  • Once you find a right cmdlet use Get-Help

Exercise-1: Find a cmdlet to Get Network Details

  • Approach
Get-Command '*Network*'
Get-Help <cmdlet> -Online

Exercise-2: Create a new file and a directory

  • Approach
Get-Command '*-Item'

Objects in Powershell

  • Everything in Powershell is an Object
  • Object has Methods & Properties

Comparision Operators in Powershell

Filtering Data using Where

  • Any Member and Operator combination to filter
<cmdlet>| Get-Member
  • Choose the Property which you want to rely and decide your condition
<cmdlet>| Where <choosenProperty> <condition>
  • Get all chrome Processes running on your machine
Get-Process
Get-Process | Get-Member
Get-Process | Where ProcessName -eq 'chrome'

Exercise-3

  • Delete all the files in temp directory which are of extension .log

  • Get All the Processes which have Working Set grater than 10000

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube