I am using the below script to make changes to a mail attribute in AD. At the moment, the script takes input from a ldap query. I would like to change it to an input file containing email addresses. In the below script, I am not using get-mailbox command let to disable email address policies on mailboxes because it wont work for those mailboxes which have aliases in an incorrect format. Please assist.
$strFilter = "(&( msexchhomeservername=/o=Messaging/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=Exchangeserver1))"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{
$objItem = $objResult.GetDirectoryEntry()
$objitem.putex(1,"msexchpoliciesincluded",$null)
$objitem.setInfo()
}