首页 > 其他 > 详细

sharepoint 脚本 强迫以管理员权限运行

时间:2015-11-27 19:14:33      阅读:262      评论:0      收藏:0      [点我收藏+]
#region 关键代码:强迫以管理员权限运行
$currentWi = [Security.Principal.WindowsIdentity]::GetCurrent() 
$currentWp = [Security.Principal.WindowsPrincipal]$currentWi
 
if( -not $currentWp.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) 
{ 
  $boundPara = ($MyInvocation.BoundParameters.Keys | foreach{
     ‘-{0} {1}‘ -f  $_ ,$MyInvocation.BoundParameters[$_]} ) -join ‘ ‘
  $currentFile = (Resolve-Path  $MyInvocation.InvocationName).Path 
 
 $fullPara = $boundPara + ‘ ‘ + $args -join ‘ ‘
 Start-Process "$psHome\powershell.exe"   -ArgumentList "$currentFile $fullPara"   -verb runas 
 return
} 
#endregion

 

sharepoint 脚本 强迫以管理员权限运行

原文:http://www.cnblogs.com/wodegui/p/5001179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!