Change 2010 GAL vcard export script To spherical out the Vcard export scripts as many individuals are nonetheless working Change 2010 this is a Distant powershell script that may let you export Mailboxes (or contacts) from Energetic listing to Vcards and likewise embrace the GAL Photograph from the AD thumbnail property if set.
The script makes use of the Get-Consumer Change Administration Shell cmdlet to get all of the Mailboxes particulars to incorporate within the Vcard file and likewise use LDAP to learn the AD thumbnailPhoto (if its been set).
earlier than you run this script be sure to set the next variable to the listing you need the vcards exported to
$exportFolder = “c:temp”
You might want to run this script from throughout the Change Administration Shell or a Distant Powershell session
I’ve put a download of this script right here the code appears like
- $exportFolder = “c:temp”
- $Mailboxes = Get-Consumer -RecipientTypeDetails UserMailbox
- foreach($Mailbox in $Mailboxes){
- strive{
- $DisplayName = $Mailbox.DisplayName;
- write-host(“Processing ” + $DisplayName)
- $fileName = $exportFolder + $DisplayName + “–” + [Guid]::NewGuid().ToString() + “.vcf“
- add-content -path $filename “BEGIN:VCARD“
- add-content -path $filename “VERSION:2.1“
- $givenName = $Mailbox.FirstName
- $surname = $Mailbox.LastName
- add-content -path $filename (“N:” + $surname + “;” + $givenName)
- add-content -path $filename (“FN:” + $Mailbox.DisplayName)
- $Division = $Mailbox.Division;
- add-content -path $filename (“EMAIL;PREF;INTERNET:” + $Mailbox.WindowsEmailAddress)
- $CompanyName = $Mailbox.Firm
- add-content -path $filename (“ORG:” + $CompanyName + “;” + $Division)
- if($Mailbox.Title -ne ““){
- add-content -path $filename (“TITLE:” + $Mailbox.Title)
- }
- $Nation = ““
- $Metropolis = ““
- $Road = ““
- $State = ““
- $PCode = ““
- if($Mailbox.Metropolis -ne ““){
- $Metropolis = $Mailbox.Metropolis
- }
- if($Mailbox.StateOrProvince -ne ““){
- $State = $Mailbox.StateOrProvince
- }
- if($Mailbox.StreetAddress -ne ““){
- $Road = $Mailbox.StreetAddress
- }
- if($Mailbox.CountryOrRegion -ne ““){
- $Nation = $Mailbox.CountryOrRegion
- }
- if($Mailbox.PostalCode -ne ““){
- $PCode = $Mailbox.PostalCode
- }
- $addr = “ADR;WORK;PREF:;” + $Nation + “;” + $Road + “;” +$Metropolis + “;” + $State + “;” + $PCode + “;” + $Nation
- add-content -path $filename $addr
- if($Mailbox.MobilePhone -ne ““){
- add-content -path $filename (“TEL;CELL;VOICE:” + $Mailbox.MobilePhone)
- }
- if($Mailbox.Cellphone -ne ““){
- add-content -path $filename (“TEL;WORK;VOICE:” + $Mailbox.Cellphone)
- }
- if($Mailbox.Fax -ne ““){
- add-content -path $filename (“TEL;WORK;FAX:” + $Mailbox.Fax)
- }
- if($Mailbox.HomePhone -ne ““){
- add-content -path $filename (“TEL;HOME;VOICE:” + $Mailbox.HomePhone)
- }
- if($Mailbox.WebPage -ne ““){
- add-content -path $filename (“URL;WORK:” + $Mailbox.WebPage)
- }
- Strive{
- $sidbind = “LDAP://<SID=” + $Mailbox.Sid + “>“
- $userObj = [ADSI]$sidbind
- $photograph = $userObj.thumbnailPhoto.worth
- if($photograph -eq $null){“No Photograph“}
- if($photograph -ne $null){
- add-content -path $filename “PHOTO;ENCODING=BASE64;TYPE=JPEG:“
- $ImageString = [System.Convert]::ToBase64String($photograph,[System.Base64FormattingOptions]::InsertLineBreaks)
- add-content -path $filename $ImageString
- add-content -path $filename “`r`n”
- }
- }
- catch{
- }
- add-content -path $filename “END:VCARD“
- “Exported ” + $filename
- }
- catch{
- }
- }