Automation

 View Only
  • 1.  Setting permissions on a virtual port group with powershell

    Posted Dec 01, 2009 01:02 PM

    Help .

    I'm trying to set permissions on a virtual port group and it doesn't work.

    I have managed to make it on folder, on VM but for those objects I'm blind.

    Somebody could help me , it would be so nice.

    Thanks .



  • 2.  RE: Setting permissions on a virtual port group with powershell

    Posted Dec 01, 2009 01:22 PM

    I suspect you are trying to this with new New-ViPermission cmdlet ?

    Then I can confirm that the cmdlet doesn't seem to take vSwitches nor Portgroups.

    It always comes back with the message:

    New-VIPermission : Cannot bind parameter 'Entity'. Cannot convert the "PG1" value of type "VMware.VimAutomation.Client20.Host.VirtualPortGroupImpl" to type "VMware.VimAutomation.Types.InventoryItem"



  • 3.  RE: Setting permissions on a virtual port group with powershell

    Posted Dec 01, 2009 01:58 PM

    No I'm trying to do it with the SetEntityPermission from the $AuthMgr , certainly not a good way.

    Thanks for your reply I'll test with your idea whenever it doesn't seem to work.



  • 4.  RE: Setting permissions on a virtual port group with powershell

    Posted Dec 01, 2009 02:21 PM

    You have to retrieve the portgroup a bit different.

    The following should work for Virtual Machine portgroups

    $tgtPg = <pg-name>
    $tgtRole = <role-name>
    $tgtEntity = <entity-name>
    $esxName = <ESX-name>
    
    $esx = Get-VMHost $esxName | Get-View
    $esx.Network | %{
    	$net = Get-View $_
    	if($net.Name -eq $tgtPg){
    		$tgtNet = $net
    	}
    }
    $authMgr = Get-View AuthorizationManager
    $authMgr.roleList | %{
    	if($_.info.label -eq $tgtRole){
    		$tgtId = $_.roleId
    	}
    }
    $permission = New-Object VMware.Vim.Permission
    $permission.principal = $tgtEntity
    $permission.group = $false
    $permission.propagate = $false
    $permission.RoleId = $tgtId
    $authMgr.SetEntityPermissions($tgtNet.MoRef, $permission)
    



  • 5.  RE: Setting permissions on a virtual port group with powershell

    Posted Dec 01, 2009 03:04 PM

    Thank you very much Dear LucD.

    Effectively it works fine .

    Sorry for my approximative English,it comes from a french beginner Vmware administrator and Powershell writer.

    See you and best wishes.

    Eric.



  • 6.  RE: Setting permissions on a virtual port group with powershell

    Posted Dec 02, 2009 02:38 AM

    Thanks for pointing out this problem with Set-VIPermission, I logged a bug for it.

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]