Hi Admins,
I trying to move VMs to another datastore using powershell.
move-vm servername -datastore iSCSI-vmfs04
Error message : Move-VM The specified parameter 'Datastore' expects a single value, but your name criteria 'iscsi-vmfs04' corresponds to multiple
values.
If i run get-datastores it will return:
iscsi-vmfs04
iscsi-vmfs04
iscsi-vmfs05
iscsi-vmfs05
iscsi-vmfs06
iscsi-vmfs06
Is my pathpolicy the problem? using RoundRobin.
Storage vmotion works just fine if i use the vCenter GUI.
Advice?
Cheers,
tyler
You did notice that the free space is not exactly the same for both lines of the same datastore.
Do you have some ghost datastores in your vCenter perhaps ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Could it be that you are running in "multiple" mode and that you have more than 1 open connection ?
Do a
Get-PowerCLIConfiguration
and
$defaultviservers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for ur reply.
Guess you are right.
S C:\> Get-PowerCLIConfiguration
Proxy Policy Default Server Invalid Certificate
Mode Action
------------ --------------- --------------------
UseSystemProxy Multiple Unset
PS C:\> $defaultviservers
Name Port User
---- ---- ----
bman-vcenter02.domain.local 443 domain\user
But how can this be changed?
I try:
PS C:\> set-PowerCLIConfiguration -defaultviservermode Single
Proxy Policy Default Server Invalid Certificate
Mode Action
------------ --------------- --------------------
UseSystemProxy Multiple Unset
Regards,
Tyler
The Set-PowerCLIConfiguration cmdlet has 3 scopes (Scope parameter).
If you want to change it for the current session, you do
Set-PowerCLIConfiguration -defaultviservermode Single -Scope Session
But I find it strange that you only see 1 connection in $defaultviservers.
Let's first set the config to single and then do the Get-Datastore again to see if it changed the result.
Update: which PowerCLI build are you using ? Do a
Get-PowerCLIVersion
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PS C:\> Set-PowerCLIConfiguration -defaultviservermode Single -Scope Session
Set-PowerCLIConfiguration : A parameter cannot be found that matches parameter name 'Scope'.
At line:1 char:55
+ Set-PowerCLIConfiguration -defaultviservermode Single -Scope Session
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-PowerCLIConfiguration], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVIToolkitConfiguration
PS C:\> Get-PowerCLIVersion
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.0.1 build 581491
---------------
Snapin Versions
---------------
VMware AutoDeploy PowerCLI Component 5.0 build 544967
VMware ImageBuilder PowerCLI Component 5.0 build 544967
VMware License PowerCLI Component 5.0 build 544881
VMware vSphere PowerCLI Component 5.0 build 581435
Regards,
Tyler
The Scope parameter was introduced in the lastest version (5.1).
But it should change the setting in PowerCLI 5.0.1 with
Set-PowerCLIConfiguration -DefaultVIServerMode Single
as you did.
Strange, can you try to stop/start your the PowerCLI prompt/session ? And then check the setting again ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And it would of course be better to upgrade to 5.1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Now upgraded PowerCli to 5.1
PS C:\> Get-PowerCLIConfiguration
Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeout
Seconds
----- ----------- ------------------- ------------------------ -------------------------- -------------------
Session UseSystemProxy Single Unset True 300
User UseSystemProxy Single
AllUsers
PS C:\> $defaultviservers
Name Port User
---- ---- ----
bman-vcenter02.domain.local 443 domain\user
PS C:\> Get-Datastore
Name FreeSpaceGB CapacityGB
---- ----------- ----------
iSCSI-VMFS12 122,523 799,750
iSCSI-VMFS12 122,524 799,750
iSCSI-VMFS11 124,875 799,750
iSCSI-VMFS11 124,874 799,750
iSCSI-VMFS10 134,264 799,750
iSCSI-VMFS10 134,263 799,750
iSCSI-VMFS09 131,741 799,750
iSCSI-VMFS09 131,739 799,750
iSCSI-VMFS08 290,095 799,750
iSCSI-VMFS08 290,096 799,750
iSCSI-VMFS07 206,809 799,750
iSCSI-VMFS07 206,767 799,750
iSCSI-VMFS06 162,819 799,750
iSCSI-VMFS06 162,863 799,750
iSCSI-VMFS05 208,211 799,750
iSCSI-VMFS05 208,210 799,750
iSCSI-VMFS04 465,455 799,750
iSCSI-VMFS04 465,455 799,750
iSCSI-VMFS03 210,101 799,750
iSCSI-VMFS03 210,101 799,750
iSCSI-VMFS02 219,981 699,750
iSCSI-VMFS02 219,936 699,750
iSCSI-VMFS01 160,239 2 662,250
iSCSI-VMFS01 160,245 2 662,250
But i still see every datastore twice!?
How many ESXi servers do you have in that vCenter ?
Are they in a cluster ?
If not, can each see all the datastores ?
If yes, try doing
Get-Datastore -VMHost ESX1
You need to update the ESXi name of course
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
I have 5 ESX hosts in one cluster. (5.1)
All 5 hosts can see the all datastores.
get-vmhost esx | get-datastore
Name FreeSpaceGB CapacityGB
---- ----------- ----------
iSCSI-VMFS12 122,524 799,750
iSCSI-VMFS11 122,996 799,750
iSCSI-VMFS10 136,322 799,750
iSCSI-VMFS09 131,741 799,750
iSCSI-VMFS08 290,092 799,750
iSCSI-VMFS07 206,719 799,750
iSCSI-VMFS06 162,819 799,750
iSCSI-VMFS05 208,211 799,750
iSCSI-VMFS04 465,443 799,750
iSCSI-VMFS03 210,101 799,750
iSCSI-VMFS02 219,884 699,750
iSCSI-VMFS01 160,054 2 662,250
This is the output id like to get...Thats strange..... or?
Cheers,
Tyler
This worked
$vm = get-vmhost esxhost | get-vm vmname
$dest = get-vmhost esxhost | Get-Datastore iscsi-vmfs04
Move-VM $vm -Datastore $dest
Very strange..
Regards,
Tyler
What does the following produce ?
foreach($ds in Get-Datastore){ Get-View ($ds.ExtensionData.Host | %{$_.Key}) |
select @{N="Datastore";E={$ds.Name}},
@{N="Host";E={$_.Name}} }
You should see a line for each ESXi that sees the datastore.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for all ur hel so far LucD!
PS C:\> foreach($ds in Get-Datastore){
Get-View ($ds.ExtensionData.Host | %{$_.Key}) |
select @{N="Datastore";E={$ds.Name}},
@{N="Host";E={$_.Name}}
}
Datastore Host
--------- ----
iSCSI-VMFS01 bman-esx01.domain.local
iSCSI-VMFS01 bman-esx03.domain.local
iSCSI-VMFS01 bman-esx04.domain.local
iSCSI-VMFS01 bman-esx02.domain.local
iSCSI-VMFS06 bman-esx01.domain.local
iSCSI-VMFS06 bman-esx03.domain.local
iSCSI-VMFS06 bman-esx04.domain.local
iSCSI-VMFS06 bman-esx02.domain.local
iSCSI-VMFS07 bman-esx01.domain.local
iSCSI-VMFS07 bman-esx03.domain.local
iSCSI-VMFS07 bman-esx04.domain.local
iSCSI-VMFS07 bman-esx02.domain.local
iSCSI-VMFS08 bman-esx01.domain.local
iSCSI-VMFS08 bman-esx03.domain.local
iSCSI-VMFS08 bman-esx04.domain.local
iSCSI-VMFS08 bman-esx02.domain.local
iSCSI-VMFS09 bman-esx01.domain.local
iSCSI-VMFS09 bman-esx03.domain.local
iSCSI-VMFS09 bman-esx04.domain.local
iSCSI-VMFS09 bman-esx02.domain.local
iSCSI-VMFS02 bman-esx01.domain.local
iSCSI-VMFS02 bman-esx03.domain.local
iSCSI-VMFS02 bman-esx04.domain.local
iSCSI-VMFS02 bman-esx02.domain.local
iSCSI-VMFS10 bman-esx01.domain.local
iSCSI-VMFS10 bman-esx03.domain.local
iSCSI-VMFS10 bman-esx04.domain.local
iSCSI-VMFS10 bman-esx02.domain.local
iSCSI-VMFS11 bman-esx01.domain.local
iSCSI-VMFS11 bman-esx03.domain.local
iSCSI-VMFS11 bman-esx04.domain.local
iSCSI-VMFS11 bman-esx02.domain.local
iSCSI-VMFS12 bman-esx01.domain.local
iSCSI-VMFS12 bman-esx03.domain.local
iSCSI-VMFS12 bman-esx04.domain.local
iSCSI-VMFS12 bman-esx02.domain.local
iSCSI-VMFS03 bman-esx01.domain.local
iSCSI-VMFS03 bman-esx03.domain.local
iSCSI-VMFS03 bman-esx04.domain.local
iSCSI-VMFS03 bman-esx02.domain.local
iSCSI-VMFS04 bman-esx01.domain.local
iSCSI-VMFS04 bman-esx03.domain.local
iSCSI-VMFS04 bman-esx04.domain.local
iSCSI-VMFS04 bman-esx02.domain.local
iSCSI-VMFS05 bman-esx01.domain.local
iSCSI-VMFS05 bman-esx03.domain.local
iSCSI-VMFS05 bman-esx04.domain.local
iSCSI-VMFS05 bman-esx02.domain.local
(When i ask vCenter)
PS C:\> Get-Datastore | Sort-Object -Descending
Name FreeSpaceGB CapacityGB
---- ----------- ----------
iSCSI-VMFS12 122,345 799,750
iSCSI-VMFS12 122,351 799,750
iSCSI-VMFS11 122,787 799,750
iSCSI-VMFS11 122,786 799,750
iSCSI-VMFS10 151,704 799,750
iSCSI-VMFS10 151,703 799,750
iSCSI-VMFS09 131,134 799,750
iSCSI-VMFS09 131,133 799,750
iSCSI-VMFS08 290,089 799,750
iSCSI-VMFS08 290,090 799,750
iSCSI-VMFS07 206,694 799,750
iSCSI-VMFS07 206,694 799,750
iSCSI-VMFS06 162,667 799,750
iSCSI-VMFS06 162,751 799,750
iSCSI-VMFS05 208,208 799,750
iSCSI-VMFS05 208,207 799,750
iSCSI-VMFS04 445,682 799,750
iSCSI-VMFS04 445,688 799,750
iSCSI-VMFS03 209,941 799,750
iSCSI-VMFS03 209,941 799,750
iSCSI-VMFS02 219,679 699,750
iSCSI-VMFS02 219,626 699,750
iSCSI-VMFS01 154,968 2 662,250
iSCSI-VMFS01 154,896 2 662,250
You did notice that the free space is not exactly the same for both lines of the same datastore.
Do you have some ghost datastores in your vCenter perhaps ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Now i am a little bit ashamed....
The thing is that i just realized that we have 2 datacenters. (Understood this when you pointed out the difference"free space" on the datastores)
get-datacenter bman | get-datastore gives me the correct answers.
Thanks again for all ur help!
Regards,
Tyler
No problem, glad the mystery was solved
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference