Jump to content

AD Group conditional startup script if anyone wants?


Recommended Posts

Posted (edited)

Hi All,

 

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! :)

 

startup_1.5.ps1.zip

 

USE'S:

---------------------

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!

 

INSTRUCTIONS:

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:

 

$drivelist = 	('authenticated users', 'G:', '\\server\projects'),
			('group1', 'Z:', '\\server\tsweb'),
			('accounts', 'Y:', '\\server\tsweb')

 

the format is: ('GroupName', 'DriveLetter', 'UncPath')

 

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:

script_output.jpg

the output is mearly there incase you want to manually run the script, or pipe it to a txt file or somthing...

 

Enjoy!

 

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!

 

Tom

Edited by TornUp

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...