.
, :
$CurrentID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$CurrentPrincipal = new-object System.Security.Principal.WindowsPrincipal($CurrentID)
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
if ($CurrentPrincipal.IsInRole($adminRole)) {
write-host "Yes we are running elevated."
}else{
write-host "No this is a normal user session."
}
, , , :
$newProc = new-object System.Diagnostics.ProcessStartInfo "PowerShell"
$newProc.Arguments = "powershell.exe"
$newProc.Verb = "runas"
[System.Diagnostics.Process]::Start($newProc)
, , , ...
. , , .
: "" . .NET/PowerShell . ( 12 COM-). vista-7-uac-how-to-lower-process-privileges .
, , "" explorer.exe.
.exe, explorer.exe, .
$newProc = new-object System.Diagnostics.ProcessStartInfo "PowerShell"
$newProc.Arguments = "explorer.exe C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
[System.Diagnostics.Process]::Start($newProc)
EDIT # 2: , , - runas.exe 0x20000 ( ):
C:\> runas /showtrustlevels
The following trust levels are available on your system:
0x20000 (Basic User)
C:\> runas /trustlevel:0x20000 devenv
