I think you mean 

    esxhost.configManager.networkSystem.AddVirtualNic(:portgroup => pgname, :nic => nic_spec)