Assistance with the creation of the VM for the automation of laboratory and criticism

Being a novice at scripting powershellCLI from scratch, I managed to put together a script to automate the creation of virtual machines for my ESXi5.1 training laboratory. Some of my orders have been adapted from Luc - D blog. Many thanks for your great blog.

I have a list of virtual computers that have different OS, memory, CPU, disk, NetworkPort, ISOPath, FloppyDrive etc.


Here's the routine I created to go after using the help of VMware PowerCLI and the reference and examples of the VMware community. I would like to help to be able to optimize the code to speed up the processing, because it does not have enough in the process, I tried to use the | Out-Null but it does not seem to turn off the output. I also wanted to know how read a CSV file parameters and phase of each virtual machine created by feeding one after the other time it has been fully configured, as remotely via VMTools looking for the existence of a file or setting on a virtual machine before the next VM is created in order--something like a configuration of vAPP. I tried the CSV file, but only managed to partially run my script is included below:
Finally, when it's time to clean up a script to check if the virtual machine is turned on then turn off and delete the inventory and drive of the virtual computer. (I think I could manage removing relatively easily). Hope my request is not a big ask.

Thanks in advance.


# Connect to vSphere Host with root

$date = get-Date

$ESXhost = Read-Host "enter the host ESX or IP name.

$username = Read-Host "Username".

$password = Read-Host "Password."

SE connect-VIServer-Server $ESXhost - User $username - Password $password


# Create DC

$VMname = "Lab_DC".

New-VM - VMHost $ESXhost - CD - name $VMname - MemoryMB 512 - NumCPU 1 - Version v9 - ID windows7Server64Guest-Floppy - Datastore LUN1-DiskGB 15 - DiskStorageFormat thin - Notes '$VMname AutoDeployed on $date.

Get - VM $VMname | Get-CDDrive. Game-CDDrive - ISOPath "[Host3] VM/Lab_Local\WIN2K8R2SP1_CUST.» "ISO" - StartConnected $true - confirm: $false

$DelayValue = "5000".

$vm = get - VM $VMname | Get-View

$vmConfigSpec = new-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.BootOptions = new-Object VMware.Vim.VirtualMachineBootOptions

$vmConfigSpec.BootOptions.BootDelay = $DelayValue

$vmConfigSpec.flags = new-Object VMware.Vim.VirtualMachineFlagInfo

$vmConfigSpec.flags.enableLogging = $false

$vm. ReconfigVM_Task ($vmConfigSpec)

Get - VM $VMname | Get-NetworkAdapter | Together-NetworkAdapter - NetworkName "Lab_Local" - confirm: $False

FloppyDrive get - VM $VMname | Game-FloppyDrive - FloppyImagePath "Automate/BootFloppies/LAB-DC.flp [build]" - StartConnected $true - confirm: $false

Most of the time the foregoing successfully created the virtual machine, but I have about 20 MV that I need to build/remove and the only way I can do it is by adding the individual game published for each virtual computer orders - it isn't nice to handle, so I tried to add a loop foreach to read the name of the virtual machine and the settings for each computer virtual to a CSV file.

The CSV file is formatted as follows:

VMName MemoryMB NumCpu Version, ID, Datastore, DiskGB, ISOPath, NetworkName, FloppyPath

Lab_DC, 512, 1, v9, windows7Server64Guest, Lun1, 15, [Host3] VM/Lab_Local\WIN2K8R2SP1_CUST. ISO, Lab_Local, Automate/BootFloppies/LAN-DC.flp [build]

Lab_VC, 2048, 1, v9, windows7Server64Guest, Lun2, 20, [Host3] VM/Lab_Local\WIN2K8R2SP1_CUST. ISO, Lab_Local, Automate/BootFloppies/LAN-VC.flp [build]

I tried to add this to "test" as below, but it seems to work partially. It fails to set the path of the ISO, disk path and the Network Port correctly - could not understand how to properly use the BootOptions so I left it.

$VMs = import-CSV - UseCulture b:\automate\servers.csv

New-VM - VMhost Host3 - CD-name $VM. VMName - MemoryMB $VM. MemoryMB - NumCPU $VM. NumCPU-Version $VM. Version - ID $VM. ID-floppy - Datastore $VM. Store data-DiskGB $VM. DiskGB - DiskStorageFormat 'thin' - Notes '$name Auto deployed on $date.

