Someone ask me how to import VM's from a list. Here is a simple script to import VM's based on a list. The script uses a single datastore.
[sourcecode languange=”css”]
#############################################
# Script Name: Importvms.ps1 #
# Author Name: Carlos Vargas #
# Version : 1.0 #
# Contact : cavarpe.wordpress.com #
#############################################
# Requirements
# VMware PowerCLI 4.1
#Clean Screen
Clear
#Import VM information
$VMs = Import-Csv .vminformation.csv
#Loop for array of VM's
foreach ($vm in $VMs )
{
$vminfo = $vm.name + "/" + $vm.name + ".vmx"
# Import VM's to VMware vSphere Datacenter Inventory
New-VM -VMFilePath "[datastore] $vminfo" -VMHost (Get-Cluster ClusterName | Get-VMHost | Get-Random) -Location (Get-Folder "FolderName")
}
# Versions
# 1.0 New Script
# ToDo's
# Add Datastore information to CSV
[/sourcecode]