Script: PowerCLI – Create Citrix Permission Role

function Create-VICitrixRole {
    param (
        [parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()][string]$vcenter,
        [parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()][string]$rolename
        )
    Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
    $vcConnection = Connect-VIServer -Server $vCenter -ErrorAction Stop
    $permissions =@()
    $permissions += "Datastore.AllocateSpace"
    $permissions += "Datastore.Browse"
    $permissions += "Datastore.FileManagement"
    $permissions += "Network.Assign"
    $permissions += "Resource.AssignVMToPool"
    $permissions += "System.Anonymous"
    $permissions += "System.Read"
    $permissions += "System.View"
    $permissions += "VirtualMachine.Config.AddExistingDisk"
    $permissions += "VirtualMachine.Config.AddNewDisk"
    $permissions += "VirtualMachine.Config.AddRemoveDevice"
    $permissions += "VirtualMachine.Config.AdvancedConfig"
    $permissions += "VirtualMachine.Config.CPUCount"
    $permissions += "VirtualMachine.Config.EditDevice"
    $permissions += "VirtualMachine.Config.Memory"
    $permissions += "VirtualMachine.Config.RemoveDisk"
    $permissions += "VirtualMachine.Config.Settings"
    $permissions += "VirtualMachine.Interact.PowerOff"
    $permissions += "VirtualMachine.Interact.PowerOn"
    $permissions += "VirtualMachine.Interact.Reset"
    $permissions += "VirtualMachine.Interact.Suspend"
    $permissions += "VirtualMachine.Inventory.Create"
    $permissions += "VirtualMachine.Inventory.CreateFromExisting"
    $permissions += "VirtualMachine.Inventory.Delete"
    $permissions += "VirtualMachine.Provisioning.Clone"
    $permissions += "VirtualMachine.Provisioning.CloneTemplate"
    $permissions += "VirtualMachine.Provisioning.DeployTemplate"
    $permissions += "VirtualMachine.State.CreateSnapshot"
    New-VIRole -name $rolename -Privilege (Get-VIPrivilege -Server $vcenter -id $permissions) -Server $vcenter
    }

Import-Module -Name VMware.VimAutomation.Core
Create-VICitrixRole -vcenter "vsphere.domain.local" -rolename "CITRIX_VAD"