Hi. I need to give permissions to an account to execute commandlets:
Set-CASMailbox -Identity $username -ActiveSyncBlockedDeviceIDs @{ add = $deviceId }
Get-MobileDeviceStatistics -Mailbox $username
Remove-MobileDevice -Identity $id -Confirm:$false
Set-CASMailbox -Identity $username -ActiveSyncAllowedDeviceIDs @{ add = $deviceId }
Search for a role that has these commandlets:
PS C:\Windows\system32> Get-ManagementRole -Cmdlet Set-CASMailbox
Name RoleType
---- --------
Organization Client Access OrganizationClientAccess
Mail Recipients MailRecipients
HelpDesk User Management Tool MailRecipients
MobileDevice Management MailRecipients
MyBaseOptions MyBaseOptions
User Options UserOptions
Exchange Virtual Directories ExchangeVirtualDirectories
PS C:\Windows\system32> Get-ManagementRole -Cmdlet Get-CASMailbox
Name RoleType
---- --------
View-Only Recipients ViewOnlyRecipients
Mail Recipients MailRecipients
HelpDesk User Management Tool MailRecipients
My Custom Mailbox Recipients MailRecipients
MobileDevice Management MailRecipients
MyBaseOptions MyBaseOptions
User Options UserOptions
Recipient Policies RecipientPolicies
Organization Client Access OrganizationClientAccess
PS C:\Windows\system32> Get-ManagementRole -Cmdlet Get-MobileDeviceStatistics
Name RoleType
---- --------
View-Only Recipients ViewOnlyRecipients
Mail Recipients MailRecipients
HelpDesk User Management Tool MailRecipients
My Custom Mailbox Recipients MailRecipients
MobileDevice Management MailRecipients
MyBaseOptions MyBaseOptions
User Options UserOptions
PS C:\Windows\system32> Get-ManagementRole -Cmdlet Remove-MobileDevice
Name RoleType
---- --------
Mail Recipients MailRecipients
User Options UserOptions
HelpDesk User Management Tool MailRecipients
MobileDevice Management MailRecipients
MyBaseOptions MyBaseOptions
I've chosen Mail Recipients
My user can't change the settings: ActiveSyncBlockedDeviceIDs and ActiveSyncAllowedDeviceIDs:
A parameter cannot be found that matches parameter name 'ActiveSyncBlockedDevic
eIDs'.
+ CategoryInfo : InvalidArgument: (:) [Set-CASMailbox], Parameter
BindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Set-CASMailbox
+ PSComputerName : ms-ex05.domain.com
My script for RBAC:
$CustomGroupName = "MobileDevice Admninistrators"
$CustomRoleName = "MobileDevice Management"
$ParentRoleName = "Mail Recipients"
$userAccount = "svc_MobileAdmin"
$AllowedCmdlets = @(
"Set-CASMailbox",
"Get-CASMailbox",
"Get-MobileDeviceStatistics",
"Remove-MobileDevice"
)
New-ManagementRole -Name $CustomRoleName -Parent $ParentRoleName
Get-ManagementRoleEntry "$CustomRoleName\*"| Where-Object { $AllowedCmdlets -notcontains $_.Name } | Remove-ManagementRoleEntry -Confirm:$false
New-RoleGroup -Name $CustomGroupName -Roles $CustomRoleName -Members $userAccount
Debug:
PS C:\Windows\system32> Get-ManagementRole -Cmdlet Set-CASMailbox -CmdletParameters ActiveSyncBlockedDeviceIDs
Name RoleType
---- --------
Organization Client Access OrganizationClientAccess
PS C:\Windows\system32> Get-ManagementRole -Cmdlet Set-CASMailbox -CmdletParameters ActiveSyncAllowedDeviceIDs
Name RoleType
---- --------
Organization Client Access OrganizationClientAccess
I think I need a parent role: Organization Client Access
But there are no commandlets in this role:
Get-MobileDeviceStatistics
Remove-MobileDevice
How can I fix this so that I don't give out more rights ?