title: Azure runbook output to email
body: <p>I am trying to send the output of a VM status from Azure automation runbook into email, I use the below code:</p>
  
  <pre><code>function Send-EMail {
  Param (
      [Parameter(Mandatory=$true)]
      [String]$EmailTo,
      [Parameter(Mandatory=$true)]
      [String]$Subject,
      [Parameter(Mandatory=$true)]
      [String]$Body,
      [Parameter(Mandatory=$false)]
      [String]$EmailFrom="noreply@idlebytes.com",  #This gives a default value to the $EmailFrom command
      [parameter(Mandatory=$false)]
      [String] $SmtpServer = (Get-AutomationVariable -Name 'SmtpHost'),
      [parameter(Mandatory=$false)]
      [String] $SmtpUsername = (Get-AutomationVariable -Name 'SmtpUsername'),
      [parameter(Mandatory=$false)]
      [String] $SmtpPassword = (Get-AutomationVariable -Name 'SmtpPassword')
  )
  
      $SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
      $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25) 
      $SMTPClient.EnableSsl = $true 
      $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SmtpUsername, $SmtpPassword); 
      $SMTPClient.Send($SMTPMessage)
      Remove-Variable -Name SMTPClient
      Remove-Variable -Name SmtpPassword
  
  } #End Function Send-EMail
  
  $AutomationCredentialAssetName = "PScredential"
  
  # Get the credential asset with access to my Azure subscription
  $Cred = Get-AutomationPSCredential -Name $AutomationCredentialAssetName
  
  # Authenticate to Azure Service Management and Azure Resource Manager
  
  Add-AzureRmAccount -Credential $Cred | Out-Null
  
  $VMStatus = Get-AzureRmVM -Name "vm0" -ResourceGroupName "TestRG" -Status
  
  
  Send-EMail -EmailTo "admin@idlebytes.com" -Body "$VMStatus" -Subject "vm0 Status"
  </code></pre>
  
  <p>I expect the email output to print the exact status of the output, whereas, it prints the object Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineInstanceView'</p>
  
  <p>Can someone help, how to get the object content as string in email?</p>