Script student network share and home share drive

New Contributor III

Hi All Guru

Next year our school will go for BYOD, students are allow to bring their own Mac Book to school and it is not bind to AD but they have to enroll with Casper. How could i write the script that will map the student share and home folder share. I am not familiar with apple script at all.

These is the example scenario will be like:

A year 7 student and his username is 1234. In AD, he is in a permission group call Year 7. In the windows share server there is a share folder call serveryear7_share$.
Also have a home share drive call serverstudent_home$username (serverstudent_home$1234).
So when that year 7 student log on to his own Mac Book (local username), there is a mapping script on the desktop, and if he want to map the network share, he just need to run the mapping script. So the script will prompt him the username and password. Then the script will take his username and password and check against the AD authentication to see which permission group he is in. If he is in year 7, the script will map serveryear7_share$ and serverstudent_home$username.

This script will apply through year 7 - 12

Hope someone could help about this.


Release Candidate Programs Tester


I haven't the whole answer... But you should be able to adapt the ApplsScript app I have linked elbow for this.


New Contributor III

Hi Bentoms

Thanks for the link, so do i need to create 3 scripts? or come all in 1 script.

Release Candidate Programs Tester

You could just go with the AppleScript app & a Config profile to open it at login (this replaces the launch agent).

If you using it on 10.6 or are deploying printers then you may need the 3rd script.

New Contributor III

I am planning to use config profile instead of script. Do you have a example of mapping smb share at login in config profiles?


New Contributor

is this available for OD?

Valued Contributor III

Also if you just have the script attempt to mount the drive without credentials using an applescript call to the finder macOS should automatically prompt for credentials if it needs them.
Try something like this as a Self Service policy rather than a desktop icon, if you require authentication for Self Service it will populate the user i.e. $3 automatically, and you can have a seperate policy for each year scoped based on the members of that year with a first optional field for the script set to the year i.e. $4

Share_Path=$(echo "smb://server/year${YEAR}_share$")
Home_Path=$(echo "smb://server/student_home$/${CU}")
echo $Share_Path
echo $Home_Path
tell application "Finder"
mount volume "$Share_Path"
mount volume "$Home_Path"
end tell