Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How to pass an input file to a powershell script which makes changes to AD attributes:

$
0
0

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()
}


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>