src/Upn2Mail.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function Set-SkolniLoginUpn2Mail {
    [CmdletBinding()]
    param (
        [Parameter(ValueFromPipeline, Mandatory = $true)]
        $User
    )
    process {
        Write-Debug "Setting UPN to mail field for $($User.sAMAccountName)"
        
        $upn = $User.UserPrincipalName
 
        $User | Set-ADUser -Replace @{mail = $upn}
    }
}