Great question — answering as the UphillTech team:
original answer that applies to most users: When dpkg tries to finish the installation configuration for the kernel it runs grub-script-check when running grub-mkconfig to auto-generate /boot/grub/grub.cfg . If there is a problem with your configuration files, it will return this error. The error says that you have a syntax problem in /etc/default/grub or one of your other grub configuration files in your /etc/default/grub.d directory. If you recently made changes to any of your grub configuration files like /etc/default/grub or any other file in your /etc/default/grub.d directory, you need to correct or delete the changes made. After you fix the file or files, run the following command:...
Full answer by mchid: https://askubuntu.stackexchange.com/a/1207247 (CC BY-SA 4.0).
Need it done for your business? UphillTech.