Hi,
Need a powershell script to collect the below given info from virtual center.
vmname | ESX Name | memory(GB) | vCPU count | vNIC Count | IP address(all) | vmdk(s) size(GB) | Total vmdk size(GB) | Datastore name | Tools version | tools update | shares | reservations(MB) | limit(MB) | snapshot count | Guest OS
vmdk(s) size(GB) ---> Need all vmdk size of the vm seperated by "". EX: for a vm of 3 vmdk's of size 20,20,10GB each the output would be 2020+10
Datastore Name ---> Name of the datastore where VMX is located.
Tools update ---> Need status like old or updated
Do you have a custom field with the name "CreatedBy" in your vSphere environment ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
It working after upgrading PowerGuito latest version.
I have one question, Can I get this report in excel format or in comma seperated format ?
Regards
GD
Sure, on the last line change this
Out-File "C:\VMreport.txt"
into this
Export-Csv "C:\VMreport.csv" -NoTypeInformation
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Thanks a lot, its working. few changes I have seen after taking the report in csv format, script is not able to fetch the Ipaddress and VMdkname , which it was able to get earlier in txt format.
Instead of ipaddress I am getting System.String[] , and for vmdkname I am getting System.Object[[]|http://] , and for vmdkname I am getting System.Object[]
Any clue.
That's because those properties are arrays.
The Export-Csv cmdlet doesn't handle arrays very well
With the Join function of the String object, you can join the array elements together
See attached script.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
HI Luc,
VMDkname was not important for me, so I have remvoed it, and script started working, along with the Ipaddress details.
Can I also get the Vlan this vm has ?
Thanks a ton again.
GD
There was a typo, a dot instead of a comma.
Attached the corrected version with the VLANids.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
As excepted its working, One more question, as I am proving a list to find the vm details, there may be some vm's which are not there in the environment, it is giving error for this vm's on the console, can I get this list of the vm's which didn;t found in a seperate file ?
in memeory field I am not getting the data in GB, it is showing me , 3609375, where it should show me 3696 , I am doing the the calculation in excel fie, is it possible do get the data in GB.
Thanks a ton again.
GD
The attached script creates a separate file with the guests that were not found.
I'm not sure which field you mean for the GB unit.
What is the name of the property ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
first of all, Thanks a lot for this script...
The datastoreName is displaying "VMware.Vim.VirtualMachineConfigInfoDatastoreUrlPair[]" for all the VM's.
Also it will good if we can add the port group column.
Thanks !!!
There you go.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi!
i cant get the script to return anything...
here is what i do:
open vi powershell
i do a connect to the vcenter ip
when i run the ./Get-VMInformation-v3.ps1
the report.csv is empty
what do i do wrong?
The script Get-VMInformation-v3.ps1 writes the output to the console, not a .csv file.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
im using the Get-VMInformation-v4-1-to-text-3-1-2.ps1
Are there any steps i should do in order to get a report? should i use any switches after the script?
should i do something other in the powershell before running the script?
Hi Luc,
After making the changes in this script Get-VMInformation-v4-1-to-text-3-1-2.ps1 to give the output of the not found vm's in some file, script is giving issue, it doesnt; stops, its just says scripting executing, andnever stops.
when I have disabled the above features from the scrpt, it worked as per desire.
Can you please look ?
Regadrs
GD
That version uses a .txt file that contains the names of the VMs to report on.
If you want to use the script for all your VMs, you have to change thfirst lines.
This
$allLines = @() # Line added $null | Out-File "C:\vmnotfound.txt" Get-Content -Path "C:\vmnames.txt" | %{ Get-VM -Name $_ -ErrorAction SilentlyContinue if(!$vm){ $_ | Out-File "C:\vmnotfound.txt" -Append } } | ForEach-Object {
should be replaced by this
$allLines = @() # Line added Get-VM | ForEach-Object {
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There was indeed a bug in the script.
I updated the attached script above.
Please try again.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i just want to let you know that now it works!
the script works like a charm!
how can i add in to get also the stats for the "used space" and "provisioned space" ?