vSphere Inventory Import Script

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]

Subscribe For Latest Updates

Sign up for best of digital marketing, livestream and technology opinions on what matters to you.

Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: