PowerCLI to display VMware disk

Any idea how to server the disk size and free space for VMware server (not the VM guests) with PowerCLI ?

Thx
AXISHKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Luciano PatrãoICT Senior Infraestructure  Engineer  Commented:
Hi,

Can you elaborate more what you plan to display?

VMware server? VMware workstation?? ESXi?? System partitions?? Datastores?
0
AXISHKAuthor Commented:
I want to check the disk size for my VMware servers and automate with PowerCLI to send it through email.

Thx

VMDisk.png
0
Luciano PatrãoICT Senior Infraestructure  Engineer  Commented:
Hi

Again, VMware servers can lot of things and also disk.

But with the image I can notice that you want to display datastore information.

I use one of Luc Dekens script and make some changes to your needs.

#########################################################################################
# Created by: Luciano Patrão (using Luc Dekens original script to display datastore)   	#
# Date: 12-05-2018   																	#
# List Datastore space and send report by email  										#
#########################################################################################

$server = "vCenter/ESXi"
$user = "user"
$pwd = "password" 

Connect-VIServer $server -User $user -Password $pwd
cls

$body = Get-Datastore | Select @{N='Datastore';E={

        $script:p = [math]::Round(($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB*100,1)
        if($p -lt 70){"#fg#$($_.Name)#fe#"}
        elseif($p -lt 90){"#fy#$($_.Name)#fe#"}
        else{"#fr#$($_.Name)#fe#"}}},
		
    @{N='CapacityGB';E={[math]::Round($_.CapacityGB,1)}},
    @{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB,1)}},
    @{N='UsedPercent';E={$script:p}} | ConvertTo-Html
	
$body = $body.Replace('#fg#','<font color=green>').Replace('#fy#','<font color=yellow>').Replace('#fr#','<font color=red>').Replace('#fe#','</font>')

$from = 'from@domain.com' 
$to = 'from@domain.com' 
$smtp = "smtp.domain.com" 
$sub = 'Datastore Report' 
$body = $body | Out-String
$secpasswd = ConvertTo-SecureString "email password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($from, $secpasswd)
Send-MailMessage -To $to -From $from -Subject $sub -Body $body -Credential $mycreds -SmtpServer $smtp -DeliveryNotificationOption Never -BodyAsHtml

Open in new window


Hope this helps

Jail
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.