Functions/Data/Format-UPN.ps1
Function Format-UPN { [CmdletBinding()] Param ( # Incoming Username to Reformat [Parameter(Mandatory=$True,ValueFromPipeLine = $true)] [String] $Username ) Process { # Derive Outgoing UPN $OutUserName = if ($Username -like "*\\*") { $UNSplit = $Username -split '\\' "$($UNSplit[0])@$($UNSplit[-1])" } elseif ($Username -like "*_*") { $Username -replace "_","@" } # Return Outgoing UPN $OutUserName } } |