Tuesday, August 29, 2017

Validation errors for users/contacts/groups in the Office 365

Scenario:

You get something like:

Get-MsolUser -UserPrincipalName user@domain.com | fl *status*,errors
OverallProvisioningStatus : Success
ValidationStatus          : Error
Errors                    : {Microsoft.Online.Administration.ValidationError}

How to get more details about the "ValidationStatus" Error?

Solution:

for users:

$errors = (Get-MsolUser -UserPrincipalName "user@domain.com").Errors

for contacts:

$errors = (Get-MsolContact -ObjectID <Object_ID>).Errors

for groups:

$errors = (Get-MsolGroup -ObjectID <Object_ID>).Errors

and then expand $errors variable:

$errors | % {"`nService: "+ $_.ErrorDetail.Name.split("/")[0]; "Error Message: "+ $_.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription}  

Example:

$errors = (Get-MsolUser -UserPrincipalName user@domain.com).Errors

$errors | % {“`nService: ” + $_.ErrorDetail.Name.split("/")[0]; “Error Message: ” + $_.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription}

Service: exchange
Error Message: Exchange can't disable the mailbox "NAMPR07A002.prod.outlook.com/Microsoft Exchange Hosted Organizations/xxxxx.onmicrosoft.com/Soft Deleted Objects/UserNameHere" because it is on In-Place Hold.

Reference:



  • You see validation errors for users in the Office 365 portal or in the Azure Active Directory Module for Windows PowerShell
  • Monday, August 7, 2017

    Install Windows Feature with DISM (without PowerShell)

    Scenario:

    Imagine that you can't Install-WindowsFeature (Add-WindowsFeature for 2008 R2) on Windows Server using PowerShell for some reason.

    Recently I had a problem with broken WMI where I couldn't manage Windows Server features of affected server. My wish was to make Full Server backup prior to any changes with broken server using built-in "Windows Server Backup" and I couldn't install backup feature using PowerShell.

    Solution:

    DISM commands running from an Elevated Command Prompt (Admin) saved my life:
    Dism /online /enable-feature /featurename:WindowsServerBackup
     
    Deployment Image Servicing and Management tool
    Version: 6.3.9600.17031
    
    Image Version: 6.3.9600.17031
     
    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.
    Dism /online /enable-feature /featurename:WindowsServerBackupSnapin
     
    Deployment Image Servicing and Management tool
    Version: 6.3.9600.17031
     
    Image Version: 6.3.9600.17031
     
    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.
    You can install any Windows feature in similar way. Get list of all available features and their names on server:
    Dism /online /get-features /format:table | more
    References:

    WMI is broken. "Configuration refresh failed with the following error: Invalid class"

    Scenario:

    When we start Server Manager on Windows Server 2012 R2 the flag lights up "Red" almost immediately with the error:
    "Configuration refresh failed with the following error: Invalid class"


    Get-WindowsFeature could end with the same "Invalid class" error.

    Solution:

    Backup WMI:

    • Launch the WMI MMC snapin by Start -> Run -> then enter WMIMGMT.MSC
    • Right click WMI Control (Local) and click Properties
    • Tab Backup/Restore, press Back Up Now...

    Recompile .mof & .mlf files by running the following commands from an Elevated Command Prompt (Admin):
    CD C:\Windows\System32\WBEM
    dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %s in (moflist.txt) do mofcomp %s
    Refresh "Server Manager" or re-open it.

    References: