Powershell Script and Group Policy

mara2021 1,121 Reputation points
2022-12-07T00:00:27.487+00:00

I wrote a powershell script that helpdesk uses to give user temporary access to a lockdown computer. We have a local temporary access group on the computer. A time stamp(file) is created. when a user is added.

I wrote a second script to remove the user from the group if timestamp is older than a day. The second script is added to a Group Policy at logon.

If I login to the workstation, users in the group older than a day are removed from the local group. I have admin rights. I am able to remove.

I would like the group to be cleaned up even if a non admin. Thanks for your help.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-12-07T03:16:20.54+00:00

    Are your timestamp files inheriting permissions from the directory, or are they assigned specific permission at the time they're created?

    If they're inheriting the permissions, change the permissions at the directory. If you're assigning them specific permissions at creation time, change the code that creates the files.


  2. Hoekstra Jelle 501 Reputation points
    2022-12-07T14:59:53.023+00:00

    I think you are right, permissions might be the issue here as deletion requires permissions.
    You could consider setting up the 2nd script locally (push) or make it available through a share followed by creating a scheduled task which runs under the systems account with trigger "upon signin > each and every user"
    Please let me know if this would work for you.

    ----------

    If this helps, please accept the answer and upvote

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.