Get current server date time from Active Roles

Hello,

Anyone please let me know how to get current server date time or how to convert current date time to specific timezone within the active roles and I wanted to set the date time to a virtual attribute. I'm unable to fix this issue. Here is the code I've using. Do let me know if you need any other info.

$currentDt = Get-Date
$currentDt = Get-Date $currentDt -Format "M/d/yyyy hh:mm:ss"

Thanks

Parents Reply Children
  • I tried but still seeing issue.

    Below is the OnPostUnDeprovision code, I'm using to set an attribute value to match the current server date time.

    $currentDt = Get-Date
    $currentDt= $currentDt.AddHours(7)
    $currentDt = Get-Date $currentDt -Format "MM/dd/yyyy hh:mm:ss"
    Set-QADUser -Proxy $dn -ObjectAttributes @{'namm-UndoDeprovisionDate'=$currentDt}

    Below are the values after running the code.

    Current Server date time: 8/23/2022 7:08 AM

    namm-UdeoDeprovisionDate: 8/22/2022 7:08 PM 

    I wanted to update the attribute value wit Current Server date time.

    Let me know if you need any other info.

    Thanks,

    Kishore

  • I was looking response from you on this.