Get - VM $VM | Get-CDDrive. Game-CDDrive - ISOPath $VM. ISOPath - StartConnected $true - confirm: $false

Get - VM $VM | Get-NetworkAdapter | Together-NetworkAdapter NetworkName - $VM.NetworkName - confirm: $False

FloppyDrive get - VM | Game-FloppyDrive - FloppyImagePath $VM. FloppyPath - StartConnected $true - confirm: $false

This is the result I get from the routine above.

NameUse of the port
--------  ----
Host3root of 443

WARNING: The 'Description' of type VirtualMachine property is deprecated. Use the property "Note".

WARNING: The 'Hard drives' property type VirtualMachine is discouraged. The "Get-hard drive" cmdlet instead.

WARNING: The 'NetworkAdapters"type VirtualMachine property is deprecated. The cmdlet "Get-NetworkAdapter" instead.

WARNING: The 'UsbDevices' of type VritualMachine property is obsolete. Use the "Get-UsbDevice" cmdlet instead.

WARNING: The 'CDDrives' of type VitrualMachine property is obsolete. Use the "Get-CDDrive" cmdlet instead.

WARNING: The 'FloppyDrives"type VirtualMachine property is deprecated. Use the "Get-FloppyDrive" cmdlet instead.

WARNING: The 'Host' of type VirtualMachine property is deprecated. Use the property "$vmhost".

WARNING: The "HostId" type VirtualMachine property is deprecated. Use the property "VMHostId".

Get-FloppyDrive: it lacks an argument for the parameter "VM". Specify a parameter of type ' VMware.VimAutomation.ViCore.Type

s.V1. [Inventory.VirtualMachine] ' and try again.

To b:\Automate\Various Scripts\CreateVM.ps1:48 tank: 20

+ Get-FloppyDrive - VM < < < < | Game-FloppyDrive - FloppyImagePath $VM. FloppyPath - StartConnected $true - confirm: $false

+ CategoryInfo: InvalidArgument: (:)) [Get-FloppyDrive], ParameterBindingException)
+ FullyQualifiedErrorId: MissingArgument, VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetFloppyDriv

e

Ah, my mistake, I don't check your code.

Inside the loop, the script must use the variable $_ instead of the variable $VM to the New - VM.

The variable $_ will have extracted the CSV file line.

I've updated the code above. Give him another chance.

Tags: VMware

