Quantcast
Channel: VMware Communities : Blog List - All Communities
Viewing all articles
Browse latest Browse all 3135

PowerCLi Script to Automate to configure vSwitch, add Uplink and bulk virtual port groups

$
0
0

I have created this script to automate to configure vSwitch, Uplink and bulk virtual port groups in cluster. when needs to create 1000 of port groups just append the script under # This configures vSwitch0 and the VPG .

 

The intention  of this script is created for reduced the manual work.

How to run this as follow below procedure:

  • Install PowerCLi 5.5 /6.x on jumpbox or vCenter server
  • Open the VMware power cli
  • Go to the path where you kept the script
  • Run the script.\AddStandardSwitch.PS1
  • It will prompt to give the credential to connect vCenter server.
  • Now you can see the progress in PowerCli

 

==============================================================================================================================

    <#

.SYNOPSIS

        Host Configuration for a Cluster

    .DESCRIPTION

        This script sets Configuration of vSwitch0 on ESXi  servers, Creates vSwitch0 Data networking for migration

 

    .NOTES

        Author: Nawal Singh

    .PARAMETER $VMCluster

        ESX(i) Host Configuration

          

.EXAMPLE

#********Reminder!!!   Open up a fresh PS window and then run this script.

    #>

#Connection to vCenter

 

 

$mycred = Get-Credential

Connect-VIServer "VCSA.local.com" -Credential $mycred

 

Write-Progress -Activity "Configuring Hosts" -Status "Working" ;

 

 

# Change this setting for the Cluster that will be configured

$VMCluster = "CL_MGMT01"

 

# This configures vSwitch0 and the VPG .

Get-Cluster $VMCluster | Get-VMHost  | New-VirtualSwitch -Name VSwitch0 -Nic vmnic2

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_100" -vLanid 100

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_200" -vLanid 200

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_201" -vLanid 201

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_MGMT_2010" -vLanid 2010

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_vMotion_1010" -vLanid 1010

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_FT_2023" -vLanid 2023

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_Data_121" -vLanid 121

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_OOB_Mgmt_105" -vLanid 105

Get-Cluster $VMCluster | Get-VMHost  | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name "PG_VMwareTEST_180" -vLanid 180

 

Disconnect-VIServer -Server *  -Force -Confirm:$false

===============================================================================================================================

Note: This is tested in test, dev and prod it worked perfectly.

 

Please mark helpful or correct


Viewing all articles
Browse latest Browse all 3135

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>