Public/Get-ADPMobilePhone.ps1
function Get-ADPMobilePhone { <# .SYNOPSIS Get a user's Mobile Phone from ADP .DESCRIPTION Get a user's Mobile Phone from ADP .PARAMETER ADPObject Object which holds the Mobile Phone .EXAMPLE Input Object: ADP Object Return String: <Mobile Phone> .NOTES This is used when passing the full adp worker object from ADP's APID .FUNCTIONALITY Powershell Language #> [CmdletBinding()] param ( [Parameter( Mandatory = $true, Position = 0, ValueFromPipeline = $true )] $ADPObject ) $localCountry = ( $ADPObject | Get-ADPLocation ).country $areaCode = $null $dialNumber = $null $finishedNumber = $null if ($ADPObject.person.communication.PSobject.Properties.Name -contains "landlines") { $areaCode = $ADPObject.person.communication.landlines.areaDialing $dialNumber = $ADPObject.person.communication.landlines.dialNumber } if ($ADPObject.person.communication.PSobject.Properties.Name -contains "mobiles") { $areaCode = $ADPObject.person.communication.mobiles.areaDialing $dialNumber = $ADPObject.person.communication.mobiles.dialNumber } if ($areaCode) { $areaCode = $areaCode.Trim() } if ($dialNumber) { $dialNumber = $dialNumber.Trim() } if ($areaCode -and $dialNumber) { switch ($localCountry) { "DE" { $finishedNumber = "$areaCode.$dialNumber"; break } "IN" { $finishedNumber = "$areaCode.$dialNumber"; break } default { $finishedNumber = "$areaCode$dialNumber".Insert(3, '.').Insert(7, '.') } } } return ( $finishedNumber | Get-ValidADPReturn ) } |