Initiator - Deprov Script

Hi Team.

I am sure I am doing something silly here. I have created a script to run as part of the provision process.

The script just adds some info to the Note attribute. Everything works fine except when I try to get the initiator value.

Any suggestions?

Administrative Policy returned an error. Deprovisioning policy failure. The 'Script Execution' policy encountered an error when deprovisioning a user. Failed to execute the script 'De-Prov - Stamp Notes Field'. At line: 5 char:1. [ref] cannot be applied to a variable that does not exist.

function onDeprovision($Request)
{

$Request.([ref]$strSam,[ref]$strDN)

$DeprovDate = (Get-Date).ToString("dd/MMM/yyyy hh:mm:ss")
$DeleteDate = (Get-Date).AddDays(30).ToString("dd/MMM/yyyy hh:mm:ss")

$notes = @"
Account Deprovisioned By: $strSam
*
Account Deprovision Date: $DeprovDate
*
Account Deletion Date: $DeleteDate
*
The account will be automatically removed on the deletion date above.   

"@

Set-QADUser -Identity $Request.GUID -IncludedProperties Notes -Notes $Notes
}

Parents
  • Got it working. Updated code below

    function onDeprovision($Request)
    {
    
    $strSan=""
      $strDN=""
      # --- Call the WhoamI method ---
      $request.WhoAmi([ref]$strSan,[ref]$strDN)
    
    
    $DeprovDate = (Get-Date).ToString("dd/MMM/yyyy hh:mm:ss")
    $DeleteDate = (Get-Date).AddDays(30).ToString("dd/MMM/yyyy hh:mm:ss")
    
    $notes = @"
    Account Deprovisioned By: $strSan
    *
    Account Deprovision Date: $DeprovDate
    *
    Account Deletion Date: $DeleteDate
    *
    The account will be automatically removed on the deletion date above.   
    
    "@
    
    Set-QADUser -Identity $Request.GUID -IncludedProperties Notes -Notes $Notes
    }

Reply
  • Got it working. Updated code below

    function onDeprovision($Request)
    {
    
    $strSan=""
      $strDN=""
      # --- Call the WhoamI method ---
      $request.WhoAmi([ref]$strSan,[ref]$strDN)
    
    
    $DeprovDate = (Get-Date).ToString("dd/MMM/yyyy hh:mm:ss")
    $DeleteDate = (Get-Date).AddDays(30).ToString("dd/MMM/yyyy hh:mm:ss")
    
    $notes = @"
    Account Deprovisioned By: $strSan
    *
    Account Deprovision Date: $DeprovDate
    *
    Account Deletion Date: $DeleteDate
    *
    The account will be automatically removed on the deletion date above.   
    
    "@
    
    Set-QADUser -Identity $Request.GUID -IncludedProperties Notes -Notes $Notes
    }

Children
No Data