Get-MSOLUserWithValidationError

I sometimes find that the validation error detail in the portal is less than helpful, and getting the verbiage from powershell can be a bit tricky, so I wrote the following Powershell function that will output all the Azure objects with a more human-readable version of the validation errors for each account…

 

function Get-MSOLUserWithValidationError

 

{

$usererr = Get-MsolUser -HasErrorsOnly

Foreach ($user in $usererr) {

    Write-output $user.UserPrincipalName;

    "Service: "+ $user.Errors.ErrorDetail.Name.split("/")[0]; "Error Message: "+ $user.Errors.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription +"`n"

    }

}

# END FUNCTION Get-MSOLUserWithValidationError