Special thanks to my better looking colleague @ http://blogg.schillman.se/
He is a powershell guru!
I did this on Linux so I do not have the power to store username and password. But I know that you can do this if you are running Windows!
If the vmware modules are not installed:
Start powershell
Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore -Confirm:$false Install-Module -Name VMware.PowerCLI -Scope CurrentUser Install-Module -Name DRSRule -Scope CurrentUse
After that create a file.ps1 with this:
Username:
Password:
SMTP server:
Export-Csv path:
Connect-VIServer 11.11.11.11 -User "user" -Password "password" Get-VM | Select Name,VMHost,@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},@{N='DRSGroup';E={$script:group = Get-DrsClusterGroup -VM $_; $script:group.Name}} | Export-Csv C:\tmp\export.csv -NoTypeInformation -UseCulture; send-mailmessage -to emailadress@domain -from emailadress@domain -subject "Report" -body "Report DRS, Datastore" -Attachments C:\temp\export.csv -SmtpServer mailserver -Port 25
Awesome, Tremendous work with combining everything into a oneliner 😉
LikeLike