Automatically Set Temporal Membership when Adding Member to Group - Update

Hi. 

I could not reply to the original post from 5 years ago. I have included the link below for reference. If you are still on the site, thank you,  , the code you provided is fantastic. I have modified it slightly as I need temp group membership on some groups in terms of hours rather than days.  

Again, thank you, and I hope this helps someone else in the future. 

https://www.oneidentity.com/community/active-roles/f/forum/29153/automatically-set-temporal-membership-when-adding-member-to-group

# BEGIN SCRIPT #
function temporalGroupMembership($Request){
    $users = $workflow.SavedObjectProperties("AddedMembers").getEx("member")
    $groupDN = $Request.Get("distinguishedName")

    $time = (Get-Date).AddMinutes(60).ToUniversalTime() # Modify here for the amount of time.
    
    $hash = @{}
    $hash.add("ScheduledOperation-SetTime",$time)


    foreach($userDN in $users){
        Remove-QADGroupMember -Identity $groupDN -Member $userDN -Control $hash
    }
}
# END SCRIPT #