Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Get-Movestatus by users active directory attribute

$
0
0

Hi all,

for monitoring of Mailbox Migration I have to check an attribute called 'msExchMailboxMoveStatus' in active directory. I try to get a powershell script which can read the email addresses of users from a csv file. The script should writte the results in a txt or csv file. How can I do that?

I've got a VB script here as an example for this job.

The powershell script will start like this:

###############################################################
# Extractemployee_v1.0.ps1
# input : n/a
# output : none (logs)
# Version 1.
# Changelog : n/a
# MALEK Ahmed - 08 / 08 / 2013
###################

##################
#--------Config
##################
$adPath="LDAP://DC=contoso,DC=msft"
##################
#--------Main  
##################
#LDAP connection
$objDomain=New-Object System.DirectoryServices.DirectoryEntry($adPath)
#Doing an LDAP search
$ObjSearch=New-Object System.DirectoryServices.DirectorySearcher($ObjDomain)
Import-Csv .\input.csv -Delimiter ';' | Foreach-Object {
$ObjSearch.Filter = "(&(objectCategory=person)(objectClass=user)(mail=" + $_.mail + "))"
$allSearchResult = $ObjSearch.FindAll()
foreach ($objSearchResult in $allSearchResult)
	{
        	$objUser=New-Object System.DirectoryServices.DirectoryEntry($objSearchResult.Path)
		$content = "" + $objUser.mail + ";" + $objUser.msExchMailboxMoveStatus + ""
		Add-Content .\output.csv $content
	}
}

The ps script ends with following error message:

+ foreach <<<<  ($objSearchResult in $allSearchResult)
    + CategoryInfo          : InvalidOperation: (System.Director...sultsEnumerator:ResultsEnumerator) [], RuntimeException
    + FullyQualifiedErrorId : BadEnumeration

And the input.csv file looks like this:

mail
john.do@contoso.msft

Thanks for any help,


Soheil

See also: http://social.technet.microsoft.com/Forums/windowsserver/en-US/2d085093-d6a7-4b1c-9248-8b7d49528784/getmovestatus-by-users-active-directory-attribute

Viewing all articles
Browse latest Browse all 21975

Trending Articles



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