Windows 10:获得远程访问权限后,以 .\Administrator 身份远程启动 Quick Assist,无需 UAC,或暂时禁用 UAC

2024-02-27

我想要a script在这种情况下使用:

  1. 无需管理员权限即可获得远程访问
  2. 远程启动快速协助.\Administrator and not进行 UAC 对话。

第 1 步通常通过 Quick Assist 完成,有时通过 Teams 屏幕共享完成。


I'm aware that I can locate quickassist.exe in File Explorer then use Shift and the context menu to Run as a different user, however I'd like a scripted approach.

实验A

这可行,但是有一个Yes/NoUAC对话:

$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ( -not $isElevated ) {
    Start-Process powershell.exe -Credential Administrator -NoNewWindow -ArgumentList {
        Start-Process quickassist.exe -Verb RunAs ;
    } ;
}

实验B

我犯了很多错误,不知道如何纠正。 (我正在尝试逐渐学习 PowerShell,但在学习时我很容易感到困惑;有点阅读障碍。)

$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

if ( -not $isElevated ) {
  Start-Process powershell.exe -Credential Administrator {
    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 0 -Force;
    };
  Write-Host "UAC (user account control) is weakened for a Quick Assist session …" -ForegroundColor Red;

  Start-Process powershell.exe -Credential Administrator -NoNewWindow -ArgumentList {Start-Process quickassist.exe -Verb RunAs -Wait};
  Write-Host "… Quick Assist session complete …" -ForegroundColor Red;

  Start-Process powershell.exe -Credential Administrator {
    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 1 -Force;
    };
  Write-Host "… UAC is strengthened." -ForegroundColor Red;
}
  • 对注册表的两次预期更改没有发生
  • 第三个证书对话出现得太早 – 我希望它出现not直到快速协助会话结束后才会出现。

另外,从概念上讲,当 UAC 暂时被削弱时,可能不需要以管理员身份运行 Quick Assist。

参考

https://stackoverflow.com/a/2258134/38108 https://stackoverflow.com/a/2258134/38108(2010-02-13) 我看到使用-Credential with Invoke-Command但是当我尝试做类似的事情来更改注册表时,我会弄得一团糟。

https://stackoverflow.com/a/47516161/38108 https://stackoverflow.com/a/47516161/38108(2017-11-27) 自提升 PowerShell 脚本。

https://superuser.com/a/1524960/84988 https://superuser.com/a/1524960/84988(2020-02-12) 和https://serverfault.com/a/1003238/91969 https://serverfault.com/a/1003238/91969(2020-02-15)很有趣——两个答案中的脚本相同——但是我需要类似的东西-Credential Administrator替代-ComputerName.

https://stackoverflow.com/a/60292423/38108 https://stackoverflow.com/a/60292423/38108(2020-03-07) 通过https://stackoverflow.com/a/60263039/38108 https://stackoverflow.com/a/60263039/38108

PowerShell 命令 - PowerShell - SS64.com https://ss64.com/ps/

https://github.com/okieselbach/Intune/blob/master/DisablePromptOnSecureDesktop.ps1 https://github.com/okieselbach/Intune/blob/master/DisablePromptOnSecureDesktop.ps1(2020-11-13) 通过快速协助 Windows 10 中的内置远程控制 – 现代 IT – 云 – 工作场所 https://oliverkieselbach.com/2020/03/03/quick-assist-the-built-in-remote-control-in-windows-10/


简短的回答是不。获取真正的远程管理工具或让某人点击 UAC yes 提示符。

这更像是 Windows 的事情,而不是 Powershell,因为 Windows 明确拒绝提升进程locally无需通过UAC(并且有充分的理由!)。你曾经可以做这样的事情:

# Use Enter-PSSession to start a "remote" session 
# This may still support elevation if you specify CredSSP and configure credential delegation):
New-PSSession MyPCName -Auth CredSSP -cred (get-credential)

# Create a scheduled task with RunAs/elevated permissions:
Register-ScheduledTask -Action $action -User .\Administrator -TaskName "Admin-Stuff" -RunLevel Highest

现在在本地运行时会发出拒绝访问的消息。您也无法在其中编辑注册表设置HKLM:没有提升,因此暂时禁用 uac 不是一个选择。

您也许可以利用这个exploit https://stackoverflow.com/a/60292423/7411885这允许管理员用户绕过 uac,但我认为您仍然必须以其他用户身份运行 shell 才能使用它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Windows 10:获得远程访问权限后,以 .\Administrator 身份远程启动 Quick Assist,无需 UAC,或暂时禁用 UAC 的相关文章

随机推荐