vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
746 stars 603 forks source link

BadEnumeration Error calling SSOClient GetLocalUsers() #495

Closed Cylindric closed 2 years ago

Cylindric commented 2 years ago

Hi folks. I'm just trying to use the SsoAdmin module to create a new local user in a vsphere 7.0.2 setup and am hitting an error I can't pin down.

$sso = Connect-SsoAdmin-Server -Server $server -User $user -Password $password
$sso_user = Get-SsoPersonUser -Name "test" -Domain "vpshere.local"

And the error I get is:

Get-SsoPersonUser : One or more errors occurred.
At line:1 char:13
+ $sso_user =  Get-SsoPersonUser -Name "test" -Domain "vpshere.local"
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-SsoPersonUser

> $error[0] | select *

writeErrorStream      : True
PSMessageDetails      : 
Exception             : Microsoft.PowerShell.Commands.WriteErrorException: One or more errors occurred.
TargetObject          :
CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-SsoPersonUser
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Get-SsoPersonUser<Process>, C:\Users\me\Documents\WindowsPowerShell\Modules\VMware.vSphere.SsoAdmin\PersonUser.ps1: line 263
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

> $error[1] | select *

format-default : One or more errors occurred.
    + CategoryInfo          :  NotSpecified: (:) [format-default], AggregateException
    + FullyQualifiedErrorId : System.AggregateException,Microsoft.PowerShell.Commands.FormatDefaultCommand          

If I try to call the Client functions directly, I get a slightly more enlightening error perhaps:

$sso.Client.GetLocalUsers($username, "vsphere.local")

An error occurred while enumerating through a collection: One or more errors occurred..
At line:1 char:1
+ $sso.Client.GetLocalUsers($username, "vsphere.local")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InavlidOperation: (Vmware.vSphere....ocalUsers>d__18:<GetLocalUsers>d__18 [], RuntimeException
    + FullyQualifiedErrorId : BadEnumeration
Cylindric commented 2 years ago

Apologies for the screenshot, but I'm in a place where I can't easily copy'n'paste out image

Cylindric commented 2 years ago

Please disregard. This whole thing was because the account I was given isn't quite as "full admin" as I was told. Would be nice if the errors were a bit more on-point perhaps.