Hi all-
Trying to find a way to automate a daily export of out vcenter inventory. Is there a way to schedule this and save it somewhere specific?
I can get RVTools to export a copy locally from command line, but I've been unsuccessful adapting that to a batch file that I could run via scheduled task in Windows. (the included batch file example in the RVTools docs are for emailing which I don't want/need)
For those who need the same thing, I'd be curious to know how you all do it. Thanks!
The example in the documentation exports the data and then mails the results. However, you can simply remove the "Send mail" lines if you only want to save the results.
André
Hey Andre,
Thanks for the reply. I didn't even catch that because it was labeled as "AttachmentDir" which made me think it was mail related. I'll give that a try and follow up if I'm successful. Thanks again!
Hi sel57,
You can achieve using the combination of PowerShell and PowerCLI. Here is an handy script that I just made on the fly. It can be modified as per your need.
Add-PSSnapin VMware.VimAutomation.Core
$Inventory = Get-Inventory -Location "Datacenter"
$Inventory | Export-Csv C:\Inventory.csv -NoTypeInformation
Send-MailMessage -From "user1@domain.com" -To "user2@domain.com" -Subject "VCenter Inventory" -Body "List of the vCenter Inventory" -Attachments "C:\Inventory.csv"
Hope this helps.
Cheers,
Adil Arif
I can't seem to get the example bat file working.
The below works fine if I run from command line from the program directory, but I need a way to automate this daily, so I thought the .bat would be ideal to run via scheduled tasks.
rvtools –u domain\user–p password -s vcenter-ip -c ExportvInfo2xls -d C:\Users\MyUser\Desktop -f Document-Name.xls
I haven't figured out why the bat isn't generating a file yet. I noticed there's no place to put credentials in the .bat, but -passthroughAuth command is used, so I assume it should still work as I'm logged in as a user with admin access to our vcenter.
Thanks @AdilArif. I first started down that route, but the fact that I know nothing about Powershell caused me to try an easier route first. I got an error about needing some cmdlet installed, and though I'm sure I could figure it out, I wanted to try something I was more familiar with first.
I figured out my .bat file issue. What I did was put the following into a .bat file, but I needed to put quotes around the Program Files directory. Here's the entire contents of my batch file using RVTools. It works!
@echo off
C:\"Program Files (x86)"\RobWare\RVTools\rvtools –u domain\user–p password -s vcenterip -c ExportvInfo2xls -d C:\Users\MyUsername\Desktop\ -f MyFileName.xls
exit
In order to run this script, as Adil Arif alluded to, you'll need to have PowerCLI installed and either run the script from PowerCLI or as a scheduled task via powershell (hence the add-pssnapin line to add the PowerCLI cmdlets.)