Sure! I Owe a lot credit to macmule.com, as that's where I pulled the most important part of this script. The rest I wrote on my own. Here's the first portion that runs on client machines at startup. It's importnat to note that in profile manager this is setup to run under Login Items > Items, using the path to the applescript application. NetworkDrives.app is the name of the application that it checks for on the logon server. Of course you can substitute names for whatever you choose.
try
-- Get the logged in users username
set loggedInUser to do shell script "whoami"
set accountType to do shell script "dscl . -read /Users/" & loggedInUser & " | grep UniqueID | cut -c 11-"
-- 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 Users Primary Domain
set Domain to do shell script "dscl " & quoted form of nodeName & " -read /Users/" & loggedInUser & " | awk /PrimaryNTDomain:/"
-- Mount logon drive based on users Primary Domain
if Domain = "PrimaryNTDOMAIN: Domain1" then
mount volume "smb://Domain1FQDN/netlogon"
end if
if Domain = "PrimaryNTDOMAIN: Domain2" then
mount volume "smb://Domain2FQDN/netlogon"
end if
if Domain = "PrimaryNTDOMAIN: Domain3" then
mount volume "smb://Domain3FQDN/netlogon"
end if
--the delay allows time after mapping to run other commands before unmounting the logon drive
delay 4
--Checks if the logon script exists on the local machine and if not copies it from the logon server
tell application "Finder"
if not (exists ("Macintosh HD:Users:" & loggedInUser & ":NetworkDrives.app")) then duplicate file "netlogon:NetworkDrives.app" to folder ("Macintosh HD:Users:" & loggedInUser & ":")
end tell
--Compares the date of the script located on the logon server vs. locally stored copy. If server side is newer copys the new file
tell application "Finder" to set Path1 to file ("Macintosh HD:Users:" & loggedInUser & ":NetworkDrives.app")
set modDate1 to modification date of Path1
tell application "Finder" to set Path2 to file "netlogon:NetworkDrives.app"
set modDate2 to modification date of Path2
if modDate1 < modDate2 then
set source to "netlogon:NetworkDrives.app"
set destination to "Macintosh HD:Users:" & loggedInUser & ":"
tell application "Finder"
duplicate file source to folder destination with replacing
end tell
end if
--unmounts logon drive. The user may see this for a few split seconds.
tell application "Finder"
eject "netlogon"
end tell
--tells actual logon script to run
tell application "NetworkDrives.app"
activate
end tell
end try