VMware Cloud Community
bruins05G
Contributor
Contributor

Exception calling "SetEntityPermissions" with "2" argument(s):-

Greetings,

I am running a script and receving a lot of Exception calling "SetEntityPermissions Errors. Please see attached. Any thoughts on what I am doing wrong?

Here is the script and it occurs right after it makes the connection to the vcenters..

0 Kudos
1 Reply
LucD
Leadership
Leadership

Looks like the $object.MoRef is $null in a call to the method.

Can you try with the following version of your function ?

It will check if you pass a $null object as the 1st parameter.

function Set-Permission

{

  param(

   [parameter(Mandatory = $true)]

    [ValidateNotNullOrEmpty()]

    [VMware.Vim.ManagedEntity]$object,

    [VMware.Vim.Permission]$permission

  )

  Begin{

  }

  Process{

    $perms = $authMgr.SetEntityPermissions($object.MoRef,@($permission))

  }

  End{

    return

  }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos