Originally published on 2017-11-28

Small Applescript snippet for Mounting Network share drive on a Mac

set MyShare to "MyShare"
set OpenShare to "OpenShare"
tell application "System Events" to set diskNames to name of every disk
set myDisks to {MyShare, OpenShare}
repeat with myVolume in myDisks
try
if myVolume is in diskNames then
tell application "Finder" to eject disk myVolume
end if
moutVolume(myVolume)
delay 1
end try
end repeat
-- have it as a subroutine for future re-use
on moutVolume(myVolume)
mount volume "smb://networkspace2.local/" & myVolume as user name "adminnnn" with password "blahblah"
end moutVolume