Get VM on what Datastore and what DRS group the VM is member of, export the result and email to you in a oneliner.

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

 

Advertisement

One thought on “Get VM on what Datastore and what DRS group the VM is member of, export the result and email to you in a oneliner.

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: