AD Group conditional startup script if anyone wants?
so, I am in the process of learning Powershell, and my first real project was to build a startup script responsible for mapping network drives. what i did yesterday, then today(version 1.5) i added more functionality to map network drives depending upon what AD group the user is part of. and here it is! :)
Whatever you want! lol... rip it apart, use it entirly, I don't mind!
Although if you do any form of bug fixing, or have any feedback/advice then please post it here! As i mentioned, im still learning. so need feedback!
If you open the file up(i recommend opening it in notepad++, windows notepad doesn't seem to appricate the tab "lining up") for editing you will find an array at the top that looks a little like:
the format is: ('GroupName', 'DriveLetter', 'UncPath')
$drivelist = ('authenticated users', 'G:', '\\server\projects'),
('group1', 'Z:', '\\server\tsweb'),
('accounts', 'Y:', '\\server\tsweb')
GroupName is the name of the AD group the user must be a member of for that drive to be mapped (using "authenticated users" or "domain users" will result in the drive being mapped for everyone, good for common drives!!)
DriveLetter is the drive letter you want mapped drive to be set as!
UncPath is the path to the server (EG: \\server\share\folder\subfolder\etc)
The script removes all the network drives(only the drives that appear in the array! so if a user has manually mapped a drive, this will not effect it!) and then simply re-add's them all again!
This is a screenshot of the script being run, normally though it should just exit without seeing any of this:
the output is mearly there incase you want to manually run the script, or pipe it to a txt file or somthing...
just to cover my arse:
Although my code doesn't contain anything malicious I offer this "as is" and can not be held responsible for any loss of data, profits, life or consumable goods such as cookies, doughnuts or Coke Cola. IE. run it in a sandbox enviroment first! don't just throw it on all users startup!