Temporary group membership

HI,  I would like to add a group by midnight through a script, I know the GUI has the setting to set date and time but how would I do it using a script.

Command:

Add-QADgroupmember -identity "groupname" -member $ADuser   (tonight at midnight)

any help would be much appreciated  Slight smile

Parents
  • so would you say this is correct, to start at 10PM

    $SetTime = get-date -Date (Get-date).Date -Hour 22 -Minute 00 -Second 00
    $ControlHash=@{}
    $ControlHash.Add('ScheduledOperation-SetTime',$($SetTime))
    Add-qadgroupmember -identity "TheGroup" -members $user -Control $ControlHash -Proxy

Reply
  • so would you say this is correct, to start at 10PM

    $SetTime = get-date -Date (Get-date).Date -Hour 22 -Minute 00 -Second 00
    $ControlHash=@{}
    $ControlHash.Add('ScheduledOperation-SetTime',$($SetTime))
    Add-qadgroupmember -identity "TheGroup" -members $user -Control $ControlHash -Proxy

Children
  • Yes

    Bear in mind however, the time that gets set is based upon your local time... so in the UK for example, currently we are in British Summer Time (GMT+1 or UTC+1), therefore if I were to add at 10, it would shown in the console as 11....

    IE I ran this:

    And it resulted in this:

    As always time zones can result in your results appears differently, so take account of this when writing/running your script. There are methods to set the time as GMT/UTC, or to the offset you require.