an you Import from Vcenter

avatar

Just wondering if there is a way to Import all the servers I have in Vcenter?


Thanks

All Comments (4)

avatar

Do you know if they have an export functionality in vcenter?

David Hervieux

avatar

Yes you can do it, Export as csv and look how you can import a valid csv to RDM then are all connections on the RDM

avatar

Could you provide me a sample?

David Hervieux

avatar

If you use powershell, you can do it like this:

#RDM-export.ps1
# exports stations for importing into Remote Desktop Manager

#define vcenter folder to query
$loc = "Systems"

# in multiple IP VMs, only one subnet is the one we want to access thru
# this is a REGEX pattern to filter the IPs
$Pattern = @"
^(([1][0]))(\.([1-2][1,9][1,3]))(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))$
"@ # matches 10.211.*.* and 10.193.*.*
$vmconn = @()


#get-vm
$vmlist = Get-VM -Location $loc |? {$_.ExtensionData.Guest.guestFullName} #| where $_.ExtensionData.Guest.guestFullName -ne $null
#$vmlist
Write-Host . > 'C:\rdm-vm.csv'
$vmconn += "Name, Host, Description"
foreach ($vm in $vmlist){
#Filter the type of VM guest
if ($vm.ExtensionData.Guest.guestFullName.startswith("Microsoft Windows")){
$i = 0
$vmip = $null
$vm.name
do{
# only use the IP that matches the pattern above
if ($vm.guest.IPAddress[$i] -match $Pattern){
$vmip = $vm.guest.IPAddress[$i]
$i++
}
$i++
}while ($i -le 1)

# Get the folder the VM resides in
$folderid = get-vm $vm | Get-View | select parent
$foldern = Get-Folder -id $folderid.parent | get-view | select name
$folder = $foldern.Name
$folder
# add the connection info for the current VM to the array
$vmconn += "$vm, $vmip, $folder"
}
}
$vmconn
# export the array to a CSV in a format you can use in RDM
$vmconn | ConvertFrom-CSV | Export-CSV C:\rdm-vm.csv -NoTypeInformation
edited by jdelgadocr on 8/7/2014