set-QADUser Question Help

Anybody know how to use Replace with set-QADUser?

Trying to switch email suffix on users through a workflow. 

$workflow.ActivityTarget("CreateDev511Account") is the name of the activity target. The workflow creates a user earlier with the old email suffix copied from other domain, but then this script further down the workflow would fix the suffix while keeping the name prior to the @.

Example myname@oldEmail.com to myname@NewEmail.com.

Something like this.

Set-QADUser $workflow.ActivityTarget("CreateDev511Account").get("distinguishedName") -email replace('@oldEmail.com', '@NewEmail.com')

I am not doing the Replace correctly and it is not working for me...

Parents
  • What property are you actually trying to change?

    Are these users mail or mailbox enabled?

    "Normally", you would change the primary e-mail address by manipulating the proxyaddresses property - i.e. by setting a new Primary SMTP address.

    Also, are you trying to use a Search Activity to find the users?

    Need a bit more detail on what you are trying to accomplish and your current approach.

Reply
  • What property are you actually trying to change?

    Are these users mail or mailbox enabled?

    "Normally", you would change the primary e-mail address by manipulating the proxyaddresses property - i.e. by setting a new Primary SMTP address.

    Also, are you trying to use a Search Activity to find the users?

    Need a bit more detail on what you are trying to accomplish and your current approach.

Children
  • The workflow takes a user that was chosen from the ARS Website to clone it to another managed domain. I setup a form for this. It keeps much the same but needs to change the email suffix to the new domain. No mailbox is being setup on the second account in the target domain but I do need the mail attribute populated. All this works but trying to run the script command mentioned to switch the mail suffix in the MAIL attribute of the user. in regular powershell you can replace text but it is not working with set-QAduser.

  • Figured it out. This is what I did.

    function UpdateMail($Request)

    {
    $UserDN = Get-QADUser $workflow.ActivityTarget("CreateDevAccount").get("distinguishedName")
    $UserMailOld = Get-QADUser -Identity $UserDN -Properties * | select mail
    $UserMailNew = $UserDN.mail.Replace('@oldMail.com', '@newMail.com')
    Set-QADUser $UserDN -mail $UserMailNew

    }