Dear Team Please Help
I want to retrieve the total disk size and free size data c & d and then in certain clusters, for the script please guide me friends
thank you
You are talking about the disks in the guest OS?
Do you have VMware Tools installed on all your VMs?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear Mr LucD
Yes i have, but how to get all vm with script ?
Thank You
Tomi Irawan
If you answered my previous questions with yes, this should do the trick.
Get-Cluster -Name $clusterName |
Get-VM -PipelineVariable vm |
Get-VMGuest |
Select-Object -ExpandProperty Disks |
Sort-Object -Property Path |
Where-Object{$_.Path -match "^C|^D"} |
Select-Object @{N='VM';E={$vm.Name}},
Path,
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear Mr LucD
i can't get vm name with right name
maybe look like
Header 1 | Header 2 | Header 3 |
---|---|---|
vm satu | 100 gb | 50 gb |
vm dua | 50 gb | 25 gb |
vm tiga | 200 | 150 |
Thank You
Which PowerShell version are you using?
Do a
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear Mr LucD
File Already attach
Thank You
Tomi Irawan
That is not what I asked, I asked for the PowerShell version.
Can you do
And your PowerCLI version is rather old.
Is there a reason you are still using this old version?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear Mr LucD
Im sorry Sir LucD.
Thank You
No problem, just wanted to check you had a PS version that supported the PipelineVariable parameter.
The following will write the result to a CSV file.
Can you check and show me what you mean with the VM name is missing?
Do you run this from the PS prompt or from a .ps1 file?
When I run this, the VM's Displayname is in the CSV file.
Get-Cluster -Name $clusterName |
Get-VM -PipelineVariable vm |
Get-VMGuest |
Select-Object -ExpandProperty Disks |
Sort-Object -Property Path |
Where-Object{$_.Path -match "^C|^D"} |
Select-Object @{N='VM';E={$vm.Name}},
Path,
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear Mr LucD
Look like the captuire
Than You
Ok, gotcha.
Try like this
Get-Cluster -Name $clusterName |
Get-VM -PipelineVariable vm |
ForEach-Object -Process {
Get-VMGuest -VM $vm |
Select-Object -ExpandProperty Disks |
Sort-Object -Property Path |
Where-Object{$_.Path -match "^C|^D"} |
Select-Object @{N='VM';E={$vm.Name}},
Path,
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}}
} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear Mr LucD
Thank You For your help, after discuss with my team, its more better if when we have more disk to one vm example :
Header 1 | Header 2 | Header 2 | Header 3 |
---|---|---|---|
hdd1 | total size | usage size | free space |
hdd 2 |
Thank You so Much Sir LucD God Bless you
How do you think that can/should be done?
You are asking for a link between the vDisk (the VMDK) and the guest OS partitions.
As I mentioned on several occasions before where this question pops up, there is no foolproof method of establishing that link between a VMDK and guest OS partitions.
A VMDK can have more than 1 partition, a guest OS partition can combine VMDK, part of a VMDK might be visible as spare space in the guest OS....
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
im apologize in advance because I didn't know and
for the previous script is there a vm restriction in the data? because not all the VMs in the cluster are recorded.
Thank you
There could be two reasons why a VM is not in the list.
- the VM doesn't have VMware Tools installed or has been powered for a longer time. Then the Disks property might be empty
- the VM doesn't have drives that start with C or D
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
how can I pipe the PipelineVariable VM with a filter like where {$_.powerstate -eq 'PoweredOn' -and $_.Guest.OSFullName -match 'Windows.*'}
and is the a why for check each driveletter whats inside the VM, or is the only why like $_.Path -match "^C|^D|^E|^F|^G|^H|^I|^J|^K .....and so on"
Thanks...
ps for linux works diffent or even is not possible?
You don't need to use the pipelinevariable for that, you can just insert the Where-clause in the pipeline.
Get-Cluster -Name $clusterName |
Get-VM -PipelineVariable vm |
where {$_.powerstate -eq 'PoweredOn' -and $_.Guest.OSFullName -match 'Windows.*'} |
ForEach-Object -Process {
Get-VMGuest -VM $vm |
Select-Object -ExpandProperty Disks |
Sort-Object -Property Path |
Where-Object{$_.Path -match "^C|^D"} |
Select-Object @{N='VM';E={$vm.Name}},
Path,
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}}
} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Not sure what you mean by "... check each driveletter whats inside the VM ...".
Since the script expands the Disks property, all known disks will be listed.
For Linux the Path will be off the format /folder.
You can filter on that as well, for example
Where-Object{$_.Path -match "^/bin"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ah ok thanks,
one more question. I want to ad a Line for something like Warning if free space is under 10% and modify the output to get anly VM´s with freespace under 10%
the output for Warning is allways TRUE ?
ForEach-Object -Process {
Get-VMGuest -VM $vm |
Select-Object -ExpandProperty Disks |
Sort-Object -Property Path |
Where-Object{$_.Path -match "^C|^D|^E|^F|^G|^H|^I|^J|^K|^L|^M|^N" } |
Select-Object @{N='VM';E={$vm.Name}},
Path,
@{N='CapacityGB';E={[math]::Round($_.CapacityGB)}},
@{N='FreeSpaceGB';E={[math]::Round($_.FreeSpaceGB)}},
@{N='Warning';E={[math]::($_.FreeSpaceGB/$_.CapacityGB) -le 0.10}}
}
That is because of the Round you are using.
Any value less or equal to 0.5 will be rounded to 0, hence the $true for all those.
Just use
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference