Hello,
I'm trying to create a bulg of datastores.
# Connect to vCenter Server:
$credential = Import-Clixml -Path xxxxxx
Connect-VIServer -Server xxxxxx -Credential $credential
$CSVFile = "D:\xxxx.csv"
$Datastores = Import-CSV $CSVFile
Foreach ($Store in $Datastores) {
New-Datastore -VMHost "xxxxxx" -Name $Store.DatastoreName -Path $Store.CanonicalName -Vmfs -FileSystemVersion 6
}
But there is something wrong:
New-Datastore : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At D:\xxxxx.ps1:8 char:51
+ ... ore -VMHost "xxxxxx" -Name $($Store.DatastoreName) -Path $ ...
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-Datastore], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewDatastore
When trying this:
$CSVFile = "D:\xxxxx"
$Datastores = Import-CSV $CSVFile
PS C:\Windows\system32> $Datastores
CanonicalName;DatastoreName
---------------------------
naa.xxxxxxxxxx;ab_cd_01
naa.xxxxxxxxxx;ab_cd_02
i see that there are values for DatastoreName and CanonicalName.
So why can this values not be used by the script?
regards
Andi