Shell.current.isPrivilegedUser
at the start of the script and force users to restart with the required privileges.isPrivilegedUser
method however often you will want to only use escalated privileges for some of the script which is possible with the Shell.current.withPriviliged
method.