Original Message:
Sent: Feb 18, 2025 09:10 PM
From: Cao Quang Chien
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Hi LucD,
My vCenter has some clusters, but i only want to get the VMs in one cluster, as you see my script and csv file.
Can you use my script to run on your environment? Please let me know the results.
Original Message:
Sent: Feb 18, 2025 04:49 AM
From: LucD
Subject: PowerCLI: Add VMs on vCenter to available resource pool
The only possible option that I can still imagine is that the cluster name or the resourcepool name in the CSV is for a resource that doesn't exist (or returns more than 1 result).
Then the Inventory Service might return an error (in HTML) while the API method behind the PowerCLI cmdlet is expecting a result in XML format.
Also check if you have multiple connections open (with $global:defaultVIServers)
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 18, 2025 03:19 AM
From: Cao Quang Chien
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Hi LucD,
No. Only above error.
I also use other script as create VMs, migrate VMs to other Host, Datastore, everything is ok. but with migrate VMs to Resource Pool has this error :(
Original Message:
Sent: Feb 18, 2025 12:23 AM
From: LucD
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Did the Connect-VIServer return any messages?
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 17, 2025 09:19 PM
From: Cao Quang Chien
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Hi LucD,
Thank so much for support me.
I used your guide, but the same error.
Move-VM : 2/18/2025 9:11:18 AM Move-VM Failed to get Lookup Service information for this vCenter server. Details: The content type text/html;charset=utf-8 of the response message does not match the
content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:
'<!DOCTYPE html>
<html class="login-pf">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Sign in to VNPAY</title>
<link rel="icon" href="/auth/resources/cbasi/login/keycloak/img/favicon.ico" />
<link href="/auth/resources/cbasi/common/keycloak/web_modules/@patternfly/react-core/dist/styles/base.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/web_modules/@patternfly/react-core/dist/styles/app.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/node_modules/patternfly/dist/css/patternfly.min.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/node_modules/patternfly/dist/css/patternfly-additions.min.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/l'.'
At line:15 char:9
+ Move-VM -VM $vm -Destination $destinationResourcePool
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Move-VM], VimException
+ FullyQualifiedErrorId : ViCore_ConnectivityServiceImpl_GetLookupServiceClient_NoClient,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
Original Message:
Sent: Feb 17, 2025 03:44 AM
From: LucD
Subject: PowerCLI: Add VMs on vCenter to available resource pool
How did you configure your PowerCLI?
Check with
Get-PowerCLIConfiguration
Try setting the certificate action to ignore, if not already so
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Scope Session,User,AllUsers -Confirm:$false
A long shot, can you change the Connect-VIServer line to this?
That might give a clue as to what is happening.
Also try with -Protocol HTTP, if https doesn't work.
Connect-VIServer -Server 10.122.113.20 -Credential $credential -Protocol https -Verbose
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 16, 2025 08:48 PM
From: Cao Quang Chien
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Hi LucD,
the CSV file as I attach, no special characters, format .csv
I try fix this error, but not OK.
Original Message:
Sent: Feb 14, 2025 06:45 AM
From: LucD
Subject: PowerCLI: Add VMs on vCenter to available resource pool
That seems to be ok.
Does the format of the CSV you are using correspond?
Are there any characters in there that do not display correctly?
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 14, 2025 04:48 AM
From: Cao Quang Chien
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Hi LucD, Thanks your answer,
I run Get-Culture, output here: please suppore me to fix this.
LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States)
Original Message:
Sent: Feb 14, 2025 02:31 AM
From: LucD
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Could it be that you are using a language setting on your station, or in the CSV, that the VCSA doesn't understand?
Can you check with Get-Culture?
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Feb 14, 2025 01:22 AM
From: Cao Quang Chien
Subject: PowerCLI: Add VMs on vCenter to available resource pool
Dear All,
I used PowerCLI to add VMs into Resource Pool on vCenter. However has error bllow. Please support me, thanks!
My code:
$credential = Get-Credential
Connect-VIServer -Server 10.122.113.20 -Credential $credential -Force -WarningAction SilentlyContinue
# Đọc thông tin từ file CSV
$csvData = Import-Csv -Path 'E:\adam\Scripts\res.csv' -UseCulture
foreach ($row in $csvData) {
$cluster = Get-Cluster -Name $row.Cluster
$defaultResourcePool = Get-ResourcePool -Name "Resources" -Location $cluster
$vm = Get-VM -Name $row.VMName | Where-Object { $_.ResourcePool -eq $defaultResourcePool }
$destinationResourcePool = Get-ResourcePool -Name $row.ResourcePool -Location $cluster
if ($vm) {
Move-VM -VM $vm -Destination $destinationResourcePool
} else {
Write-Host "VM $($row.VMName) don't Resource Pool default."
}
}
Disconnect-VIServer -Confirm:$false
Error:
Move-VM : 2/4/2025 9:01:03 AM Move-VM Failed to get Lookup Service information for this vCenter server. Details: The content type text/html;charset=utf-8 of the response message does not match the
content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:
'<!DOCTYPE html>
<html class="login-pf">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Sign in to VNPAY</title>
<link rel="icon" href="/auth/resources/cbasi/login/keycloak/img/favicon.ico" />
<link href="/auth/resources/cbasi/common/keycloak/web_modules/@patternfly/react-core/dist/styles/base.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/web_modules/@patternfly/react-core/dist/styles/app.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/node_modules/patternfly/dist/css/patternfly.min.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/node_modules/patternfly/dist/css/patternfly-additions.min.css" rel="stylesheet" />
<link href="/auth/resources/cbasi/common/keycloak/l'.'
At line:15 char:9
+ Move-VM -VM $vm -Destination $destinationResourcePool
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:)
[Move-VM], VimException
+ FullyQualifiedErrorId : ViCore_ConnectivityServiceImpl_GetLookupServiceClient_NoClient,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM