Hi
I am trying to write an all singing and dancing script in power shell at the moment to process leavers, ie disable the user, change the OU to leavers, remove group memberships, set mail forwarding. The problem I am getting is I need to reset the users password in order to set their Out Of Office as only the mailbox owner has permissions to do this.
The relevant code from the script I am writing to this issue is
#Get full name of user to work with
$cname = Read-Host "Enter Full Name of Leaver"
#Create ADSI Connection
$userAD = [ADSI]"LDAP://CN=$cname,OU=Users,OU=London,DC=MYDOMAIN,DC=MYTLD"
#Reset Users Password to Printer123
$userAD.Invoke("setpassword","Printer123")
Now if I run this code from my desktop it runs fine but If I run it from the exchange server I get the following error:
Exception calling "Invoke" with "2" argument(s): "Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERN
OTFOUND))"
At line:1 char:15
I have to run this script from the exchange server for the OOF setting script to work so really need to get this going.
Anyone got any ideas |