Hi All,
I'm new to vm ware power cli..
My task is to get a list of all vm info (vm name, host name, state , ipaddress , osname .. etc)...
i 've created a command to generate the expected result
Get-Vm | foreach-object {Get-Vmguest $_.Name} | where {$_.State -eq "Running"}| select HostName , VmName, IPAddress, OSFullName, State |Export-Csv nylab.csv
But i want to create a script which has to run periodically and generate the result into a excel sheet...
Please help me out...
In the above command IPAddress returns "system.string [] " in the excel sheet instead of the ip ..
But in vmware powercli command prompt it returns as
HostName : testwas7
VmName : RHEL53-SA78A 10.128.34.249
IPAddress : {10.128.34.249, fe80::20c:29ff:feda:2b65}
OSFullName : Red Hat Enterprise Linux 5 (64-bit)
State : Running
Please help this too...
Those are most probably guest where the VMware tools are not installed or where the guest is powered off.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Go for this thread
http://communities.vmware.com/message/1640646#1640646
You'll need to put it in scheduled tasking, or you could have the script schedule itself.
Good luck trooper.
- abe
Hi awliste,
Thanks.. i could solve the ipaddress issue.. now i could get the result in excel sheet but the script what i'm using is not retrieving all the details
$reports = @()
GET-VM |
ForEach-object {
$vm = $_
$report = " " |Select-Object VMname,GuestOS,MemoryGB,VCPUcount,IPaddresses,VMHost
$report.VMname = $vm.name
$report.GuestOS = $vm.Guest.OSFullName
$report.MemoryGB = $vm.MemoryGb/1KB
$report.VCPUcount = $vm.NumCpu
$report.IPaddresses = ::Join(',',$vm.Guest.IPAddress)
$report.VMHost = $vm.Host
$reports += $report
}
$reports |Export-Csv "C:\vmreport.csv" -NoTypeInformation
i've attached the excel sheet.. it's getting all the vm names but not some vm machines os name , ipaddress ..
Please help me out
Those are most probably guest where the VMware tools are not installed or where the guest is powered off.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
how to get only ipaddress ?
the above script returns "10.128.34.249, fe80::20c:29ff:feda:2b65" in the excel sheet but i want to get only "10.128.34.249" ..
Please give some tips to solve it..
Thanks in advance..
You're seeing that because you have apparently IPv6 enabled on some of the guests.
Now luckily, the VNware Tools always seem to pick the IPv4 address first.
The attached script only reports the IPv4 address.
And I fixed the error message you got when a guest didn't have VMware Tools installed or was powered off.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
Thanks...
But i didn't find any commandlet to find vmware tools installed or not in your script...
I've attached the script to find it.. but i'm getting the error msg as
+ $report.T <<<< oolsVersion = $VMview.Config.Tools.ToolsVersion
Property 'ToolsUpdate' cannot be found on this object; make sure it exists and
is settable.
At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vmreport.ps1:15 char
:14
Please help me out
That test was this piece of code.
if($vm.Guest.IPAddress)...
Without Toos installed this property is $null.
Attached an updated script that takes into account the new properties you added in the report.
And I fixed the MemeoryGB problem.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference