Mapping network drives

fbaker
New Contributor III

I'm trying to get a simple mount volume script to run when a user logs on to their macbook airs or iMacs. I write the script, then assign it in a policy to run on my test macbook on login. I'm not getting any drives mapped at all. I can cmd+k and type that in and it will map.

The way I've had to do this in our old MDM is actually use package maker and make a .pkg file out of the script and have it install into the applications folder and then have it execute the script when somebody logs in. I'm wanting to try and avoid it and my scripting knowledge is pretty limited when it comes to macs.

Is there any reason this wouldn't be working, or should I be doing something else?

The script is as follows

set str_username to (do shell script "whoami")
tell application "Finder" mount volume "smb://staff.domain/home/" & str_username mount volume "smb://domain/staff/staff shared data/District" mount volume "smb://domain/staff/staff shared data/TS" mount volume "smb://domain/staff/staff shared data/HS" mount volume "smb://student.domain/home/TS"
end tell

Everything in the script has its own line. Not sure why it's all running together.

12 REPLIES 12

nessts
Valued Contributor II

not sure but you have staff.domain in some places and domain/staff in others.
I would make it be a launchAgent that runs your script when people login, there are many ways of creating the lauchagent check the archives for one that suits you.

guidotti
Contributor II

Maybe use something like this:

https://jamfnation.jamfsoftware.com/discussion.html?id=5824

fbaker
New Contributor III

@nessts I know. That's how the scripts were wrote previously, otherwise they wouldn't connect to the correct folders.

@guidotti Thanks, I'll check that thread out. I did some searching earlier but a lot of it was scripting that I didn't quite understand.

davidacland
Honored Contributor II

There doesn't look seem to be anything wrong with the code. I've just tried it on my Mac (substituted with one of our servers) and it worked fine.

Which shares is it failing on? (or is it all of them)?

fbaker
New Contributor III

@davidacland It's not even acting like it's trying to run. I can try to assign the script in self service and see if I get an error message there.

davidacland
Honored Contributor II

It sounds like it might not be running, or the policy is running but not triggering the script. Are there any indications in the policy logs?

ahambidge
New Contributor II

@fbaker , is there a specific reason you're using a script with a LaunchAgent and not a Configuration Profile?

Kaltsas
Contributor III

This is what I use (it's been cobbled together from multiple sources and had diddled with a few times over the past couple of years). I package it as a run only applescript application dropped in Applications with an associated launch agent.

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

--- User Information

-- Get the logged in users username on theSplit() try set fulluser to do shell script "whoami" set AppleScript's text item delimiters to "\" set parts to text items of fulluser set firstitem to the first item of parts set seconditem to the second item of parts set slash to "\" set username to seconditem on error set username to do shell script "whoami" end try return username end theSplit set loggedInUser to theSplit() -- Get the Users account UniqueID set accountType to do shell script "dscl . -read /Users/$(whoami) | grep UniqueID | cut -c 11-" -- Get the nodeName from the Users account set nodeName to do shell script "dscl . -read /Users/$(whoami) | awk '/^OriginalNodeName:/,/^Password:/' | head -2 | tail -1 | cut -c 2-" -- Get the Users group membership from AD set ADGroups to do shell script "dscl " & quoted form of nodeName & " -read /Users/$(whoami) | awk '/^dsAttrTypeNative:memberOf:/,/^dsAttrTypeNative:msExchHomeServerName:/'" -- Get the Users AD Home Folder set ADHome to do shell script "dscl " & quoted form of nodeName & " -read /Users/$(whoami) | grep SMBHome: | cut -c 10- | sed 's/\\/\//g' " -- Checks to see if account is an AD Account, if its not exit if accountType is less than 1000 then tell me to quit end if

--- Drives

--Home Folder -- Maps the drive specified in the profile field for the AD User continue if user has no profile path set try mount volume "smb:" & ADHome on error end try -- Checks Group Membership for ADGroups contains user & if they -- are in the correct groups, mount shares. --------- -- Research Drive Mapping -- -- Application Drive Mappings -- if ADGroups contains "usergroup2" then mount volume "smb://totesafileserver/Apps" end if if ADGroups contains "usergroup2" then mount volume "smb://totesafileserver/CGI" end if

bentoms
Release Candidate Programs Tester

@Kaltsas I recognise some of that script. :P

@fbaker This is an outline of what we do.

Kaltsas
Contributor III

I only cobble from the best. There's about 170 more of those drive mappings. We have so many shares people want mapped as drives.

bpavlov
Honored Contributor

A bit unrelated but the number 170 just reminded me of a job where I had to assist a user with reconfiguring their account on their Windows 7 PC. They used up the entire alphabet of letters for shared network drives they needed mapped. Just ridiculous.

Mudalige
New Contributor III

Hi All, I'm very new to MAC and we bought a jamf pro cloud license for our school. Currently not using LDAP as this is on cloud based and in near future I will be implementing Jamf Infrastructure Manager on DMZ to sync our on premise AD through JIM. Devices are already enrolled in JAMF and Bound to AD as well. I would like to mount our network AD student home drives to the devices when student log in. I have tried to map these using configuration policies. However, it seems to be nothing is mapping at the moment. would anyone be able guide me with how to set this up ? Thanks in advance.