Posted on 04-21-2015 12:15 PM
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.
Posted on 04-21-2015 12:20 PM
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.
Posted on 04-21-2015 12:34 PM
Maybe use something like this:
https://jamfnation.jamfsoftware.com/discussion.html?id=5824
Posted on 04-21-2015 12:44 PM
Posted on 04-21-2015 01:17 PM
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)?
Posted on 04-23-2015 05:47 AM
@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.
Posted on 04-23-2015 09:30 AM
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?
Posted on 04-23-2015 12:11 PM
@fbaker , is there a specific reason you're using a script with a LaunchAgent and not a Configuration Profile?
Posted on 04-24-2015 06:13 AM
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
Posted on 04-24-2015 09:01 AM
@Kaltsas I recognise some of that script. :P
Posted on 04-24-2015 09:04 AM
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.
Posted on 04-24-2015 09:58 AM
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.
Posted on 09-08-2020 02:54 AM
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.