Hi gurrus and LucD
I am looking for a Script which can list all VMS with E1000 NIC type through CSV file output.
The script must search information in a multiple Vcenter servers plus multiple clusters and list all the VMs name, Status (either powers on or off) with NIC type E1000 Type only not others.
Regards
Nauman
Try like this
$report = @()
foreach($cluster in Get-Cluster){
foreach($rp in Get-ResourcePool -Location $cluster){
foreach($vm in (Get-VM -Location $rp | Where{Get-NetworkAdapter -VM $_ | where{$_.Type -eq 'e1000'}})){
$report += $vm | Select @{N='VM';E={$_.Name}},
@{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},
@{N='Cluster';E={$cluster.Name}},
@{N='ResourcePool';E={$rp.Name}}
}
}
}
$report | Export-Csv C:\temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try the following.
The script assumes that you are connected to all vCenters (multiple mode).
Get-VM |
Where{Get-NetworkAdapter -VM $_ | where{$_.Type -eq 'e1000'}} |
Select Name,@{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Basically, i am looking for a CSV file which contains VM Names,Nic type . Could you please check the below script and add more information like in a multi cluster, multi vcenter environment. Through the script i can connect all V center straight away with one credentials and list everything in a Csv file.
connect-viserver -Server ######,#######,#######,####### (All V centers)
$report = @()
foreach($cluster in Get-Cluster){
foreach($rp in Get-ResourcePool -Location $cluster){
foreach($vm in (Get-VM -Location $rp)){
$report += Get-VM |
Where{Get-NetworkAdapter -VM $_ | where{$_.Type -eq 'e1000'}} |
Select Name,@{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}}
}
$report | Export-Csv C:\temp\report.csv -NoTypeInformation -UseCulture
}
}
It doesn't works properly
Try like this
$report = @()
foreach($cluster in Get-Cluster){
foreach($rp in Get-ResourcePool -Location $cluster){
foreach($vm in (Get-VM -Location $rp | Where{Get-NetworkAdapter -VM $_ | where{$_.Type -eq 'e1000'}})){
$report += $vm | Select @{N='VM';E={$_.Name}},
@{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},
@{N='Cluster';E={$cluster.Name}},
@{N='ResourcePool';E={$rp.Name}}
}
}
}
$report | Export-Csv C:\temp\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD Thanks for the above script but it doesn't shows the column of Network adapter Type with E1000. I want to display one more column with this information. The below script is correct ?
$report = @()
foreach($cluster in Get-Cluster){
foreach($rp in Get-ResourcePool -Location $cluster){
foreach($vm in (Get-VM -Location $rp | Where{Get-NetworkAdapter -VM $_ | where{$_.Type -eq 'e1000'}})){
$report += $vm | Select @{N='VM';E={$_.Name}},
@{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}},
@{N='Cluster';E={$cluster.Name}},
@{N='ResourcePool';E={$rp.Name}},
@{N='Adapter Type';E={$_.Type}}
}
$report | Export-Csv C:\temp\report.csv -NoTypeInformation -UseCulture
}
}
If we only report on VMs that have an E1000 NIC, aren't all VMs in the CSV using an E1000 ?
Or do you have VMs with multiple NICs of different type ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Firstly, I have a VM with different multiple NICs types. I want script checks all multiple NICs of different types and pulls out those VMs who have only E1000 Nic type and this information of NIC type should be displayed in a CSV file along with other information (like Resource pools VC etc) .
I hope it makes much clear