Save the proxyaddresses attribute of users

The PowerShell scripts below allow for the backup of the content of the proxyaddresses attribute of Active Directory users

Backup

#
#	@author: Romain
#	@Description : Exporte le champs proxyAddresses des utilisateurs de l'OU cible $contactou
#	@website : https://rdr-it.com
#	@original source : https://241931348f64b1d1.wordpress.com/2015/10/21/how-to-dump-users-proxyaddresses-attribute-with-powershell/ 
#
ipmo activedirectory
cls 
cd C:\
$contactou = "OU=users ,DC=mondomaine,DC=intra"
$datesuffix = get-date -Format yyy-MM-dd_HHmmss
 
$allcontacts = get-adobject -filter {objectclass -eq "user" } -searchbase $contactou -property DistinguishedName,ObjectGUID,proxyaddresses
 
$allcontacts | select DistinguishedName,ObjectGUID,@{Name='proxyAddresses';Expression={[string]::join(";", $($_.proxyAddresses))}} | export-csv -delimiter ";" -notype alldominocontacts_$($datesuffix).csv
Write-Host "-----------------"
Write-Host "Export termine"

Restore

#
#	@author: Romain 
#	@Description : Import proxyAddresses
#	@website : https://rdr-it.com
#	@original source : https://241931348f64b1d1.wordpress.com/2015/10/21/how-to-dump-users-proxyaddresses-attribute-with-powershell/ 
#
cls
$contactou = "OU=users ,DC=mondomaine,DC=intra"
cd C:\
Import-Csv "alldominocontacts.csv" -delimiter ";" | ForEach-Object{
    $guid = $_.ObjectGUID
    $proxyAddresses = $_.proxyaddresses -split ';'
     
    $find = Get-ADObject -filter {(objectGUID -eq $guid)} -searchbase $contactou -Properties Name,ProxyAddresses
    Write-Host "Utilisateur:"
    Write-Host $find.Name
    Write-Host "Current ProxyAddresses:" $find.proxyaddresses
    Write-Host "Old ProxyAddresses    :" $proxyAddresses
    Set-ADObject -Identity $guid -Replace @{proxyAddresses=$proxyAddresses}    
    Write-Host "-----------------"
    Write-Host
}



Comments are not currently available for this post.