How to produce the result of the PowerCLI command in an email?


Hello world

Can someone give me help with this example. I started working with PowerCLI and I struggle out of my result in an e-mail message.

How can I store my result in the array and import the data in HTML in an email?

In the example below, I don't see any results in the email of the powercli command "Get - VM |" Select-Object Name, NumCPU, MemoryMB, ProvisionedSpaceGB.

I have to create a loop to retrieve the result?

# - CHANGE THESE VALUES.
$SMTPServer = "SMTP.toto.com".
$vCenterServerName1 = "vsphere1.toto.com".
$ToAddress = [email protected]
#-----------------------------------------------------------------------------

$Title = "connection settings for vCenter.
$Author = "lady".
$Header = "connection settings".

$Login = [email protected]# for domain WHICH
$Password = "xxxxxxxxxx #

Add-pssnapin VMware.VimAutomation.Core

$HTMLHeader = "< HTML > < report VMware TITLE > < /title >"
$HTMLFooter = 'Made with the Script POWERSHELL 2.0 - Version of the script' + $ScriptVersion + ' < / HTML > ".

$ScriptVersion = "v1.0".
$Subject = 'VMware - VM inventory report'
$FromAddress = "VMware" + "@ foo.com.

$ColorArray = 'Red', 'Orange', 'Purple', 'Blue', 'Olive', 'SlateGrey', 'Orange', 'Purple', 'Blue', 'Olive '.
$ColorArrayIndex = 0

$HTMLHeader = "< HTML > < TITLE > VMware Report for ' + $vCenterServerName1 ' < / TITLE >.
$HTMLFooter = "Made with POWERCLI Script 5.0" - + $Author + ".." < br > < br > ".
$HTMLFooter += ' < B > NOTE: < /B > $Date < / HTML > ".


$HTMLBody = "< BODY >".

$vCenter_inventory = @(get-VM |) Name Select-Object, NumCPU, MemoryMB, ProvisionedSpaceGB)

################################### OUTPUT #######################################

