Add permissions help

Trying to follow the logic of this post:

$dc = Get-Datacenter -Name <datacenter-name> | Get-View
$perm = $authMgr.RetrieveEntityPermissions($dc.MoRef, $true)
$perm = New-Object VMware.Vim.Permission
$perm.group = $false
$perm.principal = "mydomain\myaccount"
$perm.propagate = $false
$perm.roleId = $roleid
$authMgr.SetEntityPermissions($dc.MoRef, $perm)

My scenario:

Already have a custom role called 'Test '.

You want to assign this role to "Domain\Group" at the level of the root folder.

My attempt:

$folder = Get-Folder -norecursion | Get-View
$perm = $authMgr.RetrieveEntityPermissions($folder.MoRef, $true)
$perm = New-Object VMware.Vim.Permission
$perm.group = $true
$perm.principal = "Domain\Group"
$perm.propagate = $true
$perm.roleId = "Test"
$authMgr.SetEntityPermissions($folder.MoRef, $perm)

Results in:

You cannot call a method on a null-valued expression.
At [http://script...|http://script...]:2 char:43
+ $perm = $authMgr.RetrieveEntityPermissions <<<< ($folder.MoRef, $true)
+ CategoryInfo          : InvalidOperation: (RetrieveEntityPermissions:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Exception setting "RoleId": "Cannot convert value "Test" to type "System.Int32". Error: "Input string was not in a correct format.""
At [http://script...|http://script...]:7 char:7
+ $perm. <<<< roleId = "Test"
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

You cannot call a method on a null-valued expression.
At [http://script...|http://script...]:8 char:30
+ $authMgr.SetEntityPermissions <<<< ($folder.MoRef, $perm)
+ CategoryInfo          : InvalidOperation: (SetEntityPermissions:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Any Suggestions?

No problem, the roleid property must be a number.

It represents the role.

Assuming that the role is called "Test", you can find the number as the first 3 lines following.

Your script becomes

$roleName = "Test"
$authMgr = Get-View AuthorizationManager
$roleId = ($authMgr.RoleList | where {$_.Name -eq $roleName}).RoleId

$folder = Get-Folder -norecursion | Get-View
$perm = $authMgr.RetrieveEntityPermissions($folder.MoRef, $true)
$perm = New-Object VMware.Vim.Permission
$perm.group = $true
$perm.principal = "Domain\Group"
$perm.propagate = $true
$perm.roleId = $roleId
$authMgr.SetEntityPermissions($folder.MoRef, $perm)

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • Cannot add permissions for users Active Directory - the directory access error

    Hi all

    VCenter, connected as long as user with administrator privileges on the server, Active Directory running I am can be used to add permissions for domain accounts and just get errors:

    Right-click on the data center & gt; Add authorization & gt; Select read-only & gt; Add users and groups & gt; Select the domain & gt; (the list is NOT populated with users)

    Among users, enter my account of user AD & gt; Click on check names & gt; "The following names are not found: xxx".

    Enter the AD user account in the search box & gt; Click Search & gt; "A general system error occurred: directory access error.

    The only son I can find or KB articles relate to the modification of the period of Active Directory.  I did, but it did not help.

    http://communities.VMware.com/thread/14150

    http://KB.VMware.com/kb/1010094

    Any ideas why I can't delegate permissions? I do not think we have group policies that are resticting access, but I don't know which of the log files I should I seek to find the real problem.

    Thank you

    Kevin

    Windows Server 2003 R2 Standard Edition, vSphere Client 4.0.0 build 162856, vCenter Server 4.0.0 build 162856, ESXi 4.0.0 build 181792

    The problem that I had was related to what service vCenter services were running as.  No doubt during the installation (for some reason that escapes me now) I had configured the VMware VirtualCenter Server and VMware VirtualCenter Management Web services run under the local administrator account.  Change these so they ran as system Local solved the problem, and then I have a list of domain users and assign them permissions.

    Kevin

  • Script to join the domain, the role of configuration, add permissions and activate/SNMP configuration

    So I'm writing a script to install our vSphere hosts to work with our monitoring software.  Right now, it's all done by hand and I would like if possible to automate it.  So far, I came up with this.  I get to step 5 and that's where it fails.  I can get it manually run the Get-VIAccount command, but in the script, it fails.

    These are my steps

    1. connect to an existing host and retrieve role properties.

    2. connect to the new host

    3 join the domain.

    4. disconnect the new host and reconnect with the credentials of domain

    5. get the domain account, role of research/create and add permissions to host

    6. enable and configure SNMP

    7 restart MGMT officers.

    #Variables

    $vmhost = "Host03".

    $domaintojoin = "Domaine.org".

    $domainAlias = "domain".

    # $usernametograntpermissions = "service.account".

    $rolename = 'team - account control service '.

    #Connect to host17 to retrieve the role privileges

    to connect-viserver host17

    #Extract of privileges for the role of vcenter Monitoring Service

    $privsforrole = get-viprivilege-role (get-ferrule-name $rolename)

    Server VI #disconnect

    disconnect-viserver *-confirm: $false

    VSphere hosts #Connect above (enter the credentials of the root when prompted)

    SE connect-viserver-Server host03

    #Join field

    Get-vmhostauthentication - VMhost ctcvsphere3 | Game-VMHostAuthentication-domain $domaintojoin - user %-% - JoinDomain-confirm password password: $false

    credentials of the #disconnect root

    disconnect-viserver *-confirm: $false

    #reconnect with the credentials of domain

    SE connect-viserver-Server ctcvsphere3-user username-password password % domain\username

    #Get domain account and add to the host

    $viAccount = get-VIAccount-DOMAIN-User - ID service.account

    # Get the role

    $viRole = get-ferrule-name $roleName

    If (-not $viRole) {}

    throw the "Role of the creation.

    New-ferrule-name $rolename - Server $vmhost

    Together-ferrule-role (Get-ferrule-name $rolename - Server $vmhost) - AddPrivilege (get-VIPrivilege-id $privsforrole - Server $vmhost)

    }

    # Add permissions on VMHost

    New-VIPermission-Director $viAccount-role $viRole - entity $vmHost

    all VIServers #disconnect

    Disconnect-VIServer *-confirm: $false

    }

    #Configure SNMP

    Get-vmhostsnmp | set-vmhostsnmp-enabled: $true

    Get-vmhostsnmp | game-vmhostsnmp - ReadOnlyCommunity 'SNMP.

    #Restart Mgmt officers

    Get-VMHostService - VMHost $vmhost | where {$_.} Key - eq "vpxa"} | Restart-VMHostService - Confirm: $falese - ErrorAction SilentlyContinue

    Here is my error:

    Get-VIAccount: 27/02/2014-16:03:11 VIAccount Get A general system

    rror occurred: access to the directory error

    C:\ps1\vmware\snmp1.ps1:42 char: 28

    + $viAccount = get-VIAccount < < < < - domain - User - ID SERVICE. ACCOUNT

    + CategoryInfo: NotSpecified: (:)) [Get-VIAccount], SystemError)

    + FullyQualifiedErrorId: Client20_VmHostServiceImpl_RetrieveUserGroups_Vi

    Error, VMware.VimAutomation.ViCore.cmdlets.Commands.PermissionManagement.GE

    tVIAccount

    Get-VIAccount: 27/02/2014-16:03:11 Get - VIAccount VIAccount with the id

    "service.account" was not found using the specified filters.

    C:\ps1\vmware\snmp1.ps1:42 char: 28

    + $viAccount = get-VIAccount < < < < - domain - User - ID SERVICE. ACCOUNT

    + CategoryInfo: ObjectNotFound: (:)) [Get-VIAccount], VimExceptio)

    n

    + FullyQualifiedErrorId: Core_OutputHelper_WriteNotFoundError, VMware.VimA

    utomation.ViCore.Cmdlets.Commands.PermissionManagement.GetVIAccount

    New-VIPermission: Impossible to validate the argument on the parameter "principal." The argument

    ent is null or empty. Provide an argument that is not null or empty, and then try

    the command again.

    C:\ps1\vmware\snmp1.ps1:56 tank: 40

    + New-VIPermission-main < < < < $viAccount - $viRole - entity role

    y $vmHost

    + CategoryInfo: InvalidData: (:)) [new VIPermission], ParameterBi)

    ndingValidationException

    + FullyQualifiedErrorId: ParameterArgumentValidationError, VMware.VimAutom

    ation.ViCore.Cmdlets.Commands.PermissionManagement.NewVIPermission

    The term 'catch' is not recognized as a cmdlet, function, script fi

    the, or an executable program. Check the spelling of the name, or if a path has been included

    DED, make sure the path is correct, and then try again.

    C:\ps1\vmware\snmp1.ps1:57 tank: 12

    + captures < < < < {}

    + CategoryInfo: ObjectNotFound: (catch: String) [], CommandNotFou

    ndException

    + FullyQualifiedErrorId: CommandNotFoundException

    Thanks in advance!

    Dimitar did a nice write-up of this phenomenon and a possible solution.

    See ESXi hosts to join a domain and licensing with PowerCLI

  • How to add permissions for a specific to multiple ESX Servers AD account

    Hello

    I would add host authorization for a specific to about 100 guests ESXi AD account.

    I could add the authorization for a single host.

    SE connect-VIServer ESXihostname

    New-VIPermission-role role - main ADAccountname - entity ESXhostname

    Disconnect VIServer ESXihostname

    Now I need to run this in a loop of 100 servers

    Help, please.

    You can try with the SDK method?

    $esxName = "MyEsx".

    $adName = "domain\user".

    $roleName = "Admin".

    $esx = get-VMHost-name $esxName

    $authmgr = get - see $esx. ExtensionData.Client.ServiceContent.AuthorizationManager

    $perm = new-Object VMware.VIM.Permission

    $perm. Main = $adName

    $perm.group = $false

    $perm.propagate = $true

    $perm. RoleId = $authmgr. RoleList | where {$_.} Name - eq $roleName} | Select - ExpandProperty RoleId

    $authmgr. SetEntityPermissions($esx.) ExtensionData.MoRef, $perm)

  • After joining the Server Appliance Center virtual domain, you can see domain when you add permissions user

    Hello

    Help, please!

    section of the knowledge base on the particular issue is not the problem.

    Just deployed the vCSA 5.5 and joined to a Windows domain but I do not see the field to add AD groups because in my view, there is a question hour DST GMT.

    My domain controller Windows are running in UTC with Daylight Saving Time (UTC).  IM in the United Kingdom.

    If I connect directly to an ESXI host using the vSphere Client - time is correct and shows "the dates and times of hospitality have been translated into the local time of the vSphere Client.


    If I run the command on the Console of the vCSA date, time is one hour behind so out of sync with the domain controllers.  If it was winter, probably all work.


    No idea how to fix this?


    Thanks in advance.

    Can confirm you that you have done the following:

    • Join vCenter Server Appliance to the domain, i.e. the AD object is created in the "Computers" OR
    • Add the AD as an additional Source of identity domain using "Active Directory (Windows integrated authentication)"

    and you can not yet select the domain in the drop-down box when you try to configure permissions?

    André

  • Best way to add permissions to a shared data store?

    I have an application (Replay), who must be able to restore a computer to an ESX virtual.  She is aware of vCenter and uses it to identify hosts and data warehouses, but he wants then SSH to that host, mkdir on a data store directory, then copy the vm disk data.  Operations of connection and files are unattended.


    I created a user on a host ESX 4.1 but that the user has no rights to create a directory on the data store.  I want to be careful to apply permissions because this data store is shared storage between this group and there are production virtual machines running on it.  I don't want to enable the root user access SSH and I don't want the root password is known other demand for proofreading business owners.

    I already tried to add this new user directly on the host, allowing SSH access to it, adding that user to the Administrator role on the ESX using the vSphere client.  I thought that would be enough to allow file operations, but when the user account wants to mkdir there is an access denied error.

    Can anyone recommend a solution?

    Thank you

    Scott

    I would check your permissions on the host computer by using 'su - username'.  Once you are connected as long as user, try to create a directory in the subdirectory appropriate off/vmfs/volumes.

    If it fails, look this user permissions in the folder datastore ("/ vmfs/volumes/datastorename he 's").  In my case, all files owned by user root and group root.  However, by default, permissions are 755 therefore belonging to a group of "root" will not help because the members of the group is not write.  If you can, I test this on a non-essential data store and change the permissions of the directory data store itself be 775 (rwxrwxr-x).

    In addition, if the default group for the user is not root, but users or something else, the new directories in the data store will be created with a bad group membership unless you change the variables in the shell of the user.  I simplify this by ensuring that the default group for the user is 'root '.

    I don't think your NFS here login account.  The data store is read/write to this host and guests and the locking takes place on a basis by the host to the data store subdirectory level.

    I hope this helps.

  • IDM cc add on HELP

    IDM cc version add ons competable in firefox v33.0 android help

    IDM requires Windows and won't work on Android.

  • How can I get rid of iminet icon taskbar, no help and not in Add/Remove HELP either, System Restore

    Help system, no help to restore and not in Add/Remove of either, it's in my taskbar.

    Hi richardwaldrip,

    Thanks for posting in the Microsoft community! If I understand correctly you want to remove application IMinent.

    What happens when you try to uninstall IMinent request for Add/Remove programs?

    Method 1
    I suggest you to run the fixit from the following link:

    Solve problems with programs that cannot be installed or uninstalled
    http://support.Microsoft.com/mats/program_install_and_uninstall

    Method 2
    Try the steps from the following link:

    How to manually remove programs from the add tool / remove programs
    http://support.Microsoft.com/kb/314481

    Note: To do: Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base: 322756 (http://support.microsoft.com/kb/322756/) how to back up and restore the registry in Windows

    Hope this information is helpful and let us know if you need more assistance. We will be happy to help.

  • vSphere Management Assistant - add users - help please

    I'm looking to set up the vMA to use other accounts of users more I have not use Active Directory to Microsoft, will create local accounts on vMA and give permissions on the file sudo.

    Someone did he do this type of configuration that could help me in this procedure?

    Thank you!

    Possible Yes... follow it

    VMware VMA customization 5 | timcarr.NET

  • Unable to add permissions to user AD

    Hello

    I use VMware Vcenter Standard 5.0

    and if it was configured with AD, but now when I search for a user (when adding permissions) I get the following error

    Call "UserDirectory.

    RetrieveUserGroups 'to object 'UserDirectory"on vCenter Server 'Vcenterservername.domainname.local' failed."

    I do not know I did something wrong somewhere and I was hoping if anyone can me as how to solve this thank you!

    BTW, people can still whit thin connection their AD accounts and permisions them existing are always applied, I can't currently add now permisions.

    Hello and welcome to the Forums!

    See if the item is useful

    http://KB.VMware.com/kb/1027107

  • Shell ESX or MS Powershell script to add permissions to the user host account

    I have this command "Add a user" ESX 3.5 service console...

    CD/usr/sbin /.

    adduser-l user-p password u 502

    You know the command to give this user 'Read only' "permissions" of the "ESX Server"?

    The attachment shows where the permissions of the user (in this case Akorri) have been added to the GUI of the VIC connected to the ESX host.

    Even better... You have a PowerShell Script to add users and permissions?

    Hello

    You must use a shell script to modify the etc/vmware/hostd/authorization.xml file. I have yet to see a powershell script that can make these changes for you, but you could check in PowerGUI.

    Best regards
    Edward L. Haletky
    VMware communities user moderator, VMware vExpert 2009
    ====
    Author of the book ' VMWare ESX Server in the enterprise: planning and securing virtualization servers, Copyright 2008 Pearson Education.
    Blue gears and SearchVMware Pro items - top of page links of security virtualization - Security Virtualization Round Table Podcast

  • How to add the help text to the tabular columns?

    I have some tabular forms. I want to add help to the header of the column.
    APEX allows you to add page elements helping, but I don't see the option for the tabular columns. No idea/solution workaround?

    Thank you

    Hello

    I have a sample how to add Help ToolTip to the header of the report
    http://ActioNet.homelinux.NET/HTMLDB/lspdemo?p=63

    Mouse over the title, and see you help text.
    See this post for instructions
    Add help text

    PS: I think you can do better solution for example using dynamic action

    Kind regards
    Jari

    http://dbswh.webhop.NET/dbswh/f?p=blog:Home:0

  • How to add context help text to node in property of an XControl?


    Hi Vsh,

    You can set the contextual help of property by right clicking on the xcontrol in your Project Explorer, select Properties, selecting the 'Settings for' category and clicking on the property that you want to write help for.  You will see a box titled 'Description' on the right;  This is where the contextual help is defined.

    I would like to know if you have trouble finding it.

  • Add description/help to the entries in the list on a white page

    Hi all

    I'm on a white page, show 3 entries in the list, for each I want to associate a description/help for them. This help/description text should be non-interactive (no hyperlink) and preferably in a different font color. I tried to change the value of the label, but that doesn't help me, as all the text becomes clickable. Help, please

    Thank you
    Mary

    Hello

    Ok...

    1 - first of all, I created a new list template (through the shared components, lists) based on a copy of the existing model "Vertical unordered list with bullets" - I called a "vertical non ordered list» new with chips with comments I changed only TWO parameters in this new model:

    Current model list:

    <li><a href="#LINK#">#TEXT#</a> <span style="color:red">#A01#</span></li>
    

    Model list associated:

    <li><a href="#LINK#" style="color:#A01#">#TEXT#</a> <span style="color:red">#A01#</span></li>
    

    2 - I've updated my entries of the list to include text in the 'User-defined attributes' parameter number 1

    3 - I have edited the list definition to use my new model

    4. I also made sure my region of the page that contains the list using this new model - either by setting the model list to substitute "- use of the list template -" or "vertical unordered list with bullets with comments.

    And that's all I've done

    Andy

  • Help! I upgraded Incredimail and now, I got hurndreds, no, thousands of e-mail adds. Help!

    How to stop hundreds of spam ads?

    How to stop hundreds of spam ads?

    So, since this is not a Microsoft product, check with the support of Incredimail or their forums.

Maybe you are looking for