Hi guys,
Can you please help how i can be possible called upon multiple vCenters from rvtoolsbatch and will send all it all as different attachment but in a single mail?
From what i read on rvtools documentation, it was suggesting to use a colon as a separator, but i couldnt get like what i want to have and Keep getting error Unhandled exception: Invalid URI: The hostname could not be parsed.
I can write multiple lines to invoke multiple vcenters and send email or attachment likewise, but that would beat a purpose as i wanted to have all rvtools report of all vcenters in a single email.
Please help.
Cheers
Try something like this
$ExportPath = 'C:\Temp'
$Servers = 'vcenter1','vcenter2'
$Servers | %{
. "C:\Program Files (x86)\Robware\RVTools 3.9.3\RVTools.exe" -passthroughAuth -s "$($_)" -c ExportAll2xls -d "$($ExportPath)" -f "RVTools-$($_)"
}
$smtpServer = 'mail.lucd.info'
$to = 'lucd@lucd.info'
$from = 'lucd@lucd.info'
$att = Get-ChildItem -Path $ExportPath -Filter RVTools*.xlsx | select -ExpandProperty FullName
Send-MailMessage -SmtpServer $smtpServer -Subject 'RVTools reports' -To $to -From $from -Attachments $att
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$ExportPath = 'C:\Temp'
$Servers = 'vcenter1','vcenter2'
$Servers | %{
. "C:\Program Files (x86)\Robware\RVTools 3.9.3\RVTools.exe" -passthroughAuth -s "$($_)" -c ExportAll2xls -d "$($ExportPath)" -f "RVTools-$($_)"
}
$smtpServer = 'mail.lucd.info'
$to = 'lucd@lucd.info'
$from = 'lucd@lucd.info'
$att = Get-ChildItem -Path $ExportPath -Filter RVTools*.xlsx | select -ExpandProperty FullName
Send-MailMessage -SmtpServer $smtpServer -Subject 'RVTools reports' -To $to -From $from -Attachments $att
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Worked as charm but since it is calling upon many vcenters and takes much time, it cannot send the email when the spreadsheet isnt ready.
So i just put command start-sleep -s 300 before the following syntax. thanks LucD!
$att = Get-ChildItem -Path $ExportPath -Filter RVTools*.xlsx | select -ExpandProperty FullName
Send-MailMessage -SmtpServer $smtpServer -Subject 'RVTools reports' -To $to -From $from -Attachments $att
Hi All,
where do I execute from ?
I am new to this technology domain, so, please guide me.
1. I am able to login to vSphere web client and have an overview of all the 6 vCenters in the environment
2. I have to log into RV tool for each individual vCenter and then, extract the report dump.
So, how do I execute the listed script and where, in which environment ?
Considering I have a restricted client Citrix desktop environment, where I have may have to execute this.
I get this error message on this forum page:
The request could not be validated as originating from within the SBS application
The request could not be validated as originating from within the SBS application
Please advie that what does that mean, am I doing something wrong ?
No clue to be honest.
From where, and how do you start the script?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi LucD,
thank you !! please to customize the report to be saved on a local directory
That is what the $exportPath variable is doing.
Or do you mean something else?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
getting the following error
Send-MailMessage : Cannot validate argument on parameter 'Attachments'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At line:27 char:102
+ ... VTools reports' -To $to -From $from -Attachments $attachment.Fullname
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage
I suspect you might be running the script against VCSA 6.5 (or higher)?
In that case passthroughAuth does not work, and you will have to use the -u and -p parameters instead.
See RVTools not working with VCSA 6.5 (TLS 1.0 is disabed)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Below is the error for long time now upon repeated tries, seems the ps error or refers to some other. Pl help.
The term 'C:\Program Files (x86)\Robware\RVTools 3.9.3\RVTools.exe' is not
recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:9 char:3
+ . "C:\Program Files (x86)\Robware\RVTools 3.9.3\RVTools.exe" -passthr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Program File...9.3\RVTools.e
xe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
$ExportPath = 'C:\Temp'
$Servers = 'vcenter-dev'
$Servers | %{
. "C:\Program Files (x86)\Robware\RVTools 3.9.3\RVTools.exe" -passthroughAuth -s "$($_)" -c ExportAll2xls -d "$($ExportPath)" -f "RVTools-$($_)"
}
$smtpServer = 'mailserver.amat.com'
$to = 'JaiPrathop_Sadasivam@amat.com'
$from = 'JaiPrathop_Sadasivam@amat.com'
$att = Get-ChildItem -Path $ExportPath -Filter RVTools*.xlsx | select -ExpandProperty FullName
Send-MailMessage -SmtpServer $smtpServer -Subject 'RVTools reports' -To $to -From $from -Attachments $att
Is that the folder where you installed RVTools?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
So i am adopting this script and i am using exactly same way except for that i am using encrypted credentials.
Q - How do i ensure that files are deleted post Sending the mail. I fear this might fill up the disk post
The vCheck script doesn't have this 'cleanup' feature builtin at the moment.
You will have to do the cleanup your self in a script.
By default the files are created in $env:Temp. but you can change that with the OutputPath parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc
LucD,
I have 35 vCenter and need to extract the Rv tools report on a daily basis. I just tried with 2 vc but it throws an error
PS D:\Bob> .\rvtools_report.ps1
Send-MailMessage : Cannot validate argument on parameter 'Attachments'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At D:\Bob\rvtools_report.ps1:27 char:102
+ ... rver -Subject 'RVTools reports' -To $to -From $from -Attachments $att
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage
Thanks
V
It looks as if the $att variable is $null, meaning to export files were not created.
The snippet in this thread is using the parameter -passthroughAuth, meaning that the user currently running the command is allowed to connect to the vCenter(s).
If that is not the case, you can use the -u and -p parameters (see RVTools doc).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd for the script. its working using -u username and -p password for latest vCenter server version.
Could you please help to suggest how we can append the date also along with exported file. Moreover can we able to schedule this trigger automatically via schedule task.
i have tried to schedule the task by calling powershell via batch file but its works only if i run manually, not auto trigger is working.
Kindly advise with your comments.
Regards
Narayanan.
The filename for the report is passed via the -f parameter.
Change it to something like
-f "RVTools-$($_)-$(Get-Date -f 'yyyyMMdd').xlsx"
To run it via the Task Scheduler you follow the normal method to schedule a PS script.
For example, have a look at Re: How to schedule the powercli script in task scheduler
If you can't get it to work, share the code you are using to create the Scheduled Task.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD quick response. Works Perfect.
For schedule task, I have copied the arguments -NonInteractive -NoLogo -NoProfile -ExecutionPolicy Bypass from your reference link and updated the task.
Can you help to suggest if different passwords can be added for each vCenter servers (vCenter1 & vCenter2) in the same script? Kindly advise with your inputs
$ExportPath = 'C:\Temp\Rvtools'
$Servers = 'vCenter1,vCenter2'
$Servers | %{
. "C:\Program Files (x86)\Robware\RVTools\RVTools.exe" –u Root1 –p _RVToolsPWDRHyqpGAHn3n0d3xGrJzoQrIsq423hxzs= -s "$($_)" -c ExportAll2xls -d "$($ExportPath)" -f "RVTools-$($_)-$(Get-Date -f 'yyyyMMdd').xlsx"
}
$smtpServer = 'smtp.testdev.com'
$to = ''
$from = ''
start-sleep -s 100
$att = Get-ChildItem -Path $ExportPath -Filter RVTools*.xlsx | select -ExpandProperty FullName
Send-MailMessage -SmtpServer $smtpServer -Subject 'RVTools reports' -To $to -From $from -Attachments $att