Similar Questions

  • After hosting my site created with adobe muse on a ftp server, can I change my site on muse adobe later and update it on this same server ftp with the same domain name and do not have to pay for hosting again?

    After hosting my site created with adobe muse on a ftp server, can I change my site on muse adobe later and update it on this same server ftp with the same domain name and do not have to pay for hosting again?

    Yes, no extra accommodation payment is required. After editing your site and savings, click download file to the host of VTT... The info should auto fill with the same information that you used to download the site the first time. You can choose to download only files "changed" or "all files". Click OK and the old files will be overwritten.

  • What is the situation with the mac pro users and map of cuda for ray-tracing work?

    What is the situation with the mac pro users and map of cuda for ray-tracing work? If it is not necessary or should I try to install a?

    CUDA acceleration is no longer under development, and I've only played with traced to the RADIUS on a few test projects. If I need 3D dimensions objects I used C4D Lite, which is now included in EI

  • I have a problem with the Narrator, repeating words and phrases.

    original title: NARRATOR in WIN7 SUPPORT

    I use windows7.  The annoying Narrator sometimes voices repeat words and phrases.  I also need help, change of voice and using Narrator to read aloud my text book I downloaded.  It is in PDF format.

    Original title: Narrator sometimes repeat words and phrases

    Hello

    Thanks for posting your query in the Microsoft Community.

    You have a problem with the Narrator, repeat words and phrases. It can be difficult when something that is important to you does not work as expected. It's pretty simple and we're here to help you solve the problem. We work as a team and get this sorted out.

    Please answer these questions-

    (1) exactly where you run the Narrator?

    (2) the Narrator extends from a particular document?

    (3) have you made changes on the computer before the show?

    I would like more information about the issue.

    Method-

    I wish that return you the items for assistance-

    Narrator doesn't read what I expect him

    http://Windows.Microsoft.com/en-us/Windows7/Narrator-doesn

    Hear text read aloud with Narrator

    http://Windows.Microsoft.com/en-us/Windows7/hear-text-read-aloud-with-Narrator

    Let us know if you need assistance regarding the issue. We will be happy to help you. We at Microsoft, strive for excellence and provide our customers with the best support.

    Thank you.

  • Don t work under El Capitan and I don't get an update/upgrade? I've used until yesterday an old MacBook pro and Lion, everything was perfect with an opening. Now, with the new element (iMac) and El Capitan, I have problems.

    Don t work under El Capitan and I don't get an update/upgrade? I've used until yesterday an old MacBook pro and Lion, everything was perfect with an opening. Now, with the new element (iMac) and El Capitan, I have problems.

    It is not possible to update the version of Aperture is 3.4.5

    What can I do?

    You can only update if you have a version of the AppStore of Aperture - if your version of Aperture appears in the history of your purchases on the App Store. Update and then reinstalling.   See this tip of the user for more details:

    Update to Aperture 3.6 after the publication of Photos

  • text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password.

    Text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password.  This has happened recently.  My two girls have used their respective ipods and texting, without their messages of duplication for each of the other ipods for more than a year.  Somehow recently, both addresses seem to be synced with them or something, so that both see each and other messages.  I've recently updated two ipods, iTunes on my computer--not the cloud and added music for two ipods, but has not changed anything by email email settings or message I know.  Help, please!

    Welcome to the Apple community.

    I can't fully follow how you have everything set up, but a glance at the settings > messages > send & receive

  • HP7520: How to scan 2 pages with the automatic document feeder and save to a file?

    How can I scan 2 pages with the automatic document feeder and save to a file?  (Right now, it happens that 2 separate files)

    I have a HP7520, & again, I wish scan 2 pages into a single jpeg file.

    Thank you

    Well, in general JPEG format does not support several concept as a document page. Thus, each image in the JPEG file is saved in a single file. If you are considering of reduction of 2 images in 1 paper size (example: A4), you may need some image editor to do

    If you are looking for a mulit-page image format, TIFF can be a format suitable to use.

    https://en.Wikipedia.org/wiki/TIFF

  • How to stop a Web site generating spams are sent to me - it is all associated with the use of viagra and I had 10 different emails today

    How to stop a Web site generating spams are sent to me - it is all associated with the use of viagra and I had 10 different emails today

    Thank you

    You need to ask the experts of Hotmail one.
     
     
    Help for Windows Live Hotmail can be found in this forum.
    http://answers.Microsoft.com/en-us/windowslive/Forum/Hotmail?tab=all 

    Help for Outlook.com is located in this forum
    http://answers.Microsoft.com/en-us/windowslive/Forum/mail?tab=all
     
  • My laptop when turned on only comes up with the name of dell, and stops. Setup and boot menu = f2 = F1

    laptop does not start at the top. After trying menu start, it indicates there is no boot device. I would like to start fees and re install windows xp but I don't have a cd or a disc if I have the product key. Can someone help me clean up my computer and re install windows without the cd, which I hope it will fix the problem

    brick2,
    Thank you for taking the time to post.  You're saying that it sounds as if your hard drive is not detected.  You will need to contact the manufacturer of your PC to help with the possible hardware failure and to get copies of the system restore disk.  There is not a way to install windows without a CD or a recovery partition on your hard drive (which it appears right now that your laptop does not see). Mike - Engineer Support Microsoft Answers
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • KB2518870 and KB2539636 always fail with the message Code 643 and has Code 66

    Security for Microsoft .NET Framework 4 updates on... Windows Vista... KB2518870 and KB2539636 always fail with the message Code 643 and Code 66 has.  I can't find these codes or the reasons for these failures.  This happened for well over a month now.  They are reported as of the important updates, but won't install but no problem with the other updates.  Should I be worried?  Is there a solution to this problem?

    Thank you, but it doesn't work anymore. CD don't has not given me the possibility to upgrade the existing installation, so I had to reinstall the system...
    Kind regards
    Ricardo
  • Service Pack does not have changes to restore it then shuts off and restarts with the same message over and over again.

    Help!  I have an apple mac with windows alongside mac system.  I the have not used for a while and when I logged in the windows system advised me to update to IE 9.  To do this, I had to install Service Pack 2 I did.  He then restarted but cannot install and came up with the following: Service Pack does not have changes to restore it then shuts off and restarts with the same message over and over again.  I don't know what to do to reopen and to reinstall the Service Pack.

    Hello

    This article explains how to troubleshoot problems when you install a service pack for Windows Vista or Windows Server 2008.

    http://support.Microsoft.com/kb/947366

    Use this forum link for all questions related to Windows Vista SP1, Windows Vista SP2 and Windows Server 2008 SP2 below.

    http://social.technet.Microsoft.com/forums/en/itprovistasp/threads

    or repost in the Windows Update forum link below

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-windows_update?page=1&tab=all

  • Videos with the extension Bup, IFO and VOB do not play

    File extensions

    My videos with the extension Bup, IFO and VOB does not play. Free file I can download for them to work?

    VLC media player. http://www.videolan.org/VLC/ teengeek.freehostingcloud.com

  • 'Open the drawer out press ok' message with the tray open output and pressed OK.

    'Open the drawer out press ok' message with the tray open output and pressed OK. Seems that the device does not believe that the drawer is open. This has happened directly after deletion of a paper jam.

    Sometimes a small part being out of alignment can make a sensor turn off inside the printer, so make sure you put everything back together right first.  Although you to act this way, looks at the printer closely for any broken pieces.  If you do not see what has obviously broken, try to do a hard reset.  Instructions that are below.  If the hard reset does not clear the error, the output bin sensor may be broken.  If this is the case, you will need to get a new printer, as the sensor is not repairable.

    To do a hard reset:
    1. make sure that the printer is turned on.
    2. pull on the power cord from the printer.
    3. pull out the power cord from the wall.
    4. wait for 30 seconds.
    5. plug in the printer and turn it on.

  • How can I select the files in a folder with the help of a list with the files you want and after that rename only the files using another list with desired new names?

    How can I select the files in a folder with the help of a list with the files you want and after that rename only the files using another list with desired new names?

    I have only:
    D: / images (where are necessary + not need files)
    -a list with only the necessary files
    -a list with new names for the files needed
    Thank you.

    Hi Pustiu,

    Thanks for posting in the Microsoft Community.

    You want to know how to select the files in a folder using a list with the files you want and after that rename only the files using another list with desired new names.

    I would have you post your query in the TechNet forums because it caters to an audience of it professionals.

    Your query will be better addressed there.

    Check out the link-

    http://social.technet.Microsoft.com/forums/en-us/w7itprogeneral/threads

    We know if you need help. We will be happy to help you. We, at tender Microsoft to excellence.

    Thank you.

  • With the help of text and buttons movieclips as buttons to point to the same layered framework?

    I'll have a terrible time with the 3.0 AS and animating CC 2015.2 in this project.  I was given a suggestion, but now I'm so confused output errors that I hope to get answers from you advanced people.

    The project is similar to this:

    Identify the Structure of the trees

    Framework 1 - nothing selected, visible instructions

    Frame 2 - Select sheets by clicking on the image (tree top or bottom) or text, leaves description becomes visible

    Frame 3 - branches select by clicking on the image (tree top or bottom) or text, description branches becomes visible

    Frame 4 - trunk select by clicking on the image (tree top or bottom) or text, description of trunk becomes visible


    Suggestion is:

    Do the video clip of each region of image tree and drop it on the layer smaller on top with alpha 0%

    Create a badge of the clip, and then tap on timeline with each framework has put in evidence and description

    Make the text button, then tap chronology framework with each has put in evidence and description

    Trunk frame – more small area place top layer

    Branches Frame - smaller than the leaves but superior to the place of the trunk between the two

    Framework of leaves - most square of the area on the layer under the Branches

    Can anyone offer any suggestions?  I used to program 5.5 Flash with Actionscript 2.0, but difficulties with Animate and Actionscript 3.0.  I don't know if I have to use swaps or specific images, but when viewing, he travels all frames without stopping even if each image as the AS command stop ();

    Thanks in advance!


    Rick

    Tree-Example.png

    Yes, if your buttons or movieclips, overlap one on top Gets the default click event. So, if you decide to create separate movieClips or separate buttons, be sure to give everyone an exclusive space.

    One approach I've used in the past for such things is to open the work, the tree in Photoshop then "cut" art into segments and put each segment in a different layer in Photoshop. Then you can import that art directly in to animate and each layer will import under a separate post. Then you can combine them into a movieClip to a work of art on the stage. From there, you can select each segment and each a movieClip or button you want.

Maybe you are looking for