Scenario – You want to see what Management Roles and Commands a user can run from Exchange PowerShell
Scriptlet:
#Determine management role assignments for an account
$1= Get-ManagementRoleAssignment -RoleAssignee <username>
$1 | Select Role
#Determine what commands are associated with that account
#For a Single Role
Get-ManagementRole Monitoring | FL
Get-ManagementRole Monitoring | Select -ExpandProperty RoleEntries | Select Name
Get-ManagementRole Monitoring | Select -ExpandProperty RoleEntries |Sort Name | Select name
#For Multiple Roles from $1
$Roles = @()
$1.role.name | %{
$n = $_
$temp = Get-managementrole $n | Select -ExpandProperty RoleEntries |Sort Name | Select -expandproperty name
$temp | %{
$c = $_
$ServerObj = New-Object PSObject
$ServerObj | Add-Member NoteProperty -Name “ManagementRole” -value $n
$ServerObj | Add-member NoteProperty -Name “Command” -Value $c
$Roles += $ServerObj
}
$n = $null
$c = $null
}
#Display $roles
$roles | Sort Command | Select Command, ManagementRole