第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PowerShell:以管理員身份運行命令

PowerShell:以管理員身份運行命令

PowerShell:以管理員身份運行命令您知道如果您是系統(tǒng)的管理用戶,您可以右鍵單擊“說”,批處理腳本并以管理員身份運行它而不輸入管理員密碼嗎?我想知道如何使用PowerShell腳本執(zhí)行此操作。我不想輸入密碼; 我只是想模仿右鍵單擊Run As Administrator方法。到目前為止我讀到的所有內(nèi)容都要求您提供管理員密碼。
查看完整描述

3 回答

?
躍然一笑

TA貢獻1826條經(jīng)驗 獲得超6個贊

如果當前控制臺未升級并且您嘗試執(zhí)行的操作需要提升權(quán)限,則可以使用“以管理員身份運行”選項啟動PowerShell

PS> Start-Process powershell -Verb runAs


查看完整回答
反對 回復(fù) 2019-07-23
?
Helenr

TA貢獻1780條經(jīng)驗 獲得超4個贊

這是Shay Levi建議的補充(只需在腳本的開頭添加這些行):

If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){   $arguments = "& '" + $myinvocation.mycommand.definition + "'"Start-Process powershell -Verb runAs -ArgumentList $argumentsBreak}

這會導(dǎo)致當前腳本以管理員模式傳遞給新的PowerShell進程(如果當前用戶可以訪問管理員模式,并且腳本未以管理員身份啟動)。


查看完整回答
反對 回復(fù) 2019-07-23
?
慕萊塢森

TA貢獻1810條經(jīng)驗 獲得超4個贊

自升式PowerShell腳本

Windows 8.1 / PowerShell 4.0 +

一條線 :)

if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

# Your script here


查看完整回答
反對 回復(fù) 2019-07-23
  • 3 回答
  • 0 關(guān)注
  • 3217 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號