1

Closed

Failure when Ps started non-Elevated by user other than Administrator

description

By default In Windows 2008 Server, the built in Administrator account automatically starts all processes with Elevated Privildges
Other accounts which are members of the administrators group need to Explicitly run Powershell AS ADMINISTRATOR.
To warn users that they are running non-Elevated, code similar to the following will be incorporated in builds after 0.9.
 
Function test-Admin
{Param ([Switch] $verbose)
$Local:ErrorActionPreference = "SilentlyContinue"
new-psdrive -name HKUSERS -psp "registry" -root "HKEY_USERS" | out-null
dir hkusers:\s-1-5-20 | out-null
$result=($error[0].exception -notmatch 'registry access')
if ($verbose) {if ($result) { write-host -ForegroundColor Green "This session has elevated priviledges" }
             else         { write-host -ForegroundColor Red   "This session does not have elevated priviledges."}}
Remove-PSDrive hkusers | out-null
$result
}
 
test-admin -v | out-null
Closed Jan 26, 2009 at 8:04 PM by jamesone

comments