# HEADER
$HTMLBody += CreateHeader ("REPORT for < font color = blue > < b > vCENTER" + $vCenterServerName1 + ' < / police > < / b > < br > "" ")

# INTRO TEXT

$HTMLBody += ' < br br > > <.
$HTMLBody += $vCenter_inventory


# SEND THE REPORT BY E-MAIL.
$HTMLBody += ' < / BODY > "# close HTML body
$HTMLPage = $HTMLHeader + $HTMLBody + $HTMLFooter
Send-Mailmessage-to $FromAddress - to $ToAddress - subject $Subject - BodyAsHTML-body $HTMLPage - normal priority - SmtpServer $SMTPServer
Write-Host "report was sent by E-mail to '$ToAddress' to ' $FromAddress
################################### CLEANUP #######################################

$HTMLHeader = «»
$HTMLBody = «»
$HTMLFooter = «»
$HTMLPage = «»
$vCenter1_Inventory = «»
$vCenterServerName1 = «»

-Very well, cutting some of your code, it works for me in any case:

# This sets the format of the HTML table

"$Header = @".

TITLE


"@

# The data collection

$vCenter_inventory = get - VM | Select-Object Name, NumCPU, MemoryMB, ProvisionedSpaceGB

# Convert to HTML format

$HTML = $vCenter_inventory | ConvertTo-HTML-Fragment

# Prepare Mail Message

$Message = "from the random text."

"$Body = $Header +""+ $Message +"

"+ $HTML +""

$smtpServer = "smtpserver".

$HostName = $env: ComputerName

$From = $HostName + "@littlenickey.se."

$To = "[email protected]".

# Send Message

Send-MailMessage - SmtpServer $smtpServer - $From - to $To - subject $Subject - body $Body - BodyAsHtml

This should give you a little nicer output in the form of a table.

Tags: VMware

Similar Questions

  • How to restrict the running command prompt?

    How to restrict the running command prompt?

    I already know the method: HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System DisableCMD: 2

    but, but, it is possible to change reactivate cmd used much the system tool software

    So I want to deny the change of registry value by the software used, I changed all permissions to the registry [System] refusal keys with my account.

    but after a modified registry key permissions denied, disableCmd was inactivated more.

    It is impossible that the two parameter [disablecmd: dword = 2] and [{System} lock keys: administrator of the deny all permissions in my account]?

    This issue is beyond the scope of this site which is for the consumer to related issues.
    To ensure that you get a proper answer, ask either on the Technet site, if it is a type of Pro problem, or MSDN if it's related to the developer
  • How to add the translation application to my email add FB?

    Original title: translation

    I need to know how to ADD the TRANSLATION software to my email add FB? Any help?

    Try here: https://www.facebook.com/help/100117036792266

    Translate the updated Facebook application on the road

  • How to avoid the color address IOS in email HTML Template?

    Hello

    How to avoid the color address IOS in email HTML Template?

    Thank you

    Rahul Bhambri

    Hello Rahul,

    Please use css in your style sheet

    a {[x-Apple - detectors of data]

    color: inherit! important;

    text-decoration: none! important;

    font size: inherit! important;

    Police-family: inherit! important;

    Police-weight: inherit! important;

    line-height: inherit! important;

    }

    Thank you

    edynamic expert Eloqua

  • How to use the shutdown command to stop another computer?

    I just saw the setting-m to the shutdown command and decided to give it a whirl. However, when I pointed out the computer in question, I received a message that "a required privilege is not owned by the customer.

    What should I do to be able to use my laptop to turn off my old desktop computer? Both are running XP Professional SP3.
    Sometimes, I like reading or watching streaming video on Hulu on the laptop while lying in bed, and sometimes I play music if do the first, which is stored in the form of MP3 files on the desktop (which I access via a share). Be able to turn the office without getting up would be nice, but you do not get this option with Remote Desktop.

    Here is the result, the office is "slickswintel" (he's old, and since when I went first from Mac to Windows 98SE, although it is now a double XP/98) and the laptop is "slickslaptop".
    Both machines have unprivileged called 'Slick' on them local accounts that are my accounts on the day the main day. I have a different admin account, but I only use it as needed and use runas as often I log in fact.

    What should I do to get the following to work? In spite of the passing the MCSA Exam, I never learned about this feature, so I'm not sure what I should do to make it work? It'll work on a workgroup or is it only for domains? While I could set up a domain with the copy of the server I got from Dreamspark, I really didn't need one.

    Microsoft Windows XP [Version 5.1.2600]
    Copyright (C) 1985-2001 Microsoft Corp.

    D:\Documents and Settings\Slick > shutdown /?
    Usage: shutdown [-I |-l | s | r-|-a] [-f] [m \\computername] [t xx] [-c 'c
    COMMENT'] [d up: XX: YY]

    No args display this message (same as to-?)
    -i Display GUI interface, must be the first option
    l log off (cannot be used with the - m option)
    s shut down the computer
    r Shutdown and restart the computer
    -an abandonment, a system shutdown
    -m \\computername Remote to cancel the shutdown/restart computer /.
    t xx Set timeout for shutdown to xx seconds
    -c 'comment' comment (maximum of 127 characters) stop
    Forces f - running applications to close without war
    Ning
    d [u] [p]: xx:yy reason for closing code
    u is the user code
    p is a planned shutdown code
    XX is the main reason (the positive integer code
    SS to 256)
    YY is the minor reason (the positive integer code
    SS to 65536)

    D:\Documents and Settings\Slick > stop s m \\slickswintel
    The operation completed successfully.
    A required privilege is not held by the client.

    D:\Documents and Settings\Slick >

    As a general rule, you must have administrative privileges on the remote computer to shut down this computer.  Given that both computers have XP Pro, you are halfway there (remote users always authenticate as 'Guest' on XP Home).  The computer that you are trying to close must have "Simple file sharing" disabled because otherwise you can not authenticate to this computer as anything except the user "guest".  So try to disable Simple file sharing, make sure that your user name and password are the same on both computers and make sure you have administrative privileges on the remote computer, and then you can stop the machine with the command "shutdown".

    "How to disable the file sharing simple and how to set permissions on a shared folder in Windows XP"
      <>http://support.Microsoft.com/kb/307874 >

    In fact, it's easier to use the remote desktop.  Even if you do not have a "Shutdown" option in the start menu, you can always open a command prompt window (start-> Run-> "cmd") and enter the command:
    stop s f t 35
    This will give you 35 seconds to logoff this computer before its judgment (assuming that you have administrator privileges).

    You can also look in the command "psshutdown' of the PSTools Suite
    PSTools: <> http://technet.microsoft.com/en-us/sysinternals/bb896649 >

    HTH,
    JW

  • How to run the DAQmxGetTaskChannels command

    I'm reading the attributes of task of MAX by using various DAQmx with VB6 controls.  I found that a simple task of load (DAQmxLoadTask) generates a valid taskhandle of a known in MAX taskname that can be used to get the measurement data using the analog in the command "Read" (DAQmxReadAnalogF64).  The results seem to be already scaling according to my setup in MAX. What I want to do is read the names of the configuration tasks in MAX, select a VB and then read the names of channel and the ways of treatment of MAX and measurement data. I tried the following commands without error but still see a result null in the output string variable.

    DAQmxGetTaskName

    DAQmxGetTaskChannels

    DAQmxGetAICustomScaleName

    Curiously, the command, DAQmxGetTaskNumChans, book with success the number of channels in the setup of MAX.  With this information, I can get the measurement data, but I don't have the engineering units or the names of custom channel for my header output file to include with my measured data.

    I was wondering if the problem is related to incompatibility with newer versions of daqmx? Or maybe another reason?

    I use Windows XP, with service pack 6, a NOR-DAQmx 9.2.2 VB6 and NI DAQPAd-6015.

    Hi hutchins2,

    Thanks for posting, click on the link below that seems to be the reason for our problem:

    Textual DAQmx Device Information functions will return a NULL result

    Eric NOR

  • How to open the message app and past email address to send a new email

    I'm looking for a way how to open the message application to create a new email and the definition of the field emailaddress my application programmatically.

    I think that this should be possible, but it seems that I have did not use keywords to find it on goolge or this forum.

    any ideas?

    http://www.BlackBerry.com/developers/docs/6.0.0api/NET/RIM/BlackBerry/API/invoke/invoke.html#invokeA... net.rim.blackberry.api.invoke.ApplicationArguments)

    with

    http://www.BlackBerry.com/developers/docs/6.0.0api/NET/RIM/BlackBerry/API/invoke/MessageArguments.ht...

    specify what you want to be pre-set in the subject of the message

  • How to increase the memory capacity to send emails with attachments?

    I try to send a 530 MB video file to a friend, and the computer says memory is insufficient. Can someone tell me how to increase the amount of memory for my emals?

    Email size is based on your email provider and also the supplier of recipients. Most do not allow to send him something that big.

    Mine is 2 MB max.

    I use Skydrive and download files and serve as a link to your friend.

    https://SkyDrive.live.com/

  • How to avoid the FDM-command being moved files from the OpenBatch folder

    Hello world

    I have a little problem with Batch Processing of the FDM - I need to stop the movement of files in the folder OpenBatch - when a batch is executed.

    The installer by using the Task Manager, a load a Batch Script and Script integration all works very well. However, the process must run every 3 hours, so I need the file "A_LedgerTransLocation_Actual_nov - 2013_RR.txt" to remain in the \Inbox\Batches\OpenBatch\ folder at any time.

    How to avoid the file is moved?


    Best regards
    Frederik




    PS: I noticed on the OTN Forum is it may be possible to script a solution such as:

    FSO1 = CreateObject ("Scripting.FileSystemObject") set
    Set File1 = FSO1. GetFile ("FDM Directory\FDM Application\Inbox\Batches\Openbatch\A_LedgerTransLocation_Actual_nov-2013_RR.txt")
    The BATCHENG value. PcolFiles = BATCHENG.fFileCollectionCreate (CStr (strDelimiter), File1)

    However this is not possible, as the controllers of the company need to edit the. TXT file themselves. They will not be able to edit the script too.

    I don't think you can prevent the FDM, move the file. I'm assuming that the file change in each period to use the last period of POV, so I think that option easiset to copy the file (based on a part of the name (location?) to a temporary location before began the FOM and write again later.)

  • Linux Server (how to record the out command has put on another file.)

    Hi all
    I have Q?
    How do to record the out command put in another file.

    Ex: #ps - ef
    This particular exit cmd I need to record another file.
    is it possible... If possible... Please let me know
    And how to record the history of orders under Linux.

    DF h > /oracle/output.log

    Oracle - name of the mount point

    Concerning
    Asif Kabir

  • How to use the voice command?

    If you must go to the icon of voice control, you might as well just to make the call. Y at - it a shortcut?

    You can access the voice command by pressing the green call button.

  • How to disable the MATLAB command window when the Matlab Script

    Hi, is it possible to disable the MATLAB command window popup when the Matlab script? Thank you.

    Isn't fear. As soon as you close the window is closed by the ActiveX Server and your script will stop running. You can, of course, reduce by using the operating system. Under Windows, you can use the Utilities of Windows API, as provided for in one of the threads of research responses.

  • How to use the MSG command

    Hi all

    I want to use the MSG command send message from my computer to other computers on a network. We work in windows 7 and I used the following syntax:

    MSG * / server IP: address 'Message '.

    but the message back to my computer even if I use the IP address of another computer

    Thank you

    Hi Michael,

    Advanced networking issues are supported in the TechNet Forums. I suggest you send the request in the TechNet forums.
    http://social.technet.Microsoft.com/forums/Windows/en-us/home?Forum=w7itpronetworking

    Hope this information helps.

  • How to use the chkdsk command in windows 7 its not working not not his poster error access denied

    Please help me about the chkdsk command to remove the windows command prompt 7...

    If you try to use chkdsk for C:\ partition, you cannot run that the disc must be disassembled for the operation, which is not possible with the C:\ partition (or the partition where Windows is installed).

    Instead, go on-> do work right click on the partition-> click Properties-> in the Properties dialog box, go to the Tools tab-> under error-checking, click check now... This will automatically set a check the next time you start Windows.
  • How to use the del command or any other to ignore files that it cannot remove (files in use) and continue to delete other files in a folder?

    I want to do a batch tha clean windows Temp folder. For this, I tried the del command, but the problem is to stop the deletion of files when it cannot remove a file in use. I want that he skip this file and continue to delete the other files too. I hope you guessed it. Please help me.

    Hello

    Thanks for posting your question in the Microsoft Community.

    The question you posted would be better suited in the MSDN Community.
    http://social.msdn.Microsoft.com/forums/en-us/categories

Maybe you are looking for