Functions/Convert-ExchangeOnlineUserToMSPCompleteUser.ps1
<#
.SYNOPSIS This function converts an Exchange Online user to a MSPComplete user. .DESCRIPTION This function converts an Exchange Online user to a MSPComplete user. The conversion is accomplished by mapping the Exchange Online user's properties and extended properties to their corresponding MSPComplete properties. #> function Convert-ExchangeOnlineUserToMSPCompleteUser { [CmdletBinding(PositionalBinding=$true)] param ( # The Exchange Online User [Parameter(Mandatory=$true)] [ValidateNotNull()] $user ) # Retrieve the mapping from MSPComplete user to Exchange Online user properties $propertyMap = Get-MSPCompleteUserToExchangeOnlineUserPropertyMap # Create MSPComplete user object $mspCompleteUser = [PSCustomObject]@{} # Add all properties to the MSPComplete user foreach ($property in $propertyMap.GetEnumerator()) { if (![String]::IsNullOrWhiteSpace($exchangeOnlineUser.($property.Value))) { $mspCompleteUser | Add-Member -NotePropertyName $property.Key -NotePropertyValue $exchangeOnlineUser.($property.Value) } } # Retrieve the mapping from MSPComplete user to Exchange Online user extended properties $extendedPropertyMap = Get-MSPCompleteUserToExchangeOnlineUserExtendedPropertyMap # Add all extended properties to the MSPComplete user $mspCompleteUser | Add-Member -NotePropertyName "ExtendedProperties" -NotePropertyValue @{} foreach ($property in $extendedPropertyMap.GetEnumerator()) { if (![String]::IsNullOrWhiteSpace($exchangeOnlineUser.($property.Value))) { $mspCompleteUser.ExtendedProperties.Add($property.Key, $exchangeOnlineUser.($property.Value)) } } # Return the MSPComplete user return $mspCompleteUser } |