Functions/Get-MsolRoleMembers.ps1
function Get-MsolRoleMembers { [CmdletBinding()] param ( # [Parameter(Mandatory)] [string] $ParameterName ) Write-Verbose "Loading Users" $AllUsers = Get-MsolUser -All $Result = @() $Roles = Get-MsolRole | Sort-Object Name foreach ($Role in $Roles) { $i++ Write-Verbose "Get Role Member $($Role.Name) ($($i))" Get-MsolRoleMember -RoleObjectId $Role.ObjectId | Sort-Object DisplayName | ForEach-Object { $CurrentUser = $AllUsers | Where-Object ObjectId -eq $_.ObjectId $obj = [PSCustomObject]@{ RoleName = $Role.Name RoleId = $Role.ObjectId UserDisplayName = $_.DisplayName UserEmailAddress = $_.Emailaddress UserBlocked = $CurrentUser.BlockCredential } $Result += $obj } } return $Result } |