Thx for your assistence.
Original Message:
Sent: Mar 21, 2025 06:42 AM
From: Luc Dekens
Subject: Error in script
Instead of updating your CSV, you can also use the Delimiter parameter.
Import-Csv -Delimiter ';'
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Mar 20, 2025 09:04 AM
From: vmstoani
Subject: Error in script
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