Here's what I'm testing with....
$a = Get-Folder "FolderName"
$Cluster="ClusterName"
New-VM -VMFilePath "%path% with %filename%" -VMHost (Get-Cluster $Cluster | Get-VMHost ESXHOSTNAME | Select-Object -first 1) -Location $a[1] -RunAsync
sleep -seconds 10
Set-NetworkAdapter -NetworkAdapter ( Get-NetworkAdapter servername ) -NetworkName "VLAN NAME" -StartConnected $false -confirm:$false
sleep -seconds 10
$vm = Get-VM servername
sleep -seconds 10
<# last part #>
$key = "scsi0:8.filename"
$value = "/vmfs/volumes/ReplacementDiskNumber/servername/servername.vmdk"
$vm = Get-View (Get-VM servername).Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[0].Key=$key
$vmConfigSpec.extraconfig[0].Value=$value
$vm.ReconfigVM($vmConfigSpec)
First part seems to work fine, it adds machine to inventory
Second part works fine, adds correct vlan
last part, not so much. I have used the $value from a vmx file that has been built manually thru removing and adding the disk via the gui. I can relace the vmx file, but think that being able to edit a vmx file like this will be benificial in the future...