tag:blogger.com,1999:blog-47248324630515127752024-02-07T07:36:38.710+05:30Get VM-Savvy here!!Get-VMSavvy | Where{$_.Blog -eq "vmsavvy.blogspot.in"} | Select Knowledge,Experience,Learning,Sharing:-)Anonymoushttp://www.blogger.com/profile/09105722699792150037noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4724832463051512775.post-49946431119102647912014-11-19T10:21:00.000+05:302014-11-19T10:21:08.863+05:30Report VMFS Datastores and their Member Hosts<div dir="ltr" style="text-align: left;" trbidi="on">
This is my second post and I was recently requested by one of my colleagues to help him with a report which shows Datastores, Capacity, Freespace along with the cluster name and hosts that it is connected to. This can connect to multiple vCenters and push separate reports for each of the vCenter.<br />
<br />
<i>$vcservers = "vc1.company.com", "vc2.company.com"</i><br />
<i>foreach($vcserver in $vcservers){</i><br />
<i>Connect-VIServer $vcserver -Port 443</i><br />
<i>$report = @()</i><br />
<i>$DS = Get-Datastore | Where {$_.Type -eq "VMFS" -and $_.Extensiondata.Summary.MultipleHostAccess} | Sort Name</i><br />
<i>foreach ($store in $DS){</i><br />
<i> $memberhosts = ($store | Get-VMHost | Select -ExpandProperty Name) -join ","</i><br />
<i> $cluster = ($store | Get-VMHost | Sort Name | Select -First 1 | Get-Cluster).Name</i><br />
<i> $list = "" | Select-Object Name, CapacityGB, FreeGB, PercFree, FileSystem, ClusterName, MemberHosts</i><br />
<i> $list.Name = $store.Name</i><br />
<i> $list.CapacityGB = "{0:N2}" -f ($store.capacityMB/1kb)</i><br />
<i> $list.FreeGB = "{0:n2}" -f ($store.FreeSpaceMB/1kb)</i><br />
<i> $list.PercFree = "{0:N2}" -f (100 * $store.FreeSpaceMB/$store.CapacityMB)</i><br />
<i> $list.FileSystem = $store.Type</i><br />
<i> $list.ClusterName = $cluster</i><br />
<i> $list.MemberHosts = $memberhosts</i><br />
<i> $report += $list</i><br />
<i>}</i><br />
<i>$report | Export-Csv "C:\Temp\Output\$vcserver.csv" -NoTypeInformation</i><br />
<i>Disconnect-VIServer $vcserver -Confirm:$false</i><br />
<i>Clear-Variable report</i><br />
<i>}</i><br />
<i><br /></i>
Sample output below --<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDntiu3b_ZNpzM79MUVBMR2UKpW2N_izNA6ysBL_u8x5lpKC-uSrNAyYpV_ZmmPLBXdn4H2RZNndyWzKh9zeyGgiJgmr4AqqhSWHfiUWVC9IMJZzO5CYdRytzwDmSBFD_jttyW8Gwcdqc/s1600/Blogoutput.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDntiu3b_ZNpzM79MUVBMR2UKpW2N_izNA6ysBL_u8x5lpKC-uSrNAyYpV_ZmmPLBXdn4H2RZNndyWzKh9zeyGgiJgmr4AqqhSWHfiUWVC9IMJZzO5CYdRytzwDmSBFD_jttyW8Gwcdqc/s1600/Blogoutput.jpg" height="102" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
There could be much easier ways to do this, but this one just worked out for me.</div>
Anonymoushttp://www.blogger.com/profile/09105722699792150037noreply@blogger.com0tag:blogger.com,1999:blog-4724832463051512775.post-82686885229399321432014-10-22T20:33:00.003+05:302014-10-22T20:50:30.817+05:30PowerCLI - Add PortGroups to Standard vSwitch.<div dir="ltr" style="text-align: left;" trbidi="on">
If your environment uses Standard vSwitches it is more likely that you often end up adding a portgroup on all the hosts in a cluster. This becomes even more tedious task when you have multiple portgroups to add.<br />
<br />
This script helps you to add new portgroups to an existing vSwitch. You can also connect to an ESXi Host directly if you have a standalone host (which is rare in Prod environments though)..<br />
<br />
<i>$vcserver = "vCenterFQDN/IP"</i><br />
<i>$portvc = "443"</i><br />
<i>$myvSwitch ="Your vSwitch (EX: vSwitch1)"</i><br />
<i>Connect-VIServer $vcserver -Port $portvc -Credential (Get-Credential)</i><br />
<i>$hosts = Get-VMHost -Location "Cluster_Name" | Sort Name</i><br />
<div style="text-align: left;">
<i>foreach($host in $hosts){</i></div>
<span class="Apple-tab-span" style="white-space: pre;"><i> </i></span><br />
<i># Enable below line if you want to create a new vSwitch named with $myvSwitch and assign NICs 1,3,4,5 to the vSwitch.</i><br />
<i>#$host | New-VirtualSwitch -Name $myvSwitch -Nic vmnic1, vmnic3, vmnic4, vmnic5</i><br />
<i><br /></i>
<i>#Add new portgroups to the vSwitch named "$myvSwitch". Each portgroup/VLAN needs one line similar to the below..</i><br />
<i>$host | Get-VirtualSwitch -Name $myvSwitch | New-VirtualPortGroup "corp 80" -VLanId 80 -Confirm:$false</i><br />
<i>$host | Get-VirtualSwitch -Name $myvSwitch | New-VirtualPortGroup "corp 90" -VLanId 90 -Confirm:$false</i><br />
<i>$host | Get-VirtualSwitch -Name $myvSwitch | New-VirtualPortGroup "corp 100" -VLanId 100 -Confirm:$false</i><br />
<i>}</i><br />
<i>Disconnect-VIServer $vcserver -confirm:$false</i><br />
<div>
<br /></div>
<div>
***PS: Test it before you run in a Prod Cluster. ***</div>
</div>
Anonymoushttp://www.blogger.com/profile/09105722699792150037noreply@blogger.com0tag:blogger.com,1999:blog-4724832463051512775.post-5790806775877672732014-08-29T23:59:00.005+05:302014-08-29T23:59:57.650+05:30Kick Start!!<div dir="ltr" style="text-align: left;" trbidi="on">
All these years I was thinking to start a blog on the technology that I work on. Better late than never. Now is the time for me to kick start this effort.<br />
<br />
I am Pardha Nallan working as a Vmware Architect with a US based Records Management Company. I'm in the industry for little more than 9 years and working in Vmware Virtualization for the past 5 years. I work on VMware vSphere Stack, vSphere PowerCLI, vCenter Orchestrator, vCloud Director, vCloud Automation Center etc..<br />
<br />
I have a few IT Certifications like VCP 4&5, ITIL v3 Foundation, MCTS etc.. and aiming towards VCAP Certifications as well.<br />
<br />
I can be reached at vmsavvy@gmail.com and my twitter handle is @pardhanallan. My linkedin profile is http://in.linkedin.com/in/pardhanallan/<br />
<br />
Let me start sharing what I know and learn what others know.<br />
<br />
Regards,<br />
Pardha Nallan</div>
Anonymoushttp://www.blogger.com/profile/09105722699792150037noreply@blogger.com0