Hi All,
I'm planning to take a snapshot for around 400 VM's before VMware tools & VM version upgrade. Can we pull the report for Datastore free space with respect to each VM to data store before taking a snapshot? Before taking snapshot want to see Datastore having sufficient space. VM's name will be in C:\Temp\vmliste.txt
E.g. VM1 ---> Data store 1 Free space 15 % GB - 8
VM2 --> Datastore 2 Free space 12 % GB - 6
Thanks
vmk
Ok, think I got it.
Try like this
ForEach-Object -Process {
Get-Datastore -RelatedObject $_ |
Select @{N = 'VM'; E = {$vm.Name}}, Name,
FreeSpaceGB,
@{N = 'FreeSpace%'; E = {"{0:P}" -f ($_.FreeSpaceGB / $_.CapacityGB)}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
ForEach-Object -Process {
Get-Datastore -RelatedObject $_ |
Select @{N = 'VM'; E = {$vm.Name}}, Name,
FreeSpaceGB,
@{N = 'FreeSpace%'; E = {"{0:P}" -f ($_.FreeSpaceGB / $_.CapacityGB)}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear LucD,
I want to pull for a specific list of VM's from C:\temp\list.txt.
Can you please help.
Thanks
vmk
Change the 1st line to
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I ran the script but I want the VM's also should be published
VM Name FreeSpaceGB FreeSpace%
VPLX_IND_NP_EE66 828.3535156 20.22%
VPLX_IND_NP_EE5C 1069.270508 26.11%
VPLX_P_P2C2_D2319 908.5410156 75.73%
VPLX_P_P2C3_D2499 704.1796875 58.69%
thanks
vmk
Sorry, don't know what you mean here?
The VM name is in the output.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, VM name in the output.
Ok, think I got it.
Try like this
ForEach-Object -Process {
Get-Datastore -RelatedObject $_ |
Select @{N = 'VM'; E = {$vm.Name}}, Name,
FreeSpaceGB,
@{N = 'FreeSpace%'; E = {"{0:P}" -f ($_.FreeSpaceGB / $_.CapacityGB)}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD. it worked but i saw multiple errors on the screen after completing the execution.
Thanks
vmk
The error message seem sot indicate that there are VM names in the .txt file that are not found with Get-VM.
Do all the VMs mentioned in the .txt file present?
If it is the intention to have non-existing VMnames in the file, add the -ErrorAction SilentlyContinue on the Get-VM cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes, i included all the 421 VM's which I was looking for snapshot space but surprised to see the error and I got the output in CSV for all 421 VM's
Could it be that you are connected to more than 1 vCenter, and that the error comes form one of the other vCenters?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry, I have only one VCenter.
If you take the name of one of those VMs in the error messages, and do a Get-VM with that name, do you get an error?
That error only comes when a VM with the specified name is not found.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I want to add the Cluster name also in the report. is it possible?
thanks
vmk
Try like this.
Does this mean that the errors you got are gone?
ForEach-Object -Process {
Get-Datastore -RelatedObject $_ |
Select @{N = 'VM'; E = {$vm.Name}},
@{N='Cluster';E={(Get-Cluster -VM $vm).Name}},
Name, FreeSpaceGB,
@{N = 'FreeSpace%'; E = {"{0:P}" -f ($_.FreeSpaceGB / $_.CapacityGB)}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, today I didn't see any error when executed earlier script.