Appuyer sur "Entrée" pour passer au contenu

Sauvegarder l’attribut proxyaddresses des utilisateurs

Les scripts PowerShell ci-après permettent la sauvegardes du contenu de l’attribut proxyaddresses  des utilisateurs Active Directory

Sauvegarde

#
#	@author: Romain
#	@Description : Exporte le champs proxyAddresses des utilisateurs de l'OU cible $contactou
#	@website : http://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"

Restauration

#
#	@author: Romain 
#	@Description : Import proxyAddresses
#	@website : http://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
}