Last active
June 16, 2016 20:41
-
-
Save tempusthales/4f96b375fbe2bc905e77f7681942af98 to your computer and use it in GitHub Desktop.
AppleScript to automate adding mapped drives to mac via AD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------------------------------------------- | |
-- | |
-- Drive Mapping Script | |
-- Original by Ben Toms | MacMule / Modified By: Gilbert Palau | |
-- | |
---------------------------------------------------------------------------------------------------- | |
------------------------------- | |
--- User Information Logic | |
------------------------------- | |
-- Get the logged in users username | |
set loggedInUser to do shell script "whoami" | |
-- Get the Users account UniqueID | |
set accountType to do shell script "dscl . -read /Users/" & loggedInUser & " | grep UniqueID | cut -c 11-" | |
-- Get the nodeName from the Users account | |
set nodeName to do shell script "dscl . -read /Users/" & loggedInUser & " | 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/" & loggedInUser & " | awk '/^dsAttrTypeNative:memberOf:/,/^dsAttrTypeNative:msExchHomeServerName:/'" | |
-- Get the Users AD Home Folder | |
set ADHome to do shell script "dscl " & quoted form of nodeName & " -read /Users/" & loggedInUser & "| grep SMBHome: | cut -c 10- | sed 's/\\\\/\\//g' " | |
-- set SMBH to do shell script "dscl . read /Users/$USER 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 ADHome -- contains the correct server then, mounts the shares. | |
-- Caribbean - on some beach | |
if ADHome contains "name.of.your.fileserver" then | |
mount volume "smb://name.of.your.fileserver.fqdn/group" | |
mount volume "smb://name.of.your.fileserver.fqdn/public" | |
end if | |
--- Rinse and repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment