发布于 2021-08-08 18:17:03
您可以通过传递要运行的用户的凭据,从提升的会话中运行非管理进程。如果希望以交互方式运行,可以使用Get-Credential
;如果希望脚本无人参与运行,则可以使用Import-Clixml
或SecretStore或其他已建立的机制来存储和检索凭据。例如:
$credential = Get-Credential -UserName $Env:USERNAME
# or
$credential = Import-Clixml -Path 'C:\MyCredential.cred'
Start-Process -FilePath pwsh.exe -ArgumentList '-noprofile' -Credential $credential -Wait
https://stackoverflow.com/questions/29569292
复制相似问题