Functions/ConvertTo-MSPCompleteUserForm.ps1
<#
.SYNOPSIS This function converts a user from a different environment to a MSPComplete user. .DESCRIPTION This function converts a user from a different environment to a MSPComplete user. The conversion is done by mapping the other user to the MSPComplete user's properties and extended properties. #> function ConvertTo-MSPCompleteUserForm { param ( # A user from Exchange Online [Parameter(Mandatory=$true, ParameterSetName="ExchangeOnline")] $exchangeOnlineUser ) if ($PSCmdlet.ParameterSetName -eq "ExchangeOnline") { # Retrieve mapping from MSPComplete user to Exchange Online user properties $propertyMap = Get-MSPCompleteUserToExchangeOnlineUserPropertyMap # Create MSPComplete user $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 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 } |