Ste*_*nio 10 windows active-directory
我可以用runas /netonly
and开始一个进程,runas /savecred
但我不能同时使用这两个标志。
有没有办法以不同的用户远程运行进程而不必每次都输入密码?
在另一个答案中,Jason 正确地指出,runas /netonly
不支持保存凭据,并且 Microsoft故意使其难以使用硬runas
编码密码(来自批处理脚本)。
当您希望始终使用指定的凭据连接到给定服务(即)时,Stefano 在评论中指出的使用 Windows 凭据管理器的建议非常有用。myserver.mycompany.com:XXX
对于命令行解决方案,其行为类似于 runas.exe,但无需输入密码,我发现RunAs powershell 模块(似乎实现了此建议)非常有用:
通过在提升的 PowerShell 提示符中运行以下命令从 PowerShell 库进行安装(需要 Powershell v5 或 Windows 10):
Install-Module RunAs
Run Code Online (Sandbox Code Playgroud)通过运行以下命令加密密码:
# change `domain\username` as needed:
ConvertFrom-SecureString (Get-Credential 'domain\username').Password
Run Code Online (Sandbox Code Playgroud)
这将提示您输入登录名和密码,并打印一个长的十六进制数字,您必须复制该数字。
现在您可以执行与使用相同的操作runas /netonly
:
Import-Module RunAs
# replace xxxx below with the encrypted password from step 2 (and `domain\username` too)
# you might want to put this into your profile: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7
$mycreds = New-Object Management.Automation.PSCredential('domain\username', (ConvertTo-SecureString 'xxxx'))
runas -netonly $mycreds "c:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE"
Run Code Online (Sandbox Code Playgroud)PS 网上的许多资源建议使用psexec以不同用户身份运行。在了解了它的工作原理之后,我不认为它是一个可行的替代方案runas /netonly
恐怕这是一个不受支持的选项,您可以提供 /netonly 或 /savecred 但不能同时提供:
runas [{/简介 | /noprofile}] [/env] [{/netonly | /savecred}] [/smartcard] [/showtrustlevels] [/trustlevel] /user: " "
更多信息:https : //technet.microsoft.com/en-us/library/cc771525.aspx
归档时间: |
|
查看次数: |
7910 次 |
最近记录: |