VMware Appliance Management Interface (VAMI) – Unable to login

When trying to login to your VAMI interface (https://FQDN:5480), an error “Unable to login” is shown:

If the applmgmt service has been stopped, this can be the root cause.

Connect to the console of the virtual center appliance and enable SSH. Login with the root credentials and check which services has been stopped:

service-control --status

If the “applmngt” service is stopped, start it with:

service-control --start applmgmt

If you want to start all services use –all instead of applmgmt

Check your running services and if they are up, connect to the VAMI and it should be working!

VMware get inventory

source: http://www.wooditwork.com/2010/08/16/exporting-all-that-useful-vm-information-with-powercli/

To export a list of usefull information about your environment use the following oneliner to export it to a CSV.

Get-VM | Select Name, PowerState, NumCPU, MemoryMB, ProvisionedSpaceGB, UsedSpaceGB, @{N=”ESX Host”;E={Get-VMHost -VM $_}}, @{N=”Datastore”;E={Get-Datastore -VM $_}}, @{N=”Guest OS”;E={Get-VMGuest -VM $_}} | Export-CSV d:\temp\report.csv

 

 

Enable CBT on VMware

See also http://www.bvanleeuwen.nl/faq/?p=1236

Create vm list

$targets = Get-VM | Select Name, @{N="CBT";E={(Get-View $_).Config.ChangeTrackingEnabled}} | WHERE {$_.CBT -like "False"}

Enable CBT

ForEach ($target in $targets) {
   $vm = $target.Name
   $vmView = Get-vm $vm | get-view
   $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
   $vmConfigSpec.changeTrackingEnabled = $true
   $vmView.reconfigVM($vmConfigSpec)
}

Create/Remove snapshot to enable CBT

ForEach ($target in $targets) {
   $vm = $target.Name
   Get-VM $vm | Get-Snapshot | Remove-Snapshot -confirm:$false
   New-Snapshot -VM (Get-VM $vm ) -Name "CBTSnap"
   Get-VM $vm | Get-Snapshot -Name "CBTSnap" | Remove-Snapshot -confirm:$false
}

 

Configuring disks to use VMware Paravirtual SCSI (PVSCSI) adapters

source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1010398

Details

This article includes supplemental information about configuring and using VMware Paravirtual SCSI (PVSCSI) adapters.

PVSCSI adapters are high-performance storage adapters that can result in greater throughput and lower CPU utilization. PVSCSI adapters are best suited for environments, especially SAN environments, where hardware or applications drive a very high amount of I/O throughput. The VMware PVSCSI adapter driver is also compatible with the Windows Storport storage driver. PVSCSI adapters are not suited for DAS environments.

 

This table shows the support matrix for use of Paravirtual SCSI adapters for data disks and boot disks for the various guest operating systems and ESX versions. Support shown in the table is from the listed ESXi/ESX version and later versions.

Guest operating system Data Disk Boot Disk
Windows Server 2012 R2 (64 bit only) ESXi 5.0 Update 2, ESXi 5.1, ESXi 5.5 ESXi 5.0 Update 2, ESXi 5.1, ESXi 5.5
Windows Server 2012 (64 bit only) ESXi 5.0 Update 1, ESXi 5.1, ESXi 5.5 ESXi 5.0 Update 1, ESXi 5.1, ESXi 5.5
Windows Server 2008 R2 (64 bit only) ESXi/ESX 4.0 Update 1, ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.0 Update 1, ESXi/ESX 4.1, ESXi 5.x
Windows Server 2008 (32 and 64 bit) ESXi/ESX 4.x, ESXi 5.x ESXi/ESX 4.0 Update 1, ESXi/ESX 4.1, ESXi 5.x
Windows Server 2003 (32 and 64 bit) ESXi/ESX 4.x, ESXi 5.x ESXi/ESX 4.x, ESXi 5.x
Windows 8.1 (32 and 64 bit) ESXi 5.0 Update 2, ESXi 5.1, ESXi 5.5 ESXi 5.0 Update 2, ESXi 5.1, ESXi 5.5
Windows 8 (32 and 64 bit) ESXi 5.0 Update 1, ESXi 5.1, ESXi 5.5 ESXi 5.0 Update 1, ESXi 5.1, ESXi 5.5
Windows 7 (32 and 64 bit) ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.1, ESXi 5.x
Windows Vista (32 and 64 bit) ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.1, ESXi 5.x
Windows XP (32 and 64 bit) ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.1, ESXi 5.x
CentOS 5.x (32 and 64 bit) ESXi/ESX 4.0 Update 4, ESXi/ESX 4.1 Update 2, ESXi 5.x Not Supported
CentOS 6.x (32 and 64 bit) * ESXi/ESX 4.0 Update 4, ESXi/ESX 4.1 Update 2, ESXi 5.x ESXi/ESX 4.0 Update 4, ESXi/ESX 4.1 Update 2, ESXi 5.x
CentOS 7.x (64 bit) ESXi 5.5 ESXi 5.5
Red Hat Enterprise Linux (RHEL) 5 (32 and 64 bit) and all update releases ESXi/ESX 4.x, ESXi 5.x Not Supported
RHEL 6 (32 and 64 bit) ESXi/ESX 4.0 Update 2, ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.0 Update 2, ESXi/ESX 4.1, ESXi 5.x
RHEL 7 (64 bit) ESXi 5.5 ESXi 5.5
SUSE Linux Enterprise 11 SP1(32 and 64 bit) and later releases ESXi/ESX 4.0 Update 2, ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.0 Update 2, ESXi/ESX 4.1, ESXi 5.x
Ubuntu 10.04 (32 and 64 bit) and later releases ESXi/ESX 4.0 Update 2, ESXi/ESX 4.1, ESXi 5.x ESXi/ESX 4.0 Update 2, ESXi/ESX 4.1, ESXi 5.x

 

 

* = CentOS 6.5 is not supported on ESXi/ESX 4.0. Support added in ESXi/ESX 4.1 Update 3, ESXi 5.0 Update 2 and above only.

The default type of newly hot-added SCSI adapter depends on the type of primary (boot) SCSI controller. This means that hot-adding a PVSCSI adapter is only supported for those versions that support booting from a PVSCSI adapter.

Paravirtual SCSI adapters also have these limitations:

  • Hot add or hot remove requires a bus rescan from within the guest.
  • Disks with snapshots might not experience performance gains when used on Paravirtual SCSI adapters if memory on the ESX host is over committed.
  • Do not use PVSCSI on a virtual machine running Windows with spanned volumes. Data may become inaccessible to the guest operating system.
  • If you upgrade from RHEL 5 to an unsupported kernel, you might not be able to access data on the virtual machine’s PVSCSI disks. You can run vmware-config-tools.pl with the kernel-version parameter to regain access.

Solution

To configure a new or existing data disk to use a PVSCSI adapter:

  1. Launch a vSphere Client and log in to an ESXi/ESX host or vCenter Server.
  2. Select a virtual machine, or create a new one.
  3. Ensure a guest operating system that supports PVSCSI is installed on the virtual machine.
  4. If it is an existing virtual machine, power it off.
  5. In the vSphere Client, right-click on the virtual machine and click Edit Settings.
  6. Click the Hardware tab.
  7. Click Add.
  8. Select Hard Disk.
  9. Click Next.
  10. Choose any one of the available options.
  11. Click Next.
  12. Specify the options you require. Options vary depending on which type of disk you chose.
  13. Choose a Virtual DeviceNode and specify whether you want to use Independent mode. For data disks, choose a Virtual Device Nodebetween SCSI (1:0)to SCSI (3:15). For a boot disk, choose Virtual Device Node SCSI (0:0), or choose the Virtual Device Node that boots in the order you require.
    Note: To set a disk to use Independent mode there must be no snapshots associated to the virtual disk, if there are existing snapshots commit them before changing the disk type.
  14. Click Next.
  15. Click Finish to finish the process and exit the Add Hardware wizard. A new disk and controller are created.
  16. Select the newly created controller and click Change Type.
  17. Click VMware Paravirtual and click OK.
  18. Click OK to exit the Virtual Machine Properties dialog.
  19. Power on the virtual machine.
  20. Install VMware Tools. VMware Tools includes the PVSCSI driver.
  21. If it is a new virtual disk, scan and format the hard disk within the guest operating system.

To configure an existing Windows boot disk to use a PVSCSI adapter:
This procedure is required as the guest operating system does not have the PVSCSI driver and the guest will BSOD on boot if using the above method. This workaround forces the guest operating system to install the PVSCSI driver.

  1. Power off the virtual machine.
  2. Create a new temporary 1GB disk(SCSI 1:0) and assign a new SCSI controller (default is LSI LOGIC SAS).
  3. Change the new SCSI controller to PVSCSI for the new SCSI controller.
  4. Click Change Type.
  5. Click VMware Paravirtual and click OK.
  6. Click OK to exit the Virtual Machine Properties dialog.
  7. Power on the virtual machine.
  8. Verify the new disk was found and is visible in Disk Management. This confirms the PVSCSI driver is now installed.
  9. Power off the virtual machine.
  10. Delete the temporary 1GB vmdk disk and associated controller (SCSI 1:0).
  11. Change the original SCSI controller(SCSI 0:X) to PVSCSI as detailed in Steps 3 to 5.
  12. Power on the virtual machine.

To deploy and boot a new Windows virtual machine from a disk attached to a PVSCSI adapter, the VMware PVSCSI driver must be installed in the Windows guest. Floppy disk images that contain the driver are available for the versions of ESXi/ESX that support this. The required floppy images are stored on the host and are located at the /vmimages/floppies/ directory. If the floppy images are not visible, see Unable to mount a floppy image in vCenter Server (1036836).

To install PVSCSI drivers:
Note: This procedure assumes that your virtual machine does not have a floppy driver. If the virtual machine already has a floppy drive, skip directly to Step 6.

  1. Right-click the virtual machine and click Edit Settings.
  2. Click Add.
  3. From list, click Floppy Drive and click Next.
  4. Click Next to accept the default option.
  5. Click Finish.
  6. Click New Floppy or Floppy Drive.
  7. Select the Use existing floppy image in datastore option.
  8. Click Browse.
  9. Navigate to the vmimages or floppies folder.
  10. Select the image and click Open. Note: When installing Windows 2012 Server, use the Windows 2008 image pvscsi-Windows2008.flp to install the driver.
  11. Click OK.
  12. Boot the virtual machine to install the PVSCSI drivers.

 

Enabling Change Block Tracking (CBT) on a Virtual Machine (VMware vSphere 5.1)

Source: http://www.lazywinadmin.com/2013/01/enabling-change-block-tracking-cbt-on.html+

 

How to Enable CBT on your VM ? (PowerShell/PowerCli)

You can do the following even if your VM is Powered ON.

# Check and Add the PowerCli Snaping if not already present
if(-not(Get-PSSnapin -Registered -Name "VMware.VimAutomation.Core"){
    Add-PSSnapin -Name VMware.VimAutomation.Core}

# Connect to my Vcenter
Connect-VIServer -Server vcenter.fx.lab

#Here is aRunning the script on TESTSERVER04 to enable CBT
$vmtest = Get-vm TESTSERVER04 | get-view
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.changeTrackingEnabled = $true
$vmtest.reconfigVM($vmConfigSpec)

How to Apply this CBT configuration ?

Once you enable CBT, the VM must go through a stun-unstun cycle (power on, resume after suspend, migrate, or snapshot create/delete/revert) before the reconfiguration takes effect.

How to Check if CBT is enabled on your VM (PowerShell/PowerCli)

# Check if your VM has (Change Block Tracking) enabled or not
(Get-VM -Name TESTSERVER04).ExtensionData.Config.ChangeTrackingEnabled

# Find VMs where CBT (Change Block Tracking) is Enabled
Get-VM| Where-Object{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}

 

Downloading patches with VMware vCenter Update Manager fails to one of the selected sources (2009000)

source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2009000

 

Downloading patches from one of the software sites configured in VMware vCenter Update Manager fails.

The VMware vCenter Update Manager server logs contain entries similar to:

[2011-11-01 15:24:57:425 ‘httpDownload’ 4440 ERROR]  [httpDownload, 732] Error 12175 from WinHttpSendRequest for url https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml

Error 12175 deals with failed certificate validation. This issue can occur if one of the CA certificates used to sign the patch sites certificate is not trusted by the computer running the VMware vCenter Update Manager server software.

Solution 1

Update Manager 5.0 introduces a new setting that verifies the SSL certificates during download. By default, this value is set to 1 or enabled.
To disable this behavior:
  1. Click Start > Run, type regedit, and click OK. The Registry Editor window opens.
  2. Navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Update Manager  key. 
  3. Right-click the value of the SslVerifyDownloadCertificate key and click Modify.
  4. Change the Value data field value to 0.
  5. Click OK.
  6. Click Start > Run, type services.msc , and click OK.
  7. Right-click VMware vSphere Update Manager Service and click Restart.

Solution 2

Trust the certificate for the site that is failing by installing it into the trusted certificate store for the local computer. You could also download and trust the CA certificates that were used in signing the site certificate into the local computer certificate store.
You might also want to update the root certificates on the Microsoft Windows operating system. For more information, go to the Microsoft Download Center.

Installing Dell OpenManage Server Administrator on VMWare ESXi 5.5

Installing Dell OpenManage Server Administrator on VMWare ESXi 5.5

Installing Dell OMSA on a ESXi server allows you to see more detailed information regarding the Dell hardware. It also allows you to perform operations such as specifying hot spares and rebuilding RAID arrays. After you install OMSA on the ESXi server you can install the OMSA web-based GUI on another Windows PC or Server in order to access OMSA.

The steps below will get OMSA up and running on VMWare ESXi 5.5. Be sure to download the version of the OMSA Offline Installation Bundle that corresponds to your version of ESXi.

 

Download the OMSA Offline Bundle from the Dell Website.

Enable SSH on the ESXi Server

  • Open and log-in to VMWare vShpere Client.
  • Select the server node in the tree view on the left.
  • Click the Configuration tab along the top.
  • Click the Properties link to the right of Services.
vSphere Client Security Profile Page
vSphere Client Security Profile Page
  • Select SSH in the list and click Options.
  • Select “Start and stop with host”
  • Under Service Commands click Start.
  • Click OK.
vSphere SSH Options
vSphere SSH Options

Transfer the OMSA Offline Bundle to the Server

Since SSH is enabled the easiest way to transfer the file “OM-SrvAdmin-Dell-Web-7.3.0-588_A00.VIB-ESX55i.zip” to the server is with a SFTP client. I typically use WinSCP on Windows, Transmit on a Mac, or the command line SCP client on Linux systems. I’ll show you how to use WinSCP below:

  • Open WinSCP.
  • Click New to create a new connection.
  • Enter the host name of the ESXi server, user name and password. (User name is root by default).
WinSCP Login Screen
WinSCP Login Screen
  • Click Login.
  • If this is your first time connecting to this host you’ll see a warning screen about the server’s host key. You can click Yes to continue.
  • Once connected you’ll see an explorer type view with your local files on the left and the server’s file system on the right.
  • You want to navigate to the /tmp/ folder.
ESXi /tmp/ Directory
ESXi /tmp/ Directory
  • Double click tmp to enter the directory.
  • In the left pane browse to where you downloaded “OM-SrvAdmin-Dell-Web-7.3.0-588_A00.VIB-ESX55i.zip”
  • Once located, drag the file to the right pane. When the Copy dialog comes up click Copy.
OMSA In tmp Directory
OMSA In tmp Directory

Install the Offline Bundle

Its now time to install the bundle. To do this  you’ll need a SSH client. I use Putty on Windows and the command line SSH client on Mac and Linux. I’ll show you how to use Putty below.

  • Open Putty.
  • Enter the ESXi server host name and click Open.
Putty Configuration
Putty Configuration
  • Again if this is your first time connecting to this host you’ll see a Putty Security Alert dialog box. Click Yes to continue.
  • Enter the user name (root).
  • Enter the password.
  • At the command line type “esxcli software vib install -d /tmp/OM-SrvAdmin-Dell-Web-7.3.0-588_A00.VIB-ESX55i.zip
  • Make sure to match the file name of the file you actually downloaded since version numbers will change frequently. You can use tab-auto-complete to type in the first few letters such as OM- and then press tab to complete the file name.
  • Press enter.
  • Reboot the server to complete the installation. If you don’t have any running hosts you’ll be able to restart without being in maintenance mode. If you do have running hosts you’ll need to shut them down and then put the ESXi server into maintenance mode.

Installing OpenManage Server Administrator Managed Node

  • Download the installer for Dell OpenManage Server Administrator Managed Node (Windows),v7.3 to a Windows PC.
  • Run and install the application.
  • The installer will complain about it not being installed on Dell software but you can proceed with the server installation only.
  • Dell OMSA is web-based, relying on a Java back-end so when you double click the icon on your desktop it will open your default browser.
  • Enter the ESXi host, user name and password. Check the box to Ingore certificate warnings.
OMSA Login
OMSA Login
  • This should allow you to use OpenManage similarly to how you would on a bare-metal install of Windows Server on a Dell system.

How to install Dell Openmanage Server Administratior on ESXi using VMware Update Manager

http://oxfordsbsguy.com/2013/08/09/how-to-install-dell-openmanage-server-administrator-on-esxi-5-1-using-vmware-update-manager/

1.  Download the OpenManage Server Administrator vSphere Installation Bundle (VIB) for ESXi 5.1, v7.3 from Dell’s website. It can be found on the Product Support page in the System Management section. Or you can download it from here.

OpenManage Server Administrator vSphere Installation Bundle (VIB) for ESXi 5.1, the current version is v7.32. Login in to vCenter, click Home, Update Manager and then select the Patch Repository tab.

VMware Update Manager - Patch Repository3. Click Import Patches.

VMware Update Manager - Import Patches4. Browse to the downloaded zip file and click Next. If you get a Security Warning dialogue box pop up, click Ignore.

Security Warning6. Click Finish to confirm the import.

VMware Update Manager - Import Patches7. If you browse the Patch Repository you will now see the OpenManage 7.3 for ESXi 510 patch.

VMware Patch Repository showing Dell OpenManage 7.3 for ESXi 510 patch

8. Click the Baseline and Groups tab. Then click on the left-hand Create option to create a new baseline.

VMware create Baseline

9. Give the baseline a name, Dell Host Extension, and select the Host Extension radio button, and click Next.

VMware New Baseline Name and Description10. Browse to the OpenManage 7.3 for ESXi510 extension, select it and click the Down Arrow to add it, click Next.

VMware New Baseline - Select Extensions

11. Review the selection and click Finish.

VMware New Baseline Complete

12. Click on Home, Hosts and Clusters, select the host you want to Install OpenManage Server Administrator on and select the Update Manager tab, then click Attach.

VMware Update Manager tab13. Select the Dell Host Extension baseline, then click Attach.

VMware - Attach Baseline or Group14. Select Patches and Extensions check box and click Scan.

VMware Confirm Scan15. To Apply the Extension, put the host into Maintenance Mode. Click the Stage button and then click the Remediate button.

To Access Server Administrator on ESXi 5.1 do the following or, just copy and paste the following address into a browser, changing the ESXiservername:

https://ESXiservername:1311/OMSALogin?manageDWS=false

1. From a Windows Server with Dell OpenManage Server Administrator installed, Open the local Server Administrator instance.

2. Click Logout in the top right hand corner of the web interface.

3. Click Log in.

Dell Server Administrator - Log in4. At the bottom of the login dialogue box, click Manage Remote Node.

Dell OpenManage Login

4. Enter the Esxi hostname or IP address, username and password, and check the box to Ignore certificate warnings. Click Submit.

Dell OpenManage - Managed System LoginYou will now be presented with the Dell OpenManage Server Administrator interface for your ESXi server.

Dell OpenManage Server Administrator ESXi interface

Creating a persistent scratch location for ESXi 4.x and 5.x (1033696)

source: http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1033696

 

VMware recommends that ESXi has a persistent scratch location available for storing temporary data including logs, diagnostic information, and system swap. (This is not a requirement, however.) Persistent scratch space may be provisioned on a FAT 16, VMFS, or NFS partition accessible by the ESXi host.

Note: Scratch space is configured automatically during installation or first boot of an ESXi host, and does not usually need to be manually configured. ESXi Installable creates a 4 GB Fat16 partition on the target device during installation if there is sufficient space, and if the device is considered Local.

If persistent scratch space is not available, ESXi stores this temporary data on a ramdisk, which is constrained in space. This might be problematic in low-memory situations, but is not critical to the operation of ESXi. Information stored on a ramdisk does not persist across reboots, so troubleshooting information such as logs and core files could be lost. If a persistent scratch location on the host is not configured properly, you may experience intermittent issues due to lack of space for temporary files and the log files will not be updated.

 

Configuring a persistent scratch location using PowerCLI

To configure persistent scratch space for ESXi using the vSphere PowerCLI interface:

Notes:

  • Before proceeding, ensure that /tmp/scratch exists. If it does not exist, use the command mkdir /tmp/scratch to create it.
  • For more information on vSphere PowerCLI usage, see the vSphere PowerCLI documentation.
  1. Open a command prompt where the PowerCLI is installed.
  2. Connect to the ESXi host using the command:connect-viserver esx_hostname_or_IP
  3. Obtain a list of datastores reachable from this ESXi host using the command:Get-Datastore
  4. Mount a datastore read/write as a PSDrive using the command:New-PSDrive -Name "mounteddatastore" -Root \ -PSProvider VimDatastore -Datastore (Get-Datastore "DatastoreName")
  5. Access the new PSDrive using the command:Set-Location mounteddatastore:
  6. Create a uniquely-named directory for this ESXi host using the command:New-Item "DirectoryName" -ItemType directory

    For example:

    New-Item ".locker-ESXHostname" -ItemType directory

  7. Check the current value of the ScratchConfig.ConfiguredScratchLocation configuration option using the command:Get-VMHostAdvancedConfiguration -Name "ScratchConfig.ConfiguredScratchLocation"

    NoteVMHostAdvancedConfiguration has been deprecated in PowerCLI 5.1 and replaced with AdvancedSetting. For more information, see the vSphere PowerCLI documentation.

  8. Change the ScratchConfig.ConfiguredScratchLocation configuration option, specifying the full path to the directory created in step 6, using the command:Set-VMHostAdvancedConfiguration -Name "ScratchConfig.ConfiguredScratchLocation" -Value "/vmfs/volumes/DatastoreName/DirectoryName"

    For example:

    Set-VMHostAdvancedConfiguration -Name "ScratchConfig.ConfiguredScratchLocation" -Value "/vmfs/volumes/Datastore1/.locker-ESXHostname"

  9. Put the ESXi host into maintenance mode and reboot for the configuration change to take effect.

Copy vswitch information between ESX servers

Below is a script to copy vswitch information from a source ESX server to a destination ESX server.

All vswitch, network and vlan information will be copied.

# Define Variables 
$VCServer = "vc-server" 
$cred = Get-Credential

# Connect server 
$VC = Connect-VIServer -Server "$VCServer" 

#$VISRV = Connect-VIServer (Read-Host "Please enter the name of your VI SERVER")
$BASEHost = Get-VMHost -Name (Read-Host "Please enter the name of your existing server as seen in the VI Client:")
$NEWHost = Get-VMHost -Name (Read-Host "Please enter the name of the server to configure as seen in the VI Client:")

$BASEHost |Get-VirtualSwitch |Foreach {
   If (($NEWHost |Get-VirtualSwitch -Name $_.Name-ErrorAction SilentlyContinue)-eq $null){
       Write-Host "Creating Virtual Switch $($_.Name)"
       $NewSwitch = $NEWHost |New-VirtualSwitch -Name $_.Name-NumPorts $_.NumPorts-Mtu $_.Mtu
       $vSwitch = $_
    }
   $_ |Get-VirtualPortGroup |Foreach {
       If (($NEWHost |Get-VirtualPortGroup -Name $_.Name-ErrorAction SilentlyContinue)-eq $null){
           Write-Host "Creating Portgroup $($_.Name)"
           $NewPortGroup = $NEWHost |Get-VirtualSwitch -Name $vSwitch |New-VirtualPortGroup -Name $_.Name-VLanId $_.VLanID
        }
    }
}