Azure Classroom Series – 17/Apr/2020

Azure Powershell

  • Powershell will have cmd-lets (Command lets) which are in the form on <verb>-<noun>
  • Examples of powershell cmdlets
    • Get-Process: verb i.e. action is get on noun i.e. Process
    • New-Item: verb i.e. action is New on noun i.e. Item
  • Cmdlets take arguments
  • Generic Way to find any Powershell cmdlet and then the help of it
    • Find a Powershell cmdlet to kill process
    1. Get-Command '*Process*'
    # narrow down the result by finding a cmdlet
    2. Narrowed downed to Stop-Process
    
    • Get the Help of Stop-Process cmdlet
    Get-Help Get-Process
    Get-Help Get-Process -Online
    
    Preview
    • Find a powershell cmdlet to start a service
      • Get-Command '*-Service' Preview
      • Get-Help Start-Service -Online Preview
  • Cmdlets are bundled/packaged as modules
  • If you want to use azure from powershell, you need to install azure powershell module.
  • Refer Here for official installation guide
  • For the non windows 10 users use cloud shell Preview
  • For the windows 10 user open powershell as Administrator and
Install-Module -Name Az -AllowClobber -Scope AllUsers
Connect-AzAccount
  • All the Azure Cmdlets will be in the following pattern <verb>-Az<noun>
  • Examples:
Get-AzVm
New-AzSQLServer
  • To find specific commands
    • use Get-Command and Get-Help
    Get-Command '*-AzResourceGroup'
    Get-Help 'New-AzResourceGroup' -Online
    
  • To Use Reference Section
    • Navigate to here
    • And Navigate to Reference Section and find the commandlets Preview

Exercise

  1. Create a Windows VM using Azure Powershell
  2. Create a Linux VM using Azure Powershell

Best-Practice for writing Powershell

  • Create a new folder or use any existing
  • Create a new file .ps1 extension
  • Ensure Powershell Extension from Microsoft is installed in Visual Studio Code Preview
  • This extension helps in writing powershell scripts Preview

Leave a Reply

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

About learningthoughtsadmin