Need Help Writing a Script

Hello all,

I'm a newbie to writing code. I'm not a developer of any kind but have studied coding and am now trying to get my feet wet.

I'm trying to write a simple script that will sync the FileVault password with the login password for a mobile account, on a domain bound Mac. Here are the commands I'd like the script or app to run, however if you look at the commands, where it says, "Username" I'd need the script to be able to discover the username of the account that's logged in and enter it at certain points.

Here are the instructions I've been given and do manually, along with the commands to be run in terminal. I'd like the script to be able to handle all this.

Re-synced FileVault and login passwords within the user's account
  1.       Open Terminal and enter the following (wsadmin is the local admin account name):

 
su wsadmin

(The wsadmin username would be the same for all Macs this script would be run on so I assume I'd just replace wsadmin with the local admin account name)

2.      Enter the wsadmin password when prompted. Terminal hides the password while you type, so just type it and then press Enter when done.

(For this step, is there anyway to get the script to show a prompt asking for this password?)

3.      Enter the following command to view active accounts. Then it will prompt you to enter wsadmin password:

sudo fdesetup list

(The account that is usually targeted by this shows up first in the fdesetup list and is the user's logged in ID. For example C123456 would be the account name and user's ID)

 4.      Enter the following, replacing USERNAME with the user’s network account, for example C123456. or jsmith. This step removes the user from this FileVault screen:

sudo fdesetup remove -user USERNAME

(Where it says USERNAME, is there anyway I can write some variables so the script can discover the username of the logged in account and automatically enter it there?)
 
5.      Enter the wsadmin password when prompted.

(I'd need the script to prompt again for the wsadmin account's password.)

6.      Enter the following, replacing USERNAME with the user’s network account:

sudo fdesetup add -usertoadd USERNAME
Enter the user name: wsadmin
Enter the password for user ‘wsadmin’: wsadmin password
Enter the password for the added user ‘USERNAME’: USERNAME’s password

(This time I'd need the script to prompt for which user to add at USERNAME. Then prompt for the wsadmin username, then prompt for the wsadmin password and finally, prompt again for the added user's account password.)

I do this manually each time however, there are some techs that aren't very familiar with terminal so I'd like a script or app that can make this entire process easier. Thanks for reading and I'd greatly appreciate any assistance with this!
Need Help Writing a Script
 
 
Q