This script I have written to pull information from all the Virtual PortGroup on esxi/vcenter and data is saved in a single CSV file, You can use it as a backup also, It is very helpful when modifying, analysing Portgroup configuration, If you take the portgroup backup with this script frequently you can even tell what are the changes done last time or compare those settings. This has saved my lots of time while troubleshooting my Virtual Standard Switch networking.
Earlier script for collecting networking information
PowerCLI esxi host Physical nic info in nice table format
Below are the settings captured and stored in CSV file.
Earlier script for collecting networking information
PowerCLI esxi host Physical nic info in nice table format
Find CDP or LLDP information on Windows Servers
- Esxi server name
- PortGroup Name, This will be per esxi server not the common one
- Vlan Id configured on PortGroup
- vSwitch name Portgroup resides
- PortGroup Type (vmkernel or Virtual Machines)
- Mac Address (If portgroup is virtual machine, Mac address of all virtual machines, else mac address of vmkernel portgroup)
- PortGroup Security Settings (Promiscuous mode, Mac address Changes, forged transmits)
- NicTeaming Settings (Whether they are inherited from vSwitch)
- Notify Switches
- Failback, order
- Active Nics, Standby Nics, Unused Nics
- Virtual machines count on the portgroup and their name, Ip address,
- PortGroup Binding compliance
- MTU Settings
- Management, vMotion, Ft, vSan enabled for vmkernel portgroup
This is the first screenshot when I am running script, It will collect all the virtual portgroup on the esxi in vCenter and then will collect and store information from each PortGroup in CSV file.
This is the second screenshot I want to show how the data will look like on the console. Some of the information will be blank depending on if portgroup is VMKernel or virtual machines.
Copy paste below code in text file and rename extension to .ps1
And exported excel/csv file looks like this
Any suggestions and modifications are welcomed.
<#
.SYNOPSIS
Gets the complete virtual portgroup information
.DESCRIPTION
This script creates a report of complete virtual portGroup information
of the vm’s guest OS
.NOTES
Find more information on http://kunaludapi.blogspot.com
Make sure you have installed Powercli and can connect to vcenter.
.EXAMPLE
PS C:\Temp> .\Get-VirtualPortGroupInfo.ps1
.EXAMPLE
PS C:\Temp> .\Get-VirtualPortGroupInfo.ps1 | Export-Csv -NoTypeInformation -Path C:\Temp\NetworkInformation.csv
#>
#####################################
## http://kunaludapi.blogspot.com
## Version: 1
##
## Tested this script on
## 1) Powershell v4
## 2) VMware vSphere PowerCLI 6.0 Release 1 build 2548067
## 3) Vsphere 5.5
#####################################
Begin {
if (-not(Get-PSSnapin vmware.vimautomation.core -ErrorAction SilentlyContinue)) {
Add-PSSnapin vmware.vimautomation.core -ErrorAction SilentlyContinue
}
$report = @()
$IPregex=‘(?<Address>((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))’
$VMHosts = Get-VMHost
} #begin
Process {
foreach ($esxi in $VMHosts) {
Write-Host "Collecting PortGroups from Esxi Server `"$($esxi.Name)`"" -BackgroundColor DarkGreen
#All PortGroups in esxi server
$PortGroup = $esxi | Get-VirtualPortGroup
#iSCSI software adapter on esxi
$iSCSIHBA = $esxi | Get-VMHostHba -Device $HBA -Type iSCSI | Where-Object {$_.Model -eq "iSCSI Software Adapter"}
#All VMKernel Ports on esxi Server
$VMkernelPorts = $esxi | Get-VMHostNetworkAdapter -Name vmk*
#Esxicli information of esxi server
$esxcli = $esxi | Get-EsxCli
foreach ($Group in $PortGroup) {
Write-Host "`tFetching Info from Portgroup `"$($Group.Name)`"" -ForegroundColor Yellow
$Obj = New-Object psobject
$Obj | Add-Member -Name EsxiName -MemberType NoteProperty -Value $esxi.Name
$Obj | Add-Member -Name PortGroup -MemberType NoteProperty -Value $Group.Name
$Obj | Add-Member -Name VLanId -MemberType NoteProperty -Value $Group.VLanId
$Obj | Add-Member -Name vSwitch -MemberType NoteProperty -Value $Group.VirtualSwitchName
#Find whether PortGroup is VMKernel or VirtualMachine
if ($VMkernelPorts.PortGroupName -contains $group.Name) {
$Portgrouptype = "VMKernel"
} #if ($VMkernelPorts.PortGroupName -contains $group.Name)
else {
$Portgrouptype = "VirtualMachine"
} #else #if ($VMkernelPorts.PortGroupName -contains $group.Name)
$Obj | Add-Member -Name PortGroupType -MemberType NoteProperty -Value $Portgrouptype
$Macs = $Group.ExtensionData.port.mac -join ", "
$Obj | Add-Member -Name Mac -MemberType NoteProperty -Value $Macs
$Obj | Add-Member -Name AllowPromiscuous -MemberType NoteProperty -Value $Group.ExtensionData.ComputedPolicy.security.AllowPromiscuous
$Obj | Add-Member -Name MacChanges -MemberType NoteProperty -Value $Group.ExtensionData.ComputedPolicy.security.MacChanges
$Obj | Add-Member -Name ForgedTransmits -MemberType NoteProperty -Value $Group.ExtensionData.ComputedPolicy.security.ForgedTransmits
#Teaming Policy
$NicTeamingPolicy = Get-NicTeamingPolicy -VirtualPortGroup $Group
$Obj | Add-Member -Name IsLoadBalancingInherited -MemberType NoteProperty -Value $NicTeamingPolicy.IsLoadBalancingInherited
$LoadBalancing = $Group.ExtensionData.ComputedPolicy.NicTeaming.Policy
switch ($LoadBalancing)
{
loadbalance_ip {$LoadBalancingPolicy = "Route based on IP hash"}
loadbalance_srcmac {$LoadBalancingPolicy = "Route based on source MAC hash"}
loadbalance_srcid {$LoadBalancingPolicy = "Route based on the source of the port ID"}
failover_explicit {$LoadBalancingPolicy = "use explicity failover order"}
default {$LoadBalancingPolicy = "Can't Determine"}
} #switch ($LoadBalancing)
$Obj | Add-Member -Name LoadBalancing -MemberType NoteProperty -Value $LoadBalancingPolicy
$Obj | Add-Member -Name IsNetworkFailoverDetectionInherited -MemberType NoteProperty -Value $NicTeamingPolicy.IsNetworkFailoverDetectionInherited
$Obj | Add-Member -Name NetworkFailoverDetection -MemberType NoteProperty -Value $NicTeamingPolicy.NetworkFailoverDetectionPolicy
$Obj | Add-Member -Name IsNotifySwitchesInherited -MemberType NoteProperty -Value $NicTeamingPolicy.IsNotifySwitchesInherited
$Obj | Add-Member -Name NotifySwitches -MemberType NoteProperty -Value $Group.ExtensionData.ComputedPolicy.NicTeaming.NotifySwitches
$Obj | Add-Member -Name IsFailbackInherited -MemberType NoteProperty -Value $NicTeamingPolicy.IsFailbackInherited
$Obj | Add-Member -Name Failback -MemberType NoteProperty -Value $Group.ExtensionData.ComputedPolicy.NicTeaming.RollingOrder
$Obj | Add-Member -Name IsFailoverOrderInherited -MemberType NoteProperty -Value $NicTeamingPolicy.IsFailoverOrderInherited
$ActiveNics = $Group.ExtensionData.ComputedPolicy.NicTeaming.NicOrder.ActiveNic -join ", "
$Obj | Add-Member -Name ActiveNics -MemberType NoteProperty -Value $ActiveNics
$StandbyNics = $Group.ExtensionData.ComputedPolicy.NicTeaming.NicOrder.StandbyNics -join ", "
$Obj | Add-Member -Name StandbyNics -MemberType NoteProperty -Value $StandbyNics
$UnusedNics = $NicTeamingPolicy.UnusedNic -join ", "
$Obj | Add-Member -Name UnusedNics -MemberType NoteProperty -Value $UnusedNics
#All VMs having assigned PortGroup
$IPv4Address = $null
if ($Portgrouptype -eq "VirtualMachine") {
$VMList = $null
$VMList = $Group | Get-VM
$VMs = $null
$VMs = $($VMList | Select-Object -ExpandProperty Name) -join ", "
$IPlist = $VMList.guest.Nics | Where-Object {$_.NetworkName -eq $Group.Name}
$IPv4List = $IPlist.IpAddress | Where-Object {$_ -match $IPregex}
$IPv4Address = $IPv4List -Join ", "
$IPv4SubnetMask = $null
$PortBindingCompliance = $null
$MTU = $null
$VmkernelNic = $null
$PathStatus = $null
$MGMT = $null
$vMotion = $null
$FT = $null
$vSAN = $null
} #if ($Portgrouptype -eq "VirtualMachine")
else {
$iSCSIPortGroup = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name).PortGroup | Where-Object {$_ -eq $Group.Name}
$VmkernelNicinfo = $VMkernelPorts | Where-Object {$_.PortGroupName -eq $Group.Name}
if ($iSCSIPortGroup -ne $null) {
$VMList = $null
$VMs = $null
$PortBinding = "Configured"
$IPv4Address = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name) | Where-Object {$_.PortGroup -eq $iSCSIPortGroup} | Select-Object -ExpandProperty IPv4
$IPv4SubnetMask = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name) | Where-Object {$_.PortGroup -eq $iSCSIPortGroup} | Select-Object -ExpandProperty IPv4SubnetMask
$PortBindingCompliance = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name) | Where-Object {$_.PortGroup -eq $iSCSIPortGroup} | Select-Object -ExpandProperty CompliantStatus
$MTU = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name) | Where-Object {$_.PortGroup -eq $iSCSIPortGroup} | Select-Object -ExpandProperty MTU
$VmkernelNic = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name) | Where-Object {$_.PortGroup -eq $iSCSIPortGroup} | Select-Object -ExpandProperty Vmknic
$PathStatus = $esxcli.iscsi.networkportal.list($iSCSIHBA.Name) | Where-Object {$_.PortGroup -eq $iSCSIPortGroup} | Select-Object -ExpandProperty PathStatus
$MGMT = $VmkernelNicinfo.ManagementTrafficEnabled
$vMotion = $VmkernelNicinfo.vMotionEnabled
$FT = $VmkernelNicinfo.FaultToleranceLoggingEnabled
$vSAN = $VmkernelNicinfo.VsanTrafficEnabled
} #if ($iSCSIPortGroup -ne $null)
else {
$VMList = $null
$VMs = $null
$IPv4Address = $VmkernelNicinfo.IP
$IPv4SubnetMask = $VmkernelNicinfo.SubnetMask
$PortBindingCompliance = "Not Configured"
$MTU = $VmkernelNicinfo.Mtu
$VmkernelNic = $VmkernelNicinfo.Name
$PathStatus = $null
$MGMT = $VmkernelNicinfo.ManagementTrafficEnabled
$vMotion = $VmkernelNicinfo.vMotionEnabled
$FT = $VmkernelNicinfo.FaultToleranceLoggingEnabled
$vSAN = $VmkernelNicinfo.VsanTrafficEnabled
} #else #if ($iSCSIPortGroup -ne $null)
} #if ($Portgrouptype -eq "VirtualMachine")
$Obj | Add-Member -Name VMCount -MemberType NoteProperty -Value $VMList.count
$Obj | Add-Member -Name VMs -MemberType NoteProperty -Value $VMs
$Obj | Add-Member -Name IPv4Address -MemberType NoteProperty -Value $IPv4Address
$Obj | Add-Member -Name IPv4SubnetMask -MemberType NoteProperty -Value $IPv4SubnetMask
$Obj | Add-Member -Name PortBindingCompliance -MemberType NoteProperty -Value $PortBindingCompliance
$Obj | Add-Member -Name MTU -MemberType NoteProperty -Value $MTU
$Obj | Add-Member -Name VmkernelNic -MemberType NoteProperty -Value $VmkernelNic
$Obj | Add-Member -Name PathStatus -MemberType NoteProperty $PathStatus
$Obj | Add-Member -Name MGMT-Enabled -MemberType NoteProperty $MGMT
$Obj | Add-Member -Name vMotion-Enabled -MemberType NoteProperty $vMotion
$Obj | Add-Member -Name FT-Enabled -MemberType NoteProperty $vMotion
$Obj | Add-Member -Name vSAN-Enabled -MemberType NoteProperty $vSan
$report += $obj
#check under $NicTeamingPolicy more settings
} #foreach ($Group in $PortGroup)
} #foreach ($esxi in $VMHosts)
} #Process
End {
$report #| Export-Csv C:\Temp\NetworkInfo.csv -NoTypeInformation
} #End
This is how I connected to vcenter server and executed ps1 file. and exported results to csv file, if you don't export information to csv you can view results on csv.And exported excel/csv file looks like this
Any suggestions and modifications are welcomed.
54 comments:
These information were very easy to understand. Keep up the good work.
Cloud Migration Services
AWS Cloud Migration Services
Azure Cloud Migration Services
VMware Cloud Migration Services
Cloud Migration tool
Database Migration Services
Cloud Migration Services
Great info. Thanks for spending your valuable time to share this post.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching Centre in Chennai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Classes in Mumbai
IELTS Coaching in Mumbai
IELTS Coaching in Anna Nagar
Spoken English Class in Anna Nagar
Great Article. Thank you for sharing! Really an awesome post for every one.
Project Centers in Chennai
JavaScript Training in Chennai
Final Year Project Domains for IT
JavaScript Training in Chennai
Fantastic article with valuable information found very helpful waiting for next blog thank you.
Data Science Course in Hyderabad 360DigiTMG
Really nice and interesting blog information shared was valuable and enjoyed reading this one. Keep posting. Thanks for sharing.
Data Science Training in Hyderabad
Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
Cyber Security Course in Bangalore
Writing in style and getting good compliments on the article is hard enough, to be honest, but you did it so calmly and with such a great feeling and got the job done. This item is owned with style and I give it a nice compliment. Better!
Cyber Security Training in Bangalore
Hello! I just want to give a big thank you for the great information you have here in this post. I will probably come back to your blog soon for more information!. PMP Certification in Hyderabad
Great article with valuable information found very resourceful and enjoyed reading it waiting for next blog updated thanks for sharing.
typeerror nonetype object is not subscriptable
It's good to visit your blog again, it's been months for me. Well, this article that I have been waiting for so long. I will need this post to complete my college homework, and it has the exact same topic with your article. Thanks, have a good game.
Business Analytics Course in Bangalore
It's like you understand the topic well, but forgot to include your readers. Maybe you should think about it from several angles.
Data Analytics Course in Bangalore
I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!
data science courses
Attend The Data Analyst Course From ExcelR. Practical Data Analyst Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analyst Course.
Data Analyst Course
I have to search sites with relevant information ,This is a
wonderful blog,These type of blog keeps the users interest in
the website, i am impressed. thank you.
Data Science Training in Bangalore
Fantastic blog extremely good well enjoyed with the incredible informative content which surely activates the learners to gain the enough knowledge. Which in turn makes the readers to explore themselves and involve deeply in to the subject. Wish you to dispatch the similar content successively in future as well.
Data Science Course in Raipur
I bookmarked your website because this site contains valuable information. I am very satisfied with the quality and the presentation of the articles. Thank you so much for saving great things. I am very grateful for this site.
Data Science Training in Bangalore
Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such amazing content for all the curious readers who are very keen on being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in the future too.
Digital Marketing Training in Bangalore
I wanted to leave a little comment to support you and wish you the best of luck. We wish you the best of luck in all of your blogging endeavors.
Artificial Intelligence Training in Bangalore
The Extraordinary blog went amazed by the content that they have developed in a very descriptive manner. This type of content surely ensures the participants explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.
Machine Learning Course in Bangalore
Nice Blog, keep it up for more updates about this type of blog
Hii, This is Great Post..!
Best Digital Marketing Agency in Chennai
Best Content Marketing companies in Chennai
Best SEO Services in Chennai
digital marketing company in chennai
website designing company in chennai. .
best digital marketing company in chennai
Excellent effort to make this blog more wonderful and attractive.
business analytics course
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing. data scientist course in delhi
I was basically inspecting through the web filtering for certain data and ran over your blog. I am flabbergasted by the data that you have on this blog. It shows how well you welcome this subject. Bookmarked this page, will return for extra. data science course in jaipur
A good blog always contains new and exciting information, and reading it I feel like this blog really has all of these qualities that make it a blog.
Artificial Intelligence Training in Bangalore
It is late to find this act. At least one should be familiar with the fact that such events exist. I agree with your blog and will come back to inspect it further in the future, so keep your performance going.
Digital Marketing Training in Bangalore
A good blog always contains new and exciting information and as I read it I felt that this blog really has all of these qualities that make a blog.
Data Science Training in Bangalore
I am more curious to take an interest in some of them. I hope you will provide more information on these topics in your next articles.
Machine Learning Course in Bangalore
Very interesting blog. Keep sharing.
Tamil novels pdf free download
Ramanichandran novels PDF
srikala novels PDF
Mallika manivannan novels PDF
muthulakshmi raghavan novels PDF
Infaa Alocious Novels PDF
N Seethalakshmi Novels PDF
Sashi Murali Tamil Novels PDF Download
Become a Data Science Expert with us. we provide Classroom training on Data Science course in Hyderabad for the individuals who believe hand-held training. We teach as per the Indian Standard Time (IST) with In-depth practical Knowledge on each topic in classroom training, 80 – 90 Hrs of Real-time practical training classes. There are different slots available on weekends or weekdays according to your choices.
This is really very nice post you shared, i like the post, thanks for sharing..
data science training
i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
data science training in noida
A good blog always contains new and exciting information and as I read it I felt that this blog really has all of these qualities that make a blog.
Ethical Hacking Training in Bangalore
i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
data analytics course in patna
i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
Data Engineering Course in India
Excellent effort to make this blog more wonderful and attractive.
data scientist course
Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one. Keep posting. An obligation of appreciation is all together for sharing.data science colleges in bangalore
Thank you for posting this information. I just want to let you know that I just visited your site and find it very interesting and informative. I look forward to reading most of your posts.
Data Science Course in Patna
Attend the best data science course training in Hyderabad program by AI Patasala, here you can learn data science concepts with practical knowledge.
Data Science Training and Placements in Hyderabad
I am more curious to take an interest in some of them. I hope you will provide more information on these topics in your next articles.
Data Science in Bangalore
Very informative message! There is so much information here that can help any business start a successful social media campaign!
data science training in london
Very useful message. This is my first time visiting here. I found a lot of interesting things on your blog, especially your discussion. It really is a great article. Keep on going.
Data Analytics Course in Ernakulam
HIGS offers complete research assistance for our clients across the globe. We provide end-to-end PhD research assistance for our clients across all domains with the help of top-notch research experts.
http://higssoftware.com/
This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
data science course in malaysia
I read your excellent post. It's a great job. I enjoyed reading your post for the first time. I want to thank you for this publication. Thank you...
Data Analytics Course in Patna
I am another customer of this site so here I saw various articles and posts posted by this site,I curious more energy for some of them trust you will give more information further.
360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.
I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.
data science course in london
Incredible post I should say and a debt of gratitude is in order for the data. Schooling is certainly a tacky subject. Be that as it may, is still among the main subjects within recent memory. I appreciate your post and anticipate more. You have made some valid statements there. I looked on the web to study the issue and discovered a great many people will oblige your perspectives on this site...
how to make a paper airplane eagle | how to make a boomerang airplane | the eagle paper airplane | best paper airplane design for distance and accuracy
Good blog and absolutely exceptional. You can do a lot better, but I still say it's perfect. Keep doing your best.
Data Science Training in Durgapur
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
data analytics course in varanasi
It is perfect chance to make a couple of game plans for the future and the opportunity has arrived to be sprightly. I've scrutinized this post and if I may I have the option to need to suggest you some interesting things or recommendations. Perhaps you could create next articles insinuating this article. I have to examine more things about it! https://360digitmg.com/course/project-management-professional-pmp
Happy to chat on your blog, I feel like I can't wait to read more reliable posts and think we all want to thank many blog posts to share with us.
Data Science in Bangalore
Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks.
cyber security course malaysia
Very Informative post.
How to make a paper airplane | Origami paper plane
Post a Comment