I forgot to put line error :
Index operation failed; the array index evaluated to null. :323 char:3
Can you include all the error lines, not just the 1st line?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello, thx for your help
error 1 :
Deploying VMs
Attempted to divide by zero.
At C:\Users\XXXXX\Desktop\DeployVM.ps1:278 char:2
+ Write-Progress -Activity "Deploying VMs" -Status $vmStatus -PercentComplete (10 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
New-OSCustomizationSpec : 29/08/2019 12:10:24 New-OSCustomizationSpec Permission to perform this operation was
denied. Required privilege 'VirtualMachine.Provisioning.ModifyCustSpecs' on managed object with id 'Folder-group-d1'.
At C:\Users\_4123863\Desktop\DeployVM.ps1:301 char:25
+ $tempSpec = New-OSCustomizationSpec -Name temp$vmName -NamingScheme ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-OSCustomizationSpec], NoPermission
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_SavePersistentOSSpec_ViError,VMware.VimAutomation.ViCore.Cmdlets.Comm
ands.NewCustomizationSpec
Error 2 :
Deploying vm-name
NON SDRS Cluster disk on vm-name - using DiskStorageFormat parameter
Index operation failed; the array index evaluated to null.
At C:\Users\XXXXX\Desktop\DeployVM.ps1:323 char:3
+ $taskTab[(New-VM -Name $VM.NameVM -ResourcePool $VM.ResourcePool -Location $VM ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArrayIndex
First, how do you call this .ps1 file?
Do you pass the correct parameters?
Also, the line numbering from the errors does not correspond with the .ps1 file you attached earlier.
What is different?
Error 1 are in fact 2 different errors.
The first (divide by zero) could indicate a potential issue with the import of the CSV file.
The 2nd is a permissions problem.
You are not authorized to change the OSCustomizationSpec.
Error 2 is most probably due to the fact that the New-VM is producing a client-side task, not a server-side task.
Storing that task in a hash table in that case, will not work anymore.
This script dates from before when the client-side tasks were introduced.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference