I added a new Function called FixWhitelistedApps, which will check to see if any of the Whitelisted Apps were removed, and if so it should re-add them.
I then changed the code in the function Start-Debloat, given to me by Reddit user /u/GavinEke.
I fixed the issue where the whitelisted apps were being removed.
I then changed the conditional operator on lines 22-25, and lines 36-39, from -notlike to -notcontains. I also removed the asterisks from the AppXPackage/AppXProvisionedPackage names which results in the whitelisting working appropriately. The whitelisted apps are no longer being removed.
I added a $SysPrep switch parameter and function on lines 7 - 17. This will run the following command: get-appxpackage | remove-appxpackage. This is required in order to be used successfully with SysPrep.
I also added a $StopEdgePDF parameter, for those who do not wish to stop Edge from being used as the default PDF viewer, or for those who worry about unintended consequences (not being able to potentially choose Edge without removing the specified registry keys).
You can now run the script with the switch parameter -SysPrep, along with -Debloat, and -StopEdgePDF.