BTW i got same err
PowerCLI C:\> function New-VIAccount($principal) {
>> $flags = `
>> [System.Reflection.BindingFlags]::NonPublic -bor
>> [System.Reflection.BindingFlags]::Public -bor
>> [System.Reflection.BindingFlags]::DeclaredOnly -bor
>> [System.Reflection.BindingFlags]::Instance
>>
>> $global:defaultviserver.GetType().GetMethods($flags) |
>> where { $_.Name -eq "VMware.VimAutomation.Types.VIObjectCore.get_Client" }
>>
>> $client = $method.Invoke($global:DefaultVIServer, $null)
>> Write-Output (New-Object VMware.VimAutomation.Client20.PermissionManagement.VCUserAccountImpl -ArgumentList $principal, "", $client)
>> }
>>
PowerCLI C:\> $account = New-VIAccount "xxx\xxx"
You cannot call a method on a null-valued expression.
At line:9 char:29
+ $client = $method.Invoke <<<< ($global:DefaultVIServer, $null)
+ CategoryInfo : InvalidOperation: (Invoke:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
New-Object : Constructor not found. Cannot find an appropriate constructor for type VMware.VimAutomation.Client20.PermissionManagement.VCUserAccountI
mpl.
At line:10 char:29
+ Write-Output (New-Object <<<< VMware.VimAutomation.Client20.PermissionManagement.VCUserAccountImpl -ArgumentList $principal, "", $client)
+ CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand
PowerCLI C:\>