I need to get list of my all Vm in my VC server which are having Thin disk and also for one which is not having thin disk.
I do understand it can be done by Power CLI and i have Vmware Vsphere Power CLI installed. I also find few scripts on net , but i dont knw how to use them
Kindly suggest step by step how to run such scripts and from which console as well?
Thanks
Deepak
If you have the names of these servers in a CSV file with this layout.
Name server1 server2 ....
Then you can use a script like this
$report = @() Import-Csv "C:\My-Csv-file.csv" | %{ $vm = Get-VM $_.Name $vm | Get-HardDisk | %{ $row = "" | Select VMname, Folder, HDname, HDformat $row.VMname = $vm.Name $row.Folder = (Get-View $vm.FolderId).Name $row.HDname = $_.Name $row.HDformat = $_.StorageFormat $report += $row } } $report | Export-Csv "C:\VM-disk.csv" -NoTypeInformation -UseCulture
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
From the PowerCLI prompt you can run the following line to list the names of all your guests that have 1 or more 'Thin' disks
Get-VM | where {($_ | Get-HardDisk | %{$_.StorageFormat}) -contains "Thin"} | select Name
The Get-VM retrieves all the guests.
For each guest there is a condition, the where clause.
In the where clause we retrieve all the hard disks connected to that guest and then for each hard disk we get the disk format (thick or thin).
The format values are stored in an array and the -contains operator check if that array contains 1 or more 'thin' entries.
For each guest that passes the test, the line displays the name
If you want to list the guests that have no thin disk, you can use the -notcontains operator.
Get-VM | where {($_ | Get-HardDisk | %{$_.StorageFormat}) -notcontains "Thin"} | select Name
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Deepak,
Two easy options for you:
1) Download, install and run RVTools
On the vDisk tab you will see a column called 'Thin' - which will be either true or false for each of your VMs.
2) Download and install PowerGui
and the associated VMware powerpacks.
With this tool you can connect to your managed host (either vCenter or an individual ESX server) and execute powershell scripts to interrogate the VMs for thin provisioning etc.
I could dig out the specific powershell commands to do the above, but it'll take a little longer and the GUI is your friend!
Hope that helps.
Dan
LucD: Thanks for your reply, i am currently running the script and let you know once done. I think with this script i can fetch the thin disk and just replacing thin with thick ..get me Thick disk info
Is there any way where at one shot i can get all these info of all VM and output in Excel format.
Also ensure me that running such scripts how much effect the VC , ESX , Vm performance..If it really hampers something then i would prefer to run such scripts in night.
Don: I am just downloading the stuffs and wait for you to get me back the script..
I am searching for a easiest way as am a Starter to Power CLI.
Thanks again!!
Cheers
Deepak
Hello Deepak,
For ease of Excel putput - use RVTools.
As far as i'm aware the scripts run against the vCenter database (if you choose to run them against vCenter) and will have minimal impact on operations.
Regards,
Dan
ok, i am trying the options..
Thanks
It's very easy in PS to create a CSV.
The following script will list all guest with all their hard disk and for each disk the format.
$report = @() Get-VM | %{ $vm = $_ $_ | Get-HardDisk | %{ $row = "" | Select VMname, HDname, HDformat $row.VMname = $vm.Name $row.HDname = $_.Name $row.HDformat = $_.StorageFormat $report += $row } } $report | Export-Csv "C:\VM-disk.csv" -NoTypeInformation -UseCulture
If you only want the 'thin' HDs in the report, you can adapt the script like this
$report = @() Get-VM | %{ $vm = $_ $_ | Get-HardDisk | where {$_.StorageFormat -eq "thin"} | %{ $row = "" | Select VMname, HDname, HDformat $row.VMname = $vm.Name $row.HDname = $_.Name $row.HDformat = $_.StorageFormat $report += $row } } $report | Export-Csv "C:\VM-disk-thin.csv" -NoTypeInformation -UseCulture
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for this one.
But as am a new starter to Power CLI and hence not sure, where and how should i run this script?
Kindly suggest.
Also i have a another question: I have a list of VM and they are under different folders at VC server , is there any way i can get the list in Excel sheet containing my VM name and corresponding Folder (As in VC Center)
Thanks
Sure, here you go.
$report = @() Get-VM | %{ $vm = $_ $_ | Get-HardDisk | %{ $row = "" | Select VMname, Folder, HDname, HDformat $row.VMname = $vm.Name $row.Folder = (Get-View $vm.FolderId).Name $row.HDname = $_.Name $row.HDformat = $_.StorageFormat $report += $row } } $report | Export-Csv "C:\VM-disk.csv" -NoTypeInformation -UseCulture
Note1 that this shows only the name of the folder in which the guest is located, not the complete path.
Note2 that you could see some of the hidden folders (like 'vm').
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks!!
But how do i run this script?
Do i have to paste this script at command prompt of Power CLI..
Kindly suggest step by step..where i can go?
Thanks
You save the script in a file with the extension .ps1.
Start the PowerCLI.
When not yet done, make sure PS is configured to allow the execution of scripts.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Then connect to the vCenter or ESX(i) server.
Connect-VIServer -Server <your-server-name> -User <your-user> -Password <your-password>
From the PowerCLI prompt, you type the name of the file (ThinVM.ps1 in the example) like this (provided you're located in the correct directory).
.\ThinVM.ps1
Hit and the script will execute.
That's all there is to it.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ok, thanks for the script.
As of now i have a list of few VM ..either in notepad and in excel ..is there any way i can import my VM list and get the output in of there folder location in VC.
Thanks
Deepak
Do you mean the full path ?
The ýellow'folders (Hosts and Clusters view) or the 'blue' folders (VMs and Templates view) ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The full path is not as important!!
I just mean that i have a list of servers in Excel sheet (let it be 50 out of 100 servers of VC) and i want to know the folder name corresponding to those 50 servers, is there any way while running the script i can give any location where i put my list of servers in excel sheet. And power CLI take that and give me out put corresponding to them.
I knw its bit annoying..but as am using it first time
Thanks a lot..i got the output and there filter the data in Excel.
Wonderfull script.. Thanks a lot man!!
I will award you points as well!!
Cheers
Deepak
If you have the names of these servers in a CSV file with this layout.
Name server1 server2 ....
Then you can use a script like this
$report = @() Import-Csv "C:\My-Csv-file.csv" | %{ $vm = Get-VM $_.Name $vm | Get-HardDisk | %{ $row = "" | Select VMname, Folder, HDname, HDformat $row.VMname = $vm.Name $row.Folder = (Get-View $vm.FolderId).Name $row.HDname = $_.Name $row.HDformat = $_.StorageFormat $report += $row } } $report | Export-Csv "C:\VM-disk.csv" -NoTypeInformation -UseCulture
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Cool feature..its a amazing tool!!
Thanks again
Regards
Deepak
My 2 cents worth: If storage is your concern, other than finding all thin disks, RVTools is also able to find all snapshots.
chaikeong
Hi chaikeong,
Your RV tools was also a nice feature..do we also have some advance version of this or something advance than this tool as well.
i just in advance version of this ..there might be some new features
Thanks
Deepak