Multiple VCenter servers, loop "foreach"?
I need help with the syntax to change some of my existing scripts to connect to multiple VCenters servers that we have now in my environment. Something along the lines of:
$VCenters = VIServer1, VIServer2, etc..
Foreach ($VIserver to $VCenters)
{
SE connect-VIServer $VIserver
SCRIPT MAPS EXISTING HERE
}
Can any input on how I achieve this?
Thank you
Hi SNEdwards,
I do it this way:
$vCenters = VIServer1, VIServer2, etc. ForEach ($vCenter in $vCenters) { connect-VIServer $vCenter -User $VcUser -Password $VcUserPassd ... code to run against each vCenter... disconnect-VIserver -confirm:$false }
It will be useful.
Concerning
Franck
Tags: VMware
Similar Questions
-
Work with multiple vCenter servers in PowerCLI
VI the value of multiple server mode:
Game-PowerCLIConfiguration - multiple DefaultVIServerMode - confirm: $false
Connect to two servers vCenter:
SE connect-VIServer-Server vc1, vc2-userid of the user
Find the cluster and do not specify a VC:
Get-Data Center-Cluster clusterA
Cluster data center is displayed correctly:
name of the data center in VC1
name of the data center by VC2
Try to specify what VC of query:
Get-Data Center-Cluster cluster - server VC2
the names of three data centers are returned which makes no sense (only one contains the cluster)
Trying to figure out how better to work with the simultaneous connections of VC in a script and dictate what VC I want to execute a command against rather than disconnect and reconnect etc.
I think there could be a problem with the cmdlet.
You are using PowerCLI 5.5 R2 I guess?
When you try like this
Get-Data Center-Cluster (Cluster-Get-name ClusterA-Server VC1)
is it returns 1 datacenter or 2?
-
Hello
How are they managing authentication on several servers of vCneter in a script without storing the passwords in the script?
The script is run every hour.
Here's the script:
SE connect-VIServer NAN - vcenter - 02.utility .net - User script-user-01
SE connect-VIServer HKG - vcenter - 01.utility .net - user administrator
SE connect-VIServer ORY - vcenter - 09.utility .net-user special-script-user-01
SE connect-VIServer CNF - vcenter - 06.utility .net - user administrator# Download info, sort, email me-VMs.csv
Get - vm | Select name, VMHost, VApp, Powerstate, @{N = 'IP address'; E={$_. {{Guest.IPAddress [0]}}, @{N = 'DnsName'; E={$_. ExtensionData.Guest.Hostname}} | Tri - VMHost property, name. Export-Csv-path ALL - VMs.csv - NoTypeInformation
#Thank you!
Potentially, you can store your password as a string that is encrypted in a text file as I described here Powershell: securing the credentials using the PSCredential class | Deans blog
This will allow you to recover the encrypted string and convert it into a secure string supplied and this move to the PSCredential class for authentication.
-
Strategy for the SSO with multiple vCenter servers.
We are upgrading vSphere/SRM 5.0U1 for vSphere/SRM 5.5U1 with multiple vCenters in our environment. After reading 2058239 KB:
VMware KB: installing vCenter Single Sign-On 5.5 on a Microsoft Windows platform
We install SSO on a separate Windows Server and choose vCenter Single Sign-On for your first server vCenter Server for this first instance. Now my question is for the following facilities as the vCenter for MRS or vCenters which manages areas replacement fault which option, existing site or new, do we choose? Thank you
You have therefore three sites.
The first time, you will choose vCenter Single Sign-On for your first server vCenter Server.
For the second one on the same site, you choose existing vCenter Single Sign-On for an additional vCenter Server in a site.
Now, when you come to an another site vCenter and third, you will need to decide if you have a site that is your main or you want to still have a site on the second.
If you decide to join at the elementary level, that you will yet choose existing vCenter Single Sign-On for an additional vCenter Server in a site.
If you choose to have another site, you choose vCentre of Single Sign-On for an additional vCenter Server with a new site.
The end of it, you will have to make the decision to design. I can only tell you what they mean. Make sure you have adequate connectivity between sites.
-
Is it possible to use a server for multiple vCenter servers UNIFIED messaging?
In order to keep administration to all least, we would like to use a UNIFIED Messaging server for many devices of vCenter Server?
Is it possible and taken in charge?
You must install and register instances of update with each vCenter Server system manager. You can use an instance of Manager update only with vCenter Server system with which he is registered.
-
standard vcops - can be attached to multiple vcenter servers?
I think that the topic States the question entirely, but says otherwise:
If there are two sites, each with its own vcenter, an instance of vCops can connect at once? Or we have by definition would have to have 2 vCops installations/licenses in this situation?
No addition of a second vCenter does not replace the first. Not sure why it happened with mine. the second time, it worked fine. So I think I did something wrong.
So the the bottom line is you can go ahead and do it. It should work.
If you found my answer helpful, review the allocation of points by choosing the correct and useful answers
-
With multiple vcenter inventory
Hi guys,.
Try to get connected with multiple vcenter inventory,
Have problems with the release of some VM are attributed to wrong Vcenter and running OS is not always correct.
Can anyone help?
Here's the script:
$VmInfo = Foreach ($vcenter in $global: DefaultVIServers) {}
ForEach ($Datacenter in (Get-Data Center |)) Sort - Object - property name)) {}
ForEach ($Cluster in ($Datacenter |)) Get-Cluster | Sort - Object - property name)) {}
ForEach ($VM in ($Cluster |)) Get - VM | Sort - Object - property name)) {}
ForEach ($HardDisk to ($VM |)) Get-hard drive | Sort - Object - property name)) {}
"" | Select-Object - property @{N = "VM"; E = {$VM. Name}},
@{N = 'Vcenter'; E = {$vcenter. Name}},
@{N = "OS"; E = {$vm. Guest.OsFullName}},
@{N = 'Center'; {E = {$Datacenter.Name}}.
@{N = 'Cluster'; E = {$cluster. Name}},
@{N = 'Host'; E = {$vm. VMHost.Name}},
@{N = "HostVersion"; E = {$vm. VMHost.version}}
}
}
}
}
}
$VmInfo | Export-Csv - NoTypeInformation - UseCulture-Path "D:\report.csv".
Try like this.
-What is produced fewer lines?
$VmInfo = Foreach ($vcenter in $global: DefaultVIServers) {}
ForEach ($Datacenter in (Get-Data Center-Server $vcenter |)) Sort - Object - property name)) {}
ForEach ($Cluster in ($Datacenter |)) Get-Cluster-Server $vcenter | Sort - Object - property name)) {}
ForEach ($VM in ($Cluster |)) Get-VM-Server $vcenter | Sort - Object - property name)) {}
ForEach ($HardDisk to ($VM |)) Get-disk hard-Server $vcenter | Sort - Object - property name)) {}
"" | Select-Object - property @{N = "VM"; E = {$VM. Name}},
@{N = 'Vcenter'; E = {$vcenter. Name}},
@{N = "OS"; E = {$vm. Guest.OsFullName}},
@{N = 'Center'; {E = {$Datacenter.Name}}.
@{N = 'Cluster'; E = {$cluster. Name}},
@{N = 'Host'; E = {$vm. VMHost.Name}},
@{N = "HostVersion"; E = {$vm. VMHost.version}}
}
}
}
}
}
$VmInfo | Export-Csv - NoTypeInformation - UseCulture-Path "D:\report.csv".
-
Migration between vCenter servers, publishes the setting destination folder
I'm having a problem with a migration script, I wrote to migrate virtual machines between 2 VCs. The first part of the script works as expected (checking tools, right-size and removes the VM of the inventory on the VC source). The second fails.on of Part VC of destination when the folder setting:
#The CSV should be in the following format #VMNAME,$MEM,$CPU,$VMHOST,$VMXFILE,$CLUSTER,$VMFOLDER,$RESPOOL,$VMNETWORK #Even if there's not going to be a change, the #cells cannot be blank use "" for blank #Import the CSV $vmlist = Import-CSV d:\scripts\naotest-UCSmigration.csv #Prompts user for the source and destination vCenter servers $SourceVC = Read-Host -Prompt 'What is the source vCenter?' $DestVC= Read-Host -Prompt 'What is the destination vCenter?' #connects to the source vCenter for right-sizing connect-viserver $SourceVC #check tools status first write-host "" write-host "Checking VMware Tools Status before proceeding." -foreground green write-host "" foreach ($item in $vmlist) { $vmname=$item.vmname $ToolsStatus = (Get-VM $vmname).extensiondata.Guest.ToolsStatus -eq "toolsNotRunning" IF ($ToolsStatus -eq $true){ write-host "" write-host "Tools is not installed or running on $vmname. Remediate on guest and restart the script" -foreground Yellow write-host "Script will exit" -foreground yellow write-host "" Exit} Else { write-host "" write-host "Tools running, script will continue" -foreground green write-host ""} } #Power down all the VMs in the list write-host "" write-host "Powering down all VMs in the list. Script will sleep for 2 minutes before continuing" -foreground green write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname Shutdown-VMGuest -VM $vmname -Confirm:$false } #sleep for 2 minutes before continuing #may need to adjust depending upon time for #servers to shut down Start-sleep -s 120 #stop VMs that haven't shut down write-host "" write-host "Stopping VMs that have hung on power-down" -foreground green write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname Stop-VM -VM $vmname -RunAsync -Confirm:$false } #Right-size CPU and memory write-host "" write-host "Right-sizing CPU and Memory" -foreground green write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname $cpu = $item.cpu $mem = $item.mem Set-VM -VM $vmname -NumCpu $cpu -MemoryGB $mem -RunAsync -Confirm:$false} #start the VMs after the vCPU/Memorychange write-host "" write-host "Restarting the VMs to enact the vCPU/Memory change" -foreground green write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname Start-VM -VM $vmname -RunAsync } #Wait 5 minutes for the VMs to completely Power Up write-host "" Write-host "Sleeping for 5 minutes to wait for all VMs to power up" -foreground green write-host "" Start-sleep -s 300 #Power down the VMs in preparation for migration #NOTE: It's necessary to power them up after the right-sizing write-host "Power down and sleep for 2 minutes" foreach ($item in $vmlist) { $vmname = $item.vmname Shutdown-VMGuest -VM $vmname -Confirm:$false } #Wait 2 minutes for the VMs to completely Power down Start-sleep -s 120 #stop VMs that haven't shut down write-host "" write-host "Stop VMs that haven't shut down normally." -foreground green write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname Stop-VM -VM $vmname -RunAsync -Confirm:$false } #disconnect CD-ROM write-host "" write-host "Disconnect any connected CD-ROM drives." write-host "" get-vm $vmname|Get-CDDrive | Set-CDDrive -nomedia -Confirm:$false #remove VMs in list from inventory on the source vCenter write-host "" write-host "Remove VMs from inventory on the source vCenter." write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname Remove-VM -VM $vmname -Confirm:$false } #disconnect from the source vCenter disconnect-viserver -Confirm:$false #Connect to the destination vCenter server connect-viserver $DestVC #Add VMs to the new vCenter server write-host "" Write-host "Add VMs to the Destination vCenter" write-host "" foreach ($item in $vmlist) { $VMXFILE = $item.VMXFILE $CLUSTER = $item.CLUSTER $VMHOST = Get-VMHost -location $Cluster | Sort $_.CPuUsageMhz -Descending | Select -First 1 $VMFOLDER = $item.VMFOLDER $RESPOOL = $item.RESPOOL $VMNETWORK = $item.VMNETWORK New-VM -VMFilePath "`"$VMXFILE`"" -VMHost $VMHOST -Location $VMFOLDER -ResourcePool $RESPOOL} #change the network for the new vCenter foreach ($item in $vmlist) { $vmname = $item.vmname get-vm $vmname | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $vmnetwork -confirm:$false } #Power up the VMs on the new vCenter server write-host "" write-host "Powering up VMs on the destination vCenter." -foreground green write-host "" foreach ($item in $vmlist) { $vmname = $item.vmname Start-VM -VM $vmname -RunAsync }
The CSV looks like this:
vmname, cpu, mem, vmxfile, cluster, vmfolder, wrap, vmnetwork
ATEST-VM002, 1, 4, ATEST-VM002/ATEST-VM002.vmdk,DEV-STND1,DEV\Dev\Infrastructure,DEV-root,VLAN-123 [DEV-DATASTORE]
The error is:
New - VM: 2015/12/16 14:46:49 New - VM can not find the folder with
the name "DEV\Dev\Infrastructure".
D:\scripts\vm-uscmigration.ps1:144 char: 5
+ New-VM - VMFilePath "'" $VMXFILE'"'-VMHost $VMHOST - location $VMFOLDER
-Resources...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo: ObjectNotFound: (SAT1-DEV\Dev-NAOTEST\Infrastruc
ture:String) [New - VM], VimException
+ FullyQualifiedErrorId: Core_ObnSelector_SelectObjectByNameCore_ObjectNo
tFound, VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
I pulled information from RVTOOLS path (as well as most other relevant information). Is the incorrect path information, or is it a problem in my script? Any help would be appreciated.
P.S. I know not that defining the network will work or not, I did not get that far!
Thank you!
This is because the screenshot in my post was taken in an old PowerCLI release.
The current version shows other default properties.
Direct the result of Select - property *, then you will see all of the properties of the Folder object.
You can try to use the function and use the returned object file on the location setting.
-
Syncronize "tags" between vcenter servers
Maybe someone already has a solution to do this, so I'll ask here until I get out all my hair.
In one of our vcenter, we started the use of the tags later. Similar to this is the way we want to go, so now the challenge is to "synchronize" tags between all of our vcenter servers.
I hope that some of you already have a way to do this, or an idea on where to start.
I suppose we could export using csv and import them to a different vcenter? Or is there a better way?
Suggestions are welcome at this stage...
Best regards
Jorgen S
You can use a CSV file to export/import of categories and labels.
Something like that.
Note that according to the number of connections that you opened, you must use the Server parameter to indicate the location of export/import.
(1) export
& {{foreach ($tCat in Get-TagCategory)
$tags = get-Tag-category $tCat
{if ($Tags)}
$tags | Select @{N = 'Category'; E={$tCat.name}},@{N='cDescription'; E={$tCat.Description}},@{N='Cardinality'; {E = {$tCat.Cardinality}}, Name, Description
}
else {}
$tCat | Select @{N = 'Category'; E={$tCat.name}},@{N='cDescription'; E={$tCat.Description}},@{N='Cardinality'; E={$tCat.cardinality}},@{N='Name'; {E = {""}}, @{N = 'Description'; E={''}}
}
}} | Export Csv C:\tag.csv - NoTypeInformation - UseCulture
(2) import
foreach ($tag in c:\tag.csv Import-Csv - UseCulture) {}
Try {}
Get-TagCategory-name $tag. Category - ErrorAction Stop
}
Catch {}
New-TagCategory-name $tag. Category Description $tag.cDescription - $tag cardinality. Cardinality-confirm: $false
}
if($tag.) {Name)
Try {}
Get-Tag-category $tag. Category-name $tag. Name - ErrorAction Stop
}
Catch {}
-Tag - new name $tag. Name - category $tag. Category Description $tag. Description-confirm: $false
}
}
}
-
A list of virtual machines to different vCenter servers
I am running a report that connects to the servers multiple vCenter. Within these vCenter servers, I have a number of clusters and in each group a subset of virtual machines that I'll call acme VMs with the acmevmnaming convention 1, acmevm3, acmevm2, etc. They all start with acmevm*.
Is it possible to create a report that tells me how many acme VMs are in each vCenter, and how many are in each cluster?
I suspect Re: access on behalf of the cluster of a VM answer this question on the cluster?
-
Multiple ESX servers to access the same data store
We connect our ESX servers to an Equallogic SAN iSCSI using VMWare iSCSI card. I have a data store that has ISO files to store. So far, I can connect only this data to an ESX Server store on time. I have to disconnect an and connect manually to the other. We currently have a facility relatively bare bones (don't have vCenter again, grouping, etc.).
Is there anyway to connect the same data store to multiple ESX servers? I tried to adjust the volume of Equallogic SAN for read only (since I just need to read ISO files), but I can't connect to ESX servers when I do this.
Remember that the volume is enabled for clustering.
From v4.x Equallogic firmware, there is an option advanced on each volume.
André
-
RAY of relief with multiple Radius servers
Wism2 version 7.6.130
I have multiple Radius servers for different wireless LANs that are used for authentication. For example:
WLAN1 - Radius1, Radius2
Wlan2 - Radius3, Radius4
WLAN3 - Radius5, Radius6
Radius servers have different types of user to the authentication databases.
My question is, when you configure RADIUS of relief in Active mode on the WLC he must receive a successful authentication response in order to stay active or simple an answer?
Thank you
Waqas
"My question is, when you configure RADIUS of relief in Active mode on the WLC he must receive a successful authentication response in order to stay active or simple an answer?
Hi Waqas,
It doesn't have to be a successful authentication, could be access accept or decline. You may have noticed with mode active there is a section to specify the user name (default: cisco-probe) what it does is when the radius known as death wlc server use that specific account to query the server radius on the specified time intervals.all these responses would also be responses to refuse access. Just a response if accept or reject to keep active.
Look here to see little more on the functionality of relief
See you soon
Micheline
WLC actively interrogate the radius server
-
ICPPX 4.05 and/or call Mgr 4.13 multiple LDAP servers for redundancy
We run IPCCX 4.05 to high availability (active / standby) and Call Manager 4.13 Pub/Sub. In this configuration, we use LDAP for authentication AD instead of the directory of DC (not my choice... things you inherit in life).
The call of Bishop and/or the servers IPCCX can be setup to point to multiple LDAP servers for redundancy?
CAN CM 4.13 and/or IPCCX 4.05 LDAPS support (as I have said, things you inherit)?
Our sysadmin team won our main server to the DC, and with him all functins LDAP search broke. Needless to say they will be put in place of LDAP or LDAPS on our main and backup DC in the near future.
Any information/suggestions/recommendatinos are appreciated.
Thank you
-Scott
Hello
This IS possible.
If the CRS web interface admin (/ appadmin) is available:
1. open a session
2. go to the system > LDAP information
3 type the FQDN / IP addresses (I recommend the latter) for LDAP servers, separated by commas (for example, I have something like in our laboratory: "ldapserver.domain.as, 10.1.1.1" - works like charm)
4. a window will appear asking if the LDAP information must be created or you just want to add another LDAP server (~ configuration already there). Choose wisely :-)
5. restart the server. No, restart the CRS engine is not enough.
If the CRS web administration interface is not available (~ as you said Mr. Sysadmin won DC backend), the there is a chance to get rid of this guy ;-) Anyway, there is always a chance that you can make it work. Of course, the LDAP server must already contain the appropriate configuration.
1. connect to the CRS Server using rdesktop/VNC
2. look for this file: C:\Program Files\wfavvid\properties\directory.properties it's just a plain text file. Look for this CCNIniFile=c:\\winnt\\system32\\ccn\\ccndir.ini
In fact, it can be something else too, this is the default path.
3. this file contains the information that we are looking for: LDAPURL 'ldap://10.1.1.1:389, ldap://10.1.1.2:389' and other important things like passwords and base DN
Change it according to your needs. :-)
4. restart the server.
Good luck.
G.
-
Managing 2 vsphere vcenter servers
We have 2 each Vcenter server running data centers. (Principal and Dr. Colo data center). In Vcenter 4, we had our configured client vsphere where we could both stop VCenter VShpere inside servers. I could log into my main data center and the VCenter servers were visible and manageable. (Even with our Colo). Somehow during our migration up to 5 VCenter, we lost that connection.
I would like to pick it up where I can see them both again.
Thank you
Looks like the linked Mode must be configured again.
-
Save multiple vCenter Server 5.1 with vSphere WebClient 5.1
How to save multiple vCenter Server 5.1 with vSphere WebClient 5.1?
simple enough... on your vCenter > https://localhost:9443 / admin-app / > registry vCenter Server... that's all
Greetings from Munich, Ralf
Maybe you are looking for
-
I tried to download microsoft fix and re-install vista from the disc that came with my laptop but neither stage work (the re - install vista wouldn't let not me full and I received the message)' upgreade cannot be started. Updated canecel installatio
-
I use Vista. The 'My videos' folder is missing. Impossible to find it's a search and my documents, music files etc is still there. How can I fix?
-
Since I got this new computer, none of my old games will play. I tried everything I know how to do it. I have vista.
-
Hello I use the http POST method to send data from BB device. Sending data is built in a loop (for). There is little break like 1-2 seconds between loops. The problem is that sometimes I can send data in one, sometimes two and sometimes three iterati
-
I received text messages which includes pictures on my bb curve 9360 and cannot find a way to copy the pictures of text messages on my pc. Another possibility, if I could only learn how to transfer these pictures in text messages to photos of section