TechnoGist

gist (jst)# The central idea; the essence…

Archive for the ‘LDAP’ tag

Disconnected Mailboxes in Exchange 2003

without comments

I was looking into finding all disconnected/orphaned mailboxes in an Exchange2003 org. Normally I would use either an old VBScript I have or the Exchange 2003 ESM. I thought it would be good to experiment with PowerShell and try to simplify the VBScript that I have.

Below is a PowerShell script that utilizes ADSI to gather all Exchange 2003 servers in your configuration container. Then for each server it utilizes WMI to connect to the Root/MicrosoftExchangeV2 ‘NameSpace’ and the Exchange_Mailbox provider. From there we filter on only mailboxes that the “DateDiscoveredAbscentInDS” property is NOT NULL. That data is then passed through the pipeline to a Select-Object where a custom Hash table is built to display the Server Name of the filtered mailboxes. The filtered mailboxes and the selected data is then passed through the pipeline and exported to a .csv file on the root of C:\ named with the format C:\DisconnectedMailboxes_%Servername%.csv.

Code:

[String]$StrFilter = "(objectCategory=msExchExchangeServer)"
$objRootDSE = [ADSI]"LDAP://RootDSE"
[String]$strContainer = $objRootDSE.configurationNamingContext
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-object System.DirectoryServices.DirectoryEntry("LDAP://$strContainer")
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
ForEach ($objResult in $colResults) {
[String]$ServerDN = $objResult.Properties.distinguishedname
$objServer = [ADSI]"LDAP://$ServerDN"
[String]$Server = $objServer.cn
Get-WmiObject -NameSpace Root\MicrosoftExchangeV2 -Class Exchange_Mailbox -Computer $Server | `
Where { $_.DateDiscoveredAbsentInDS -ne $null } | `
Select-Object @{N="Server";E={$_.__Server}},`
StorageGroupName,StoreName,MailboxDisplayName,Size,DateDiscoveredAbsentInDS | `
Export-Csv "C:\DisconnectedMailboxes_$Server.csv" -NoTypeInformation
}#End ForEach

Hope this helps.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Written by Paul Brice

August 19th, 2009 at 10:56 pm

Getting Proxy Addresses from an AD User Object

without comments

In Active Directory a user object can hold multiple “Proxy” addresses.
Using ADSI and LDAP the PowerShell script below enumerates all .proxyaddresses from a specific Active Directory user object.

This scripting technique can be used to get any Active Directory user object attributes.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Written by Paul Brice

April 10th, 2009 at 3:55 pm

Posted in PowerShell

Tagged with , , , ,

Converting .diasplayName to .cn User object attributes

without comments

I routinely have to populate Active Directory Email distribution lists from lists of employee full names. These list usually contain the “.displayName” of the user. A quick way to resolve this is to convert the “.displayName” of the user into the users common name or “.cn” attribute and cut/paste them into the distribution lists “Members” box. I put the list of users display names into a C:\Scripts\Users.txt file and the script will produce a list of .cn attribute in the C:\Scripts\ConvertedUsers.txt file.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Written by Paul Brice

April 9th, 2009 at 1:33 pm

Posted in PowerShell

Tagged with , , , , , ,

All Exchange Server Objects from Active Directory

without comments

Many of the PowerShell scripts that I write are for Exchange 2003. To keep the scripts as dynamic as possible I like to enumerate my servers from AD. The server objects for Exchange are held in the Configuration partition of the AD Schema.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Written by Paul Brice

April 8th, 2009 at 9:41 pm