This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

change deprovisioned user's reporting objects to it's manager

I am looking for a way to change all of a deprovisioned user's Direct Reports to the deprovisioned user's manager. For example I have Manager1 and Manager2. Manager2 has 50 employees who report to him listed under direct reports of manager2. Manager2 is listed under Manager1's direct reports and when I deprovision Manager2 I would like all of the employees reporting to him to now be reporting to Manager1. Make sense?

  • something like this:

    function onDeprovision($Request)
    {

    $DPDSAM = $DirObj.Get("sAMAccountName")
    $user=Get-QADUser -IncludeAllProperties $DPDSAM
    $manager = $user.manager
    $DirectReports = Get-QADUser -Manager $DPDSAM


    {
    foreach ($users in $DirectReports) { Set-QADuser -identity $users -Manager $manager }
    $action = $Request.AddDeprovisioningReportRecord()
    $action.Name = "$manager is the new manager of $DirectReports"
    $action.IsSuccess = $true
    }
    }