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)] [OutputType([PSCustomObject])] param ( # The Exchange Online User. [Parameter(Mandatory=$true, ValueFromPipeline=$true)] [ValidateNotNull()] [PSCustomObject]$user ) # Create the MSPComplete user object $mspCompleteUser = [PSCustomObject]@{} # Retrieve the mapping from MSPComplete user to Exchange Online user properties $propertyMap = Get-MSPCompleteUserToExchangeOnlineUserPropertyMap # Add all properties to the MSPComplete user foreach ($property in $propertyMap.GetEnumerator()) { if (![String]::IsNullOrWhiteSpace($user.($property.Value))) { $mspCompleteUser | Add-Member -NotePropertyName $property.Key -NotePropertyValue $user.($property.Value) } } # Retrieve the map from MSPComplete user extended properties to Exchange Online user properties $extendedPropertyMap = Get-MSPCompleteUserToExchangeOnlineUserExtendedPropertyMap # Convert the extended properties to the MSPComplete user $mspCompleteUser | Add-Member -NotePropertyName "ExtendedProperties" -NotePropertyValue @{} foreach ($property in $extendedPropertyMap.GetEnumerator()) { if (![String]::IsNullOrWhiteSpace($user.($property.Value))) { $mspCompleteUser.ExtendedProperties.Add($property.Key, $user.($property.Value)) } } # Return the converted user return $mspCompleteUser } |