Why is same privileged bash command giving different information from script than from command line?
The difference comes from the change in shell environment once elevated. I'm not sure how you would write a script that would account for this change easily, but the answer to my original question is that you need to be aware of such differences when you elevate privileges.

Thanks to "thankyour" for this lead. I finally posted this as an answer since they didn't for some weeks.