Suspend notification to manager?

Comments

20 comments

  • Avatar
    Tatiana Golubovich

    Hi Niklas,

    To automatically notify a suspended users manager you should add this code into "To" field: $(GetMailPropertyByDn -ObjectDN  $FoundObject.manager).

    To add a path to a user home folder, use this code: $FoundObject.homeDirectory

    Can you please explain, link to OneDrive site - you mean user personal site or the sites list where this user is an owner? 

    Here is the message example:

    {
    $managerName = "Manager"
    if($FoundObject.manager -ne $Null){
    $mgr = Get-ADUser -Identity $FoundObject.manager -Properties * -ErrorAction Ignore
    if($mgr -ne $Null){
    $managerName = $mgr.DisplayName
    }
    }

    $header =
    "
    Dear $managerName<br/><br/>
    This account was suspended: $($FoundObject.givenName) $($FoundObject.sn).<br/><br/>
    "

    $body =
    "
    User home directory: $($FoundObject.homeDirectory)<br/>
    "

    $message = $header + $body
    $message
    }.InvokeReturnAsIs()

    Tatiana

     

     

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    Hi, Tatiana!

     

    The link to OneDrive that I referred to is this
    companyxxxx-my.sharepoint.com/personal/xxxxxx_xxxxxx_munters_se/_layouts/15/onedrive.aspx

    Best regards

    Niklas

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    So, companyxxxx - xxxx is this company name?

    xxxxxx_xxxxxx - user first name and last name?

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    Yes, mine looks like this

    munters-my.sharepoint.com/personal/niklas_myrnas_munters_se/_layouts/15/onedrive.aspx

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Niklas, 

    For OneDrive please try this: 

    $UserURL= "https://$((CayoGetMsolAccountSku))-my.sharepoint.com" + "/personal/$($FoundObject.UserPrincipalName.Replace("@","_").Replace(".","_"))/"

     

    Tatiana

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    Hi

    When testing I get this error:

    Cannot process command because of one or more missing mandatory parameters: To.


    It seems to be something wrong with this- $(GetMailPropertyByDn -ObjectDN $FoundObject.manager)

     

    Best regards

    Niklas

     

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Hi Niklas, 

     

    Please check that the suspended user has a manager otherwise there is nobody in To, email can't be sent and you get this error. Or you can add some additional email address to send this email in case the user doesn't have a manager.

     

    Tatiana

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    I am manager of that test user.

     

    But I added text before the { in the message field and that maybe isn't possible?

     

    Best regards

    Niklas

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Yes, you should add text to $header and $body variables.

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    HI

     

    Everything works fine except this error.

    Cannot process command because of one or more missing mandatory parameters: To.

    Something is wrong with this- $(GetMailPropertyByDn -ObjectDN $FoundObject.manager)

    /Niklas

     

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Hi Niklas, 

     

    Please create a support case and send us the logs.

     

    Tatiana

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    Hi Tatiana!

    This workes fine now.

    Thanks for your help.

     

    Best regards

    Niklas

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    Hi, Tatiana!

    This solution works very well.

    But would it be possible to handle an empty manager attribute in the To: field?

    $(GetMailPropertyByDn -ObjectDN $FoundObject.manager)

     

    I get an error when the manager attribute is empty and my colleagues don't think that the Suspend worked for such an account.

     

    Best regards

    Niklas

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Hi Niklas, 

     

    You can add to TO field administrator email, for example. In this case, you always will have To field not empty and won't get the error: 

    $((GetMailPropertyByDn -ObjectDN $FoundObject.manager),"admin@domain.com")

     

    Please let me know if it works for you.

     

    Tatiana

     

    0
    Comment actions Permalink
  • Avatar
    Niklas Myrnäs

    Hi Tatiana!

    I have an additional question to this case as well. Sorry!

    This setup works really well and we use it to send an email to our Helpdesk system that in turn uses the email to create a helpdesk case with a bunch of related escalated child cases.

    Now to my question; IF I want to schedule the suspend I need the email to be sent on the date I have scheduled the actual suspend. In short, I want the email to be scheduled as well. Is this possible?

    Best regards

    Niklas

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Unfortunately, that is not possible now. I added this scenario to the enhancement request 4547.

     

    Tatiana

    0
    Comment actions Permalink
  • Avatar
    Jesse Tucker

    Hi, I just came across this post and I'm trying to accomplish something very similar. 

    Tatiana Golubovich - in your last post you mentioned this was an enhancement request to allow for a scheduled suspend operation to send this automated email at the time of the suspension-- was that ever taken up/completed?  I'm trying to figure out a way enable scheduled suspends and have the email go out to the user's manager at the time the suspension occurs, rather than immediately upon scheduling it.  

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Hi Jesse, 

    We do not have any specific date for this enhancement request. 

    This enhancement request will be regularly reviewed for possible inclusion into a future version or product. Due to many factors including the popularity of the request, the complexity of the request, and other business drivers - Cayosoft cannot guarantee this request will be included in any specific product or version.

    You can use the tracking number 4547 to check for the feature in our release notes and when you contact Cayosoft about the current status of the request.

    Tatiana

     

    0
    Comment actions Permalink
  • Avatar
    Derek Michals

    I just came across this post and it helped me with several things

    Tatiana Golubovich I seem to be having an issue with $(GetMailPropertyByDn -ObjectDN $FoundObject.manager).  It never returns a value even when I know that they have a manager assigned.  

     

    Derek 

    0
    Comment actions Permalink
  • Avatar
    Tatiana Golubovich

    Hi Derek, 

    Please check that manager has an email set in the mail attribute.

     

    Tatiana 

    0
    Comment actions Permalink

Please sign in to leave a comment.