Hi
Can anyone help me to check the below script is anything wrong in it.. I am getting error while running. This is for VMware HCX migration powerCLI script.
I tried to initiate migration by using this script and but getting error.
$Data = Import-csv C:\Input.csv -delimiter “;”
$Data | foreach {
$VmHost = $_.ServerName
$SourceSite = $_.SourceSite
$DestSite = $_.DestinationSite
$DestFolder = $_.containerFolder
$DestinationCompute = $_.DestinationCompute
$Datastore = $_.DestinationDataStore
$Network = $_.DestinationNetwork
#####Intiating Miration
$newMigration = New-HCXMigration -DestinationSite $DestSite -DiskProvisionType Thick -Folder $DestFolder -MigrationType Bulk -SourceSite $SourceSite -TargetComputeContainer $DestinationCompute -TargetDatastore $Datastore -TargetNetwork $Network -VM $VmHost
Test-HCXMigration -Migration $newMigration
#Start-HCXMigration -Migration $newMigration -Confirm:$false
}
Thanks in advance
It looks like $SrcNetworkB is an array, while the New-HcxNetworkMapping cmdlet only accepts a single value on the SourceNetwork parameter.
If Get-HcxNetwork returns more than one object, you will have to a use a ForEach loop over all the returned networks.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Can you help me with the changes please also if networkB, C and D data is not available in the sheet, it shouldn't return any errors in screen.
Can we export the whole list migration status report in CSV once script ends.
Like I said before, I don't have access to HCX HW, so I can't really test this.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ok LuCD Thank you..
Hi LuCD
Could you guss why I am getting the below errror,
Import-Csv : A positional parameter cannot be found that accepts argument '\MappingInput.csv'.
At T:\Migration initiation.ps1:2 char:9
+ $Data = Import-csv -Path T:\MappingInput.csv -delimiter ";"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Import-Csv], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.ImportCsvCommand
And my code is,
$Name= $Env:Username
$Data = Import-csv T:\MappingInput.csv -delimiter “;”
Place the path between single quotes.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LuCD,
I am unable to call multiple variable in -TargetNetwork.. How do I do that. I created as below
$newMigration = New-HCXMigration -SourceSite $SrcSite -DestinationSite $DstSite -VM $vm -MigrationType Bulk -DiskProvisionType Thick -TargetComputeContainer $TargetCluster -TargetDatastore $TargetDatastore -NetworkMapping {$TarNetworkA, $TarNetworkB, $TarNetworkC, $TarNetworkD} -UpgradeVMTools $False -RemoveISOs $True -ForcePowerOffVm $False -RetainMac $True -UpgradeHardware $False -RemoveSnapshots $False -ScheduleStartTime $StartTime -ScheduleEndTime $EndTime
The NetworkMapping value should be an array afaik.
Try with -NetworkMapping @($TarNetworkA, $TarNetworkB, $TarNetworkC, $TarNetworkD)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference