Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Feature Forums
  3. - Uncategorised posts -
  4. Powershell: Dynamic Email Message Body

Powershell: Dynamic Email Message Body

Scheduled Pinned Locked Moved - Uncategorised posts -
questionwindows-admintoolsworkspace
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    namerg
    wrote on last edited by
    #1

    Hello, not sure if I am in the right spot to post my question about PowerShell/PowerCLI I have a script in powershell that will send an email to an outlook client. The msg body will have values regarding to two things: Active Snapshots in the virtual environment and CD ROMs attached to the VMs. Let's talk when the email reports more that one CDRoms attached, how do I increase or decrease the msg body depending of the results gathered from the virtual environment ? So, far I have this code:

    if (($Snapshots -eq "yes") -or ($cdroms -eq "yes"))
    {
    $array0 = @()
    $array1 = @()
    $array2 = @()
    $array3 = @()
    start-sleep 1
    connect-VIServer $vcserver
    $array0 += Get-VM | get-snapshot | %{$_.VM.Name}
    $array1 += Get-VM | get-snapshot | select-object -expandproperty Name
    $array2 += Get-VM | get-snapshot | select-object -expandproperty Created
    $array3 =@(Get-VM | where { $_ | Get-CDdrive | where { $_.ConnectionState.Connected -eq "true" } } | Select-object -ExpandProperty Name)
    $i = 0
    $j = 0
    Do {
    $msg.Body += "<FONT COLOR=black>VMware HealthCheck vCenter2</FONT><BR><BR>" + `
    "<B><FONT COLOR=black>Snapshots Active</FONT></B><BR>" + `
    "<B><FONT COLOR=black>VM Name</FONT></B>"+`
    "<B><FONT COLOR=black>                                      `
    Name</FONT></B>"+`
    "<B><FONT COLOR=black>                                      `
    Created</FONT></B><BR>"+`
    "<FONT COLOR=Red>"+$array0+"</FONT>"

    L 1 Reply Last reply
    0
    • N namerg

      Hello, not sure if I am in the right spot to post my question about PowerShell/PowerCLI I have a script in powershell that will send an email to an outlook client. The msg body will have values regarding to two things: Active Snapshots in the virtual environment and CD ROMs attached to the VMs. Let's talk when the email reports more that one CDRoms attached, how do I increase or decrease the msg body depending of the results gathered from the virtual environment ? So, far I have this code:

      if (($Snapshots -eq "yes") -or ($cdroms -eq "yes"))
      {
      $array0 = @()
      $array1 = @()
      $array2 = @()
      $array3 = @()
      start-sleep 1
      connect-VIServer $vcserver
      $array0 += Get-VM | get-snapshot | %{$_.VM.Name}
      $array1 += Get-VM | get-snapshot | select-object -expandproperty Name
      $array2 += Get-VM | get-snapshot | select-object -expandproperty Created
      $array3 =@(Get-VM | where { $_ | Get-CDdrive | where { $_.ConnectionState.Connected -eq "true" } } | Select-object -ExpandProperty Name)
      $i = 0
      $j = 0
      Do {
      $msg.Body += "<FONT COLOR=black>VMware HealthCheck vCenter2</FONT><BR><BR>" + `
      "<B><FONT COLOR=black>Snapshots Active</FONT></B><BR>" + `
      "<B><FONT COLOR=black>VM Name</FONT></B>"+`
      "<B><FONT COLOR=black>                                      `
      Name</FONT></B>"+`
      "<B><FONT COLOR=black>                                      `
      Created</FONT></B><BR>"+`
      "<FONT COLOR=Red>"+$array0+"</FONT>"

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Its quite tricky, but try to post this question at likeplum. I always get good answers there to my computer/programming issues and questions. They have programmers online to help you now. You can get a great answer to your question so fast. https://www.likeplum.com/help/programming?aid=3321

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups