Powershell - "IF NOT MEMBER OF" then EXIT
11/07/2016 636 views
We have a domain with 250 users.
I have written a very simple PS script - The script runs at login (as a Group policy login script - bit its only aimed at two departments only) the script checks for the existence of a "flag file" in a user share - if it doesn't exist, then it copies some files and folders from an "application" share down to the users local drive, and then creates a flag file into the users network share)
It all works fine, but the only snag is, it runs for everyone, and if the person doesn't have permission to the network share (not in the right security group, it still runs the script, and creates the flag file - but cant copy the files.
Now, although its not a massive problem, it would be great if the script could do a check as it launches, checking the users security group permission, to dictate if the script runs or not, something like, IF NOT MEMBER OF "domain\tax" then QUIT else proceed...
Is this easily achievable?
Many thanks for reading.