I need to check whether the user executing the script has administrative privileges on the machine.
I have specified the user executing the script because the script
By doing this you break scenarios where the user has the required privs for your script but does not belong to Administrators. Instead of checking for group membership, check for the specific abilities you require.