Replace $userName for $dbuserName 
Replace $userName for $dbuserName 

If user has different name than login won't script the permissions
SirCaptainMitch/dbatools,dsolodow/dbatools,Splaxi/dbatools,sqlpadawan/dbatools,wsmelton/dbatools,kozloski/dbatools