Rob, can you give a bit more info ?
I assume you're working with the 4.1 version (ESXi and vCenter) ?
Are you also using PowerCLI 4.1 or PowerCLI 4u1 ?
And perhaps the complete error message with the line number ?
It's probably the following line that causes the error
$task = Get-View $taskMoRef
Could you try replacing it by this
$task = Get-View ([http://VMware.Vim.VIConvert|http://VMware.Vim.VIConvert]::ToVim($taskMoRef))
Blog: LucD notes
Twitter: lucd22Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz1 person found this helpful
vCenter and ESXI are both version 4.1. Powercli is alo version 4.1
I also get an error before (i forgot to add that as well)
Exception calling "ReconfigureDvs_Task: with 1 argument(s): "Not initialized: vim.hostsystem.host"
When i call the function after the server is already in vcenter, then there is no prob.
I added a do while loop, so i am certain the MoRef from the host is there.