adminロールを持つユーザーを使用しています。ただし、デフォルトでは、スクリプトは管理者としてではなくUACモードで実行されます。 UACダイアログボックスを使わずにpowershellスクリプトでpowershellコンソールを開くことは可能ですか?PowershellがPowerShellコンソールをUACダイアログボックスなしで管理者モードで開き、何らかのタスクを実行する
私は次のようにやってみたいけど、それは私に出席する必要があります]ダイアログボックスを与えるタスク上昇しようとした:しかし、これは私がしたい場合は確認してUACのダイアログボックスが開きます
# Get the ID and security principal of the current user account
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID);
# Get the security principal for the administrator role
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator;
# Check to see if we are currently running as an administrator
if ($myWindowsPrincipal.IsInRole($adminRole))
{
# We are running as an administrator, so change the title and background colour to indicate this
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)";
$Host.UI.RawUI.BackgroundColor = "DarkBlue";
Clear-Host;
}
else {
# We are not running as an administrator, so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit;
}
#DOING SOME TASK HERE
を管理者モードでPowerShellを開きます。
私が試したもう一つの方法は、デフォルトで管理者モードでPowerShellコンソールを開くことです(私はWS 2012を使用し、これを行う方法はWindows 10と同じです)。しかし、私はDevOpsが私にそうしないようにシステムにこのような変更を加える権利を持っていません。これに対処するためにPowerShellスクリプトを使って他の方法がありますか?
何が投票されますか?私は、有権者が同じ理由を提供するよう、有権者に要求する。 – Rishi
私は時間の短い量で昨日のdownvotesのいくつかを得た - その男が持っていたか、誰かがハックした問題を知らない – DAXaholic