Eposta hesaplarını export etme

Exchange Server üzerinde tanımlı olan eposta hesaplarının hepsini csv dosyasına export edebilirsiniz. Yapmanız gereken aşağıda verdiğim iki farklı kodu, Exchange Server versiyonunuza göre powershell üzerinde çalıştırmak.

Exchange 2007 yada Exchange 2010

Get-Mailbox -ResultSize Unlimited |Select-Object displayname,PrimarySmtpAddress | export-csv c:\mail_list.csv

Exchange 2003

‘***************************************************************** ’Exchange users listesi’ Ozgur Ozocak’ info@teknolojikadam.com’ 24 Nisan 2012? ‘***************************************************************** Option Explicit Dim StartTime,EndTime: StartTime = Now ’ For seeing how long the script takes to run Dim objShell Dim objFSO Const ScriptVersion = “1.01? Set objShell = WScript.CreateObject(“WScript.Shell”) Set objFSO = CreateObject(“Scripting.FileSystemObject”) Wscript.Echo “StartTime = ” & StartTime ‘ ***************************************************************** ’ Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim objRootDSE Dim objDomain Dim objContainer Dim objOrganizationalUnit Dim strOutputFileName, objOutputFileName, GarbageRC Dim intUserObjectCountAll, intUserObjectCountSelected strOutputFileName = “GAL_Export.csv” Set objOutputFileName = objFSO.OpenTextFile(strOutputFileName, ForWriting, True) intUserObjectCountAll = 0 intUserObjectCountSelected = 0 Set objRootDSE = GetObject(“LDAP://RootDSE”) Set objDomain = GetObject(“LDAP://” & objRootDSE.Get(“DefaultNamingContext”)) Call Sub_EnumOUs(objDomain.ADsPath) Sub Sub_EnumOUs(sADsPath) Set objContainer = GetObject(sADsPath) objContainer.Filter = Array(“OrganizationalUnit”) For Each objOrganizationalUnit in objContainer WScript.Echo “Checking OU: ” & objOrganizationalUnit.ADsPath Wscript.Echo ” User Object Count: ” & intUserObjectCountAll Sub_EnumUsers(objOrganizationalUnit.ADsPath) Sub_EnumOUs(objOrganizationalUnit.ADsPath) Next End Sub Sub Sub_EnumUsers(sADsPath) Dim objADobject Set objContainer = GetObject(sADsPath) objContainer.Filter = Array(“User”) For Each objADobject in objContainer If objADobject.Class = “user” Then intUserObjectCountAll = intUserObjectCountAll + 1 If objADobject.Mail <> “” Then objOutputFileName.Writeline(Chr(34) & objADobject.displayName & Chr(34) & “,” & objADobject.Mail) intUserObjectCountSelected = intUserObjectCountSelected + 1 End If End If Next End Sub objOutputFileName.Close ‘ ***************************************************************** ’ EndTime = Now Wscript.Echo vbCrLf & “EndTime = ” & EndTime Wscript.Echo “Seconds Elapsed: ” & DateDiff(“s”, StartTime, EndTime) Wscript.Echo “Script Complete” Wscript.Quit(0) ‘ ***************************************************************** ’