Problems making VM to host exchanges - need help please!

Hi all.  I'm having a problem with I script I have and could greatly grateful for the help.

Little bit of background, I have written a script our team uses to generate shells VM.  The script prompts for a name, the type of operating system, cpu, memory, disk.  Then, it connects to vCenter and based on the credentials, this what data center to build.  Once selected, it then queries the datacenter for all available clusters.  The user selects the cluster and the script queries the hosts connected in the cluster, and then randomly selects one.  From there, he questions all exchanges of VM and presents a choice for the user to select.  Finally given what precedes, then goes and built the hull VM and it powers on.

vCenter 5.1 update 1 Patch 2

ESXi 5.1 update 1 - Build 1157734

PowerCLI 5.1 Release 2 / PowerShell Version 2.0

So here's my problem.  I am in standard vswitches transition for vDS connections and when I run the following line to get the available trade, it error.

$PortGroups = $VMHost | Get-VirtualPortGroup | Where {$_.} Name.ToUpper (). StartsWith ("VLAN")} | Select name - ExpandProperty | Sorting

Error:

ATTENTION: The output of the command product distributed virtual portgroup

objects. This behavior is deprecated, and may change in the future. To retrieve

distributed Exchange, use cmdlet Get-VDPortgroup of the VDS component. TO

retrieve the standard exchanges, use - Standard.

And then the line that actually running to build virtual machine is:

Try {Write-Host "Creation of VM... » ; $VM = new-VM-name $objVMName.text - VMHost $VMHost '

-Store data $DataStore"

-Card (Get-data center-name $VDataCenter |) Get-Folder-name of the Build)"

-DiskGB $objSysDisk.Text - MemoryGB $objMemory.Text NumCpu - $objCPU.Text - CD '

DiskStorageFormat - thin '

$objPortGroup.Text - NetworkName '

-ID $VMGuestID

}

Any help?  I need to get vm exchanges that begin with "VLAN" regardless of vDS or vSwitch in order to feed the parameters Create-VM.

Thanks for any help!

So thanks for the tip about hiding the warning message.  As the parameter seems to be depricated, I would like to change the code of a most appropriate syntax before she actually only l '.

That said, I have found highest in the newspaper, the real error message preventing the script completed successfully by trying to create the virtual machine.  This time, it was RED everywhere...:

"Message: an element with the same key has already been added."

Once I found that the googs told me this post: first New - VM: an element with the same key has already been added.

So I upgraded PowerCLI 5.5 Release 2, and of course, the problem disappeared!

So now, with your advice on warning and googs, I solved the problem AND can hide these warnings until I change the code to use the appropriate syntax.

Tags: VMware

Similar Questions

Maybe you are looking for

  • Highlight words problem

    How to highlight words or phrase selected in an article? Then the method will copy / paste the word? Mine is MacBook Air OS X... Thank you!!

  • NB100-12N - 120 GB shows only 56 + 51 GB

    Hello When I check the properties of my hard drive I cannot summarize the specified 120 GB capacity (do not used but available).I get only about 56 + 51 GB split on drive C:\ and D:\. There is participation of the hard disk drive that are initially h

  • High temperature CPU on Satellite A215

    Hello My Satellite A215 is 3 months old. I use coolfan 4.33. and my temperature is 89 degrees now... This is not normal. How is that possible? What should I do?

  • WhatsApp is not compatible with iOS 6.1.6

    Hello Today I bought an iPod Touch 4th generation (iOS 6.1.6) a friend. I'll install some applications of my "Purchased" in my iTunes account section. When I get Whatsapp and move a little box pops up saying: it is not supported with this iPhone. I g

  • Updating BIOS for Satellite 1110-Z14

    Does anyone know what the BIOS update is right for a Satellite 1110-Z14? It doesn't seem to be a specific list on the drop-down list for this machine. I was wondering if I need to use the Satellite 1100.