
If you need to run something as the local admin then you can test for that. See below:
function Test-Administrator
{
$User = [Security.Principal.WindowsIdentity]::GetCurrent();
return (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
If you're not admin it returns 'False'.

And you will never guess what it brings back if you are an admin user...

Edit: Some neckbeard on Reddit accused me of stealing this code, which I absolutely did not. However in the interest of playing fair here are some other sources where you could find something similar to this. (Sources provided by Mr NeckBeard